From 50ff158c50b32314cd219a2e3d1edc7a95290f4f Mon Sep 17 00:00:00 2001 From: Michael Bestas Date: Mon, 25 Jan 2016 03:27:52 +0200 Subject: recovery: Add wipe system partition option Change-Id: Id606cef249a7464037443de6265055803c290d82 --- device.cpp | 2 ++ device.h | 1 + recovery.cpp | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/device.cpp b/device.cpp index 95608d6..0186d5b 100644 --- a/device.cpp +++ b/device.cpp @@ -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 } }, diff --git a/device.h b/device.h index 98427a2..8ff541a 100644 --- a/device.h +++ b/device.h @@ -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; -- cgit v1.1