recovery: Add wipe system partition option
Change-Id: Id606cef249a7464037443de6265055803c290d82
diff --git a/install/include/install/wipe_data.h b/install/include/install/wipe_data.h
index b34891f..4c15fff 100644
--- a/install/include/install/wipe_data.h
+++ b/install/include/install/wipe_data.h
@@ -28,3 +28,6 @@
// Returns true on success.
bool WipeData(Device* device, bool convert_fbe);
+
+// Returns true on success.
+bool WipeSystem(RecoveryUI* ui, const std::function<bool()>& confirm);
\ No newline at end of file
diff --git a/install/wipe_data.cpp b/install/wipe_data.cpp
index ed67207..6561d39 100644
--- a/install/wipe_data.cpp
+++ b/install/wipe_data.cpp
@@ -124,4 +124,15 @@
}
ui->Print("Data wipe %s.\n", success ? "complete" : "failed");
return success;
-}
\ No newline at end of file
+}
+
+bool WipeSystem(RecoveryUI* ui, const std::function<bool()>& confirm_func) {
+ if (confirm_func && !confirm_func()) {
+ return false;
+ }
+
+ ui->Print("\n-- Wiping system...\n");
+ bool success = EraseVolume(get_system_root().c_str(), ui, false);
+ ui->Print("System wipe %s.\n", success ? "complete" : "failed");
+ return success;
+}
diff --git a/recovery.cpp b/recovery.cpp
index 9cf81e8..2d85833 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -548,6 +548,16 @@
break;
}
+ case Device::WIPE_SYSTEM: {
+ save_current_log = true;
+ std::function<bool()> confirm_func = [&device]() {
+ return yes_no(device, "Wipe system?", " THIS CAN NOT BE UNDONE!");
+ };
+ WipeSystem(ui, ui->IsTextVisible() ? confirm_func : nullptr);
+ if (!ui->IsTextVisible()) return Device::NO_ACTION;
+ break;
+ }
+
case Device::APPLY_ADB_SIDELOAD:
case Device::APPLY_SDCARD:
case Device::ENTER_RESCUE: {
diff --git a/recovery_ui/device.cpp b/recovery_ui/device.cpp
index e09431a..c09411d 100644
--- a/recovery_ui/device.cpp
+++ b/recovery_ui/device.cpp
@@ -34,6 +34,7 @@
{ "Apply update from SD card", Device::APPLY_SDCARD },
{ "Wipe data/factory reset", Device::WIPE_DATA },
{ "Wipe cache partition", Device::WIPE_CACHE },
+ { "Wipe system partition", Device::WIPE_SYSTEM },
{ "Mount /system", Device::MOUNT_SYSTEM },
{ "View recovery logs", Device::VIEW_RECOVERY_LOGS },
{ "Run graphics test", Device::RUN_GRAPHICS_TEST },
diff --git a/recovery_ui/include/recovery_ui/device.h b/recovery_ui/include/recovery_ui/device.h
index d532d86..3996910 100644
--- a/recovery_ui/include/recovery_ui/device.h
+++ b/recovery_ui/include/recovery_ui/device.h
@@ -62,6 +62,7 @@
REBOOT_FASTBOOT = 17,
REBOOT_RECOVERY = 18,
REBOOT_RESCUE = 19,
+ WIPE_SYSTEM = 100,
};
explicit Device(RecoveryUI* ui);