Commit 8654c6f81ae69bd72e801511c9b534d104407620
Committed by
faqiang.zhu
1 parent
d26dee0793
Exists in
smarc_8mm-imx_v2018.03_4.14.98_2.0.0_ga
and in
5 other branches
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>
Showing 1 changed file with 34 additions and 13 deletions Side-by-side Diff
drivers/usb/gadget/f_fastboot.c
... | ... | @@ -3198,11 +3198,40 @@ |
3198 | 3198 | "lock_status", |
3199 | 3199 | "lock_status"); |
3200 | 3200 | |
3201 | +static void wipe_all_userdata(void) | |
3202 | +{ | |
3203 | + char response[FASTBOOT_RESPONSE_LEN]; | |
3204 | + | |
3205 | + /* Erase all user data */ | |
3206 | + printf("Start userdata wipe process....\n"); | |
3207 | + /* Erase /data partition */ | |
3208 | + fastboot_wipe_data_partition(); | |
3209 | + | |
3210 | +#ifdef CONFIG_ANDROID_SUPPORT | |
3211 | + /* Erase the misc partition. */ | |
3212 | + process_erase_mmc(FASTBOOT_PARTITION_MISC, response); | |
3213 | +#endif | |
3214 | + | |
3215 | +#ifndef CONFIG_ANDROID_AB_SUPPORT | |
3216 | + /* Erase the cache partition for legacy imx6/7 */ | |
3217 | + process_erase_mmc(FASTBOOT_PARTITION_CACHE, response); | |
3218 | +#endif | |
3219 | + /* The unlock permissive flag is set by user and should be wiped here. */ | |
3220 | + set_fastboot_lock_disable(); | |
3221 | + | |
3222 | + | |
3223 | +#if defined(CONFIG_AVB_SUPPORT) && !defined(CONFIG_IMX_TRUSTY_OS) | |
3224 | + printf("Start stored_rollback_index wipe process....\n"); | |
3225 | + rbkidx_erase(); | |
3226 | + printf("Wipe stored_rollback_index completed.\n"); | |
3227 | +#endif | |
3228 | + printf("Wipe userdata completed.\n"); | |
3229 | +} | |
3230 | + | |
3201 | 3231 | static FbLockState do_fastboot_unlock(bool force) |
3202 | 3232 | { |
3203 | 3233 | int status; |
3204 | - if (force) | |
3205 | - set_fastboot_lock_disable(); | |
3234 | + | |
3206 | 3235 | if ((fastboot_lock_enable() == FASTBOOT_UL_ENABLE) || force) { |
3207 | 3236 | printf("It is able to unlock device. %d\n",fastboot_lock_enable()); |
3208 | 3237 | if (fastboot_get_lock_stat() == FASTBOOT_UNLOCK) { |
3209 | 3238 | |
... | ... | @@ -3213,15 +3242,8 @@ |
3213 | 3242 | if (status < 0) |
3214 | 3243 | return FASTBOOT_LOCK_ERROR; |
3215 | 3244 | |
3216 | - printf("Start /data wipe process....\n"); | |
3217 | - fastboot_wipe_data_partition(); | |
3218 | - printf("Wipe /data completed.\n"); | |
3245 | + wipe_all_userdata(); | |
3219 | 3246 | |
3220 | -#if defined(CONFIG_AVB_SUPPORT) && !defined(CONFIG_IMX_TRUSTY_OS) | |
3221 | - printf("Start stored_rollback_index wipe process....\n"); | |
3222 | - rbkidx_erase(); | |
3223 | - printf("Wipe stored_rollback_index completed.\n"); | |
3224 | -#endif | |
3225 | 3247 | } else { |
3226 | 3248 | printf("It is not able to unlock device."); |
3227 | 3249 | return FASTBOOT_LOCK_ERROR; |
... | ... | @@ -3233,6 +3255,7 @@ |
3233 | 3255 | static FbLockState do_fastboot_lock(void) |
3234 | 3256 | { |
3235 | 3257 | int status; |
3258 | + | |
3236 | 3259 | if (fastboot_get_lock_stat() == FASTBOOT_LOCK) { |
3237 | 3260 | printf("The device is already locked\n"); |
3238 | 3261 | return FASTBOOT_LOCK; |
... | ... | @@ -3241,9 +3264,7 @@ |
3241 | 3264 | if (status < 0) |
3242 | 3265 | return FASTBOOT_LOCK_ERROR; |
3243 | 3266 | |
3244 | - printf("Start /data wipe process....\n"); | |
3245 | - fastboot_wipe_data_partition(); | |
3246 | - printf("Wipe /data completed.\n"); | |
3267 | + wipe_all_userdata(); | |
3247 | 3268 | |
3248 | 3269 | return FASTBOOT_LOCK; |
3249 | 3270 | } |