diff options
author | Dan Pasanen <dan.pasanen@gmail.com> | 2017-04-04 13:40:19 -0500 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2019-04-04 20:28:58 +0300 |
commit | dc95db8ebe6db3fa2c9c1e656f77ce506a71ffa3 (patch) | |
tree | ad7fb6fee7af9aa4c183ea16e17742d0d6a5b597 | |
parent | 865c6c770816f6e8099d6d93e04aeea35091a9d6 (diff) | |
download | android_bootable_recovery-dc95db8ebe6db3fa2c9c1e656f77ce506a71ffa3.tar.gz android_bootable_recovery-dc95db8ebe6db3fa2c9c1e656f77ce506a71ffa3.tar.bz2 android_bootable_recovery-dc95db8ebe6db3fa2c9c1e656f77ce506a71ffa3.zip |
recovery: Add wipe system partition option
Change-Id: Id606cef249a7464037443de6265055803c290d82
-rw-r--r-- | device.cpp | 2 | ||||
-rw-r--r-- | device.h | 13 | ||||
-rw-r--r-- | recovery.cpp | 25 |
3 files changed, 34 insertions, 6 deletions
@@ -25,6 +25,7 @@ static const char* MENU_ITEMS[] = { #ifndef AB_OTA_UPDATER "Wipe cache partition", #endif // !AB_OTA_UPDATER + "Wipe system partition", "Mount /system", "View recovery logs", "Run graphics test", @@ -41,6 +42,7 @@ static const Device::BuiltinAction MENU_ACTIONS[] = { #ifndef AB_OTA_UPDATER Device::WIPE_CACHE, #endif // !AB_OTA_UPDATER + Device::WIPE_SYSTEM, Device::MOUNT_SYSTEM, Device::VIEW_RECOVERY_LOGS, Device::RUN_GRAPHICS_TEST, @@ -62,12 +62,13 @@ class Device { // APPLY_ADB_SIDELOAD was 4. WIPE_DATA = 5, WIPE_CACHE = 6, - REBOOT_BOOTLOADER = 7, - SHUTDOWN = 8, - VIEW_RECOVERY_LOGS = 9, - MOUNT_SYSTEM = 10, - RUN_GRAPHICS_TEST = 11, - RUN_LOCALE_TEST = 12, + WIPE_SYSTEM = 7, + REBOOT_BOOTLOADER = 8, + SHUTDOWN = 9, + VIEW_RECOVERY_LOGS = 10, + MOUNT_SYSTEM = 11, + RUN_GRAPHICS_TEST = 12, + RUN_LOCALE_TEST = 13, }; // Return the list of menu items (an array of strings, NULL-terminated). The menu_position passed diff --git a/recovery.cpp b/recovery.cpp index 9140a55e..53dfd94c 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -933,6 +933,20 @@ static bool wipe_cache(bool should_confirm, Device* device) { return success; } +static bool ask_to_wipe_system(Device* device) { + return yes_no(device, "Wipe system?", " THIS CAN NOT BE UNDONE!"); +} + +// Return true on success. +static bool wipe_system() { + modified_flash = true; + + ui->Print("\n-- Wiping system...\n"); + bool success = erase_volume("/system"); + ui->Print("System wipe %s.\n", success ? "complete" : "failed"); + return success; +} + // Secure-wipe a given partition. It uses BLKSECDISCARD, if supported. Otherwise, it goes with // BLKDISCARD (if device supports BLKDISCARDZEROES) or BLKZEROOUT. static bool secure_wipe_partition(const std::string& partition) { @@ -1303,6 +1317,17 @@ static Device::BuiltinAction prompt_and_wait(Device* device, int status) { if (!ui->IsTextVisible()) return Device::NO_ACTION; break; + case Device::WIPE_SYSTEM: + if (ui->IsTextVisible()) { + if (ask_to_wipe_system(device)) { + wipe_system(); + } + } else { + wipe_system(); + return Device::NO_ACTION; + } + break; + case Device::APPLY_UPDATE: { status = show_apply_update_menu(device, &should_wipe_cache); |