aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--device.cpp2
-rw-r--r--device.h1
-rw-r--r--recovery.cpp18
3 files changed, 21 insertions, 0 deletions
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;