diff options
author | Ji Luo <ji.luo@nxp.com> | 2018-07-26 14:20:57 +0800 |
---|---|---|
committer | faqiang.zhu <faqiang.zhu@nxp.com> | 2018-08-24 14:48:35 +0800 |
commit | 8654c6f81ae69bd72e801511c9b534d104407620 (patch) | |
tree | 72ffe3658db864e670084ef7ad1aac760e81b6ea /drivers | |
parent | d26dee0793389c63bb3bfbd90f3cf2a11518d2c4 (diff) |
MA-12214: Wipe all userdate when lock/unlock
For Android, /data, misc, cache, presistdata, RBK are erased
when lock/unlock.
For Android Things, above partitions except misc are erased.
Change-Id: I4c9f5b81f15bf46322d6aea8d535d80f9ae7ca8b
Signed-off-by: Ji Luo <ji.luo@nxp.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/gadget/f_fastboot.c | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 03fd9a8dc38..2a6bf00ac6f 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -3198,11 +3198,40 @@ U_BOOT_CMD( "lock_status", "lock_status"); +static void wipe_all_userdata(void) +{ + char response[FASTBOOT_RESPONSE_LEN]; + + /* Erase all user data */ + printf("Start userdata wipe process....\n"); + /* Erase /data partition */ + fastboot_wipe_data_partition(); + +#ifdef CONFIG_ANDROID_SUPPORT + /* Erase the misc partition. */ + process_erase_mmc(FASTBOOT_PARTITION_MISC, response); +#endif + +#ifndef CONFIG_ANDROID_AB_SUPPORT + /* Erase the cache partition for legacy imx6/7 */ + process_erase_mmc(FASTBOOT_PARTITION_CACHE, response); +#endif + /* The unlock permissive flag is set by user and should be wiped here. */ + set_fastboot_lock_disable(); + + +#if defined(CONFIG_AVB_SUPPORT) && !defined(CONFIG_IMX_TRUSTY_OS) + printf("Start stored_rollback_index wipe process....\n"); + rbkidx_erase(); + printf("Wipe stored_rollback_index completed.\n"); +#endif + printf("Wipe userdata completed.\n"); +} + static FbLockState do_fastboot_unlock(bool force) { int status; - if (force) - set_fastboot_lock_disable(); + if ((fastboot_lock_enable() == FASTBOOT_UL_ENABLE) || force) { printf("It is able to unlock device. %d\n",fastboot_lock_enable()); if (fastboot_get_lock_stat() == FASTBOOT_UNLOCK) { @@ -3213,15 +3242,8 @@ static FbLockState do_fastboot_unlock(bool force) if (status < 0) return FASTBOOT_LOCK_ERROR; - printf("Start /data wipe process....\n"); - fastboot_wipe_data_partition(); - printf("Wipe /data completed.\n"); + wipe_all_userdata(); -#if defined(CONFIG_AVB_SUPPORT) && !defined(CONFIG_IMX_TRUSTY_OS) - printf("Start stored_rollback_index wipe process....\n"); - rbkidx_erase(); - printf("Wipe stored_rollback_index completed.\n"); -#endif } else { printf("It is not able to unlock device."); return FASTBOOT_LOCK_ERROR; @@ -3233,6 +3255,7 @@ static FbLockState do_fastboot_unlock(bool force) static FbLockState do_fastboot_lock(void) { int status; + if (fastboot_get_lock_stat() == FASTBOOT_LOCK) { printf("The device is already locked\n"); return FASTBOOT_LOCK; @@ -3241,9 +3264,7 @@ static FbLockState do_fastboot_lock(void) if (status < 0) return FASTBOOT_LOCK_ERROR; - printf("Start /data wipe process....\n"); - fastboot_wipe_data_partition(); - printf("Wipe /data completed.\n"); + wipe_all_userdata(); return FASTBOOT_LOCK; } |