diff options
author | Michael Bestas <mikeioannina@cyanogenmod.org> | 2016-01-25 03:27:52 +0200 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-04-05 15:48:12 -0700 |
commit | 50ff158c50b32314cd219a2e3d1edc7a95290f4f (patch) | |
tree | 1d0975f12dda294d6e6ebd204a3de3f53eae2f38 | |
parent | d6e1fbb7c2fd4aea6154015a89b7de24435f5625 (diff) | |
download | bootable_recovery-50ff158c50b32314cd219a2e3d1edc7a95290f4f.zip bootable_recovery-50ff158c50b32314cd219a2e3d1edc7a95290f4f.tar.gz bootable_recovery-50ff158c50b32314cd219a2e3d1edc7a95290f4f.tar.bz2 |
recovery: Add wipe system partition option
Change-Id: Id606cef249a7464037443de6265055803c290d82
-rw-r--r-- | device.cpp | 2 | ||||
-rw-r--r-- | device.h | 1 | ||||
-rw-r--r-- | recovery.cpp | 18 |
3 files changed, 21 insertions, 0 deletions
@@ -68,6 +68,7 @@ static const char* ADVANCED_MENU_NAMES[] = { #endif #ifndef RELEASE_BUILD "Mount /system", + "Wipe system partition", #endif "View recovery logs", "Power off", @@ -82,6 +83,7 @@ static const menu_entry ADVANCED_MENU_ENTRIES[] = { #endif #ifndef RELEASE_BUILD { ACTION_INVOKE, { .action = Device::MOUNT_SYSTEM } }, + { ACTION_INVOKE, { .action = Device::WIPE_SYSTEM } }, #endif { ACTION_INVOKE, { .action = Device::VIEW_RECOVERY_LOGS } }, { ACTION_INVOKE, { .action = Device::SHUTDOWN } }, @@ -74,6 +74,7 @@ class Device : public VoldWatcher { SHUTDOWN, VIEW_RECOVERY_LOGS, MOUNT_SYSTEM, + WIPE_SYSTEM, }; // Return the list of menu items (an array of strings, diff --git a/recovery.cpp b/recovery.cpp index c13a689..03425dc 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -906,6 +906,20 @@ static bool wipe_cache(bool should_confirm, Device* device) { return success; } +// Return true on success. +static bool wipe_system(Device* device) { + if (!yes_no(device, "Wipe system?", " THIS CAN NOT BE UNDONE!")) { + return false; + } + + 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; +} + static void choose_recovery_file(Device* device) { // "Back" + KEEP_LOG_COUNT * 2 + terminating nullptr entry char* entries[1 + KEEP_LOG_COUNT * 2 + 1]; @@ -1163,6 +1177,10 @@ prompt_and_wait(Device* device, int status) { } break; + + case Device::WIPE_SYSTEM: + wipe_system(device); + break; } if (status == Device::kRefresh) { status = 0; |