recovery: Add wipe system partition option
Change-Id: Id606cef249a7464037443de6265055803c290d82 Signed-off-by: zlewchan <zlewchan@icloud.com>
This commit is contained in:
parent
e8ccb88add
commit
096e85eb89
5 changed files with 27 additions and 0 deletions
|
@ -29,3 +29,6 @@ bool WipeCache(RecoveryUI* ui, const std::function<bool()>& confirm,
|
||||||
|
|
||||||
// Returns true on success.
|
// Returns true on success.
|
||||||
bool WipeData(Device* device, bool keep_memtag_mode = false, std::string_view new_fstype = "");
|
bool WipeData(Device* device, bool keep_memtag_mode = false, std::string_view new_fstype = "");
|
||||||
|
|
||||||
|
// Returns true on success.
|
||||||
|
bool WipeSystem(RecoveryUI* ui, const std::function<bool()>& confirm);
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <android-base/file.h>
|
#include <android-base/file.h>
|
||||||
#include <android-base/logging.h>
|
#include <android-base/logging.h>
|
||||||
#include <android-base/stringprintf.h>
|
#include <android-base/stringprintf.h>
|
||||||
|
#include <fs_mgr/roots.h>
|
||||||
|
|
||||||
#include "bootloader_message/bootloader_message.h"
|
#include "bootloader_message/bootloader_message.h"
|
||||||
#include "install/snapshot_utils.h"
|
#include "install/snapshot_utils.h"
|
||||||
|
@ -122,3 +123,14 @@ bool WipeData(Device* device, bool keep_memtag_mode, std::string_view data_fstyp
|
||||||
ui->Print("Data wipe %s.\n", success ? "complete" : "failed");
|
ui->Print("Data wipe %s.\n", success ? "complete" : "failed");
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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(android::fs_mgr::GetSystemRoot().c_str(), ui);
|
||||||
|
ui->Print("System wipe %s.\n", success ? "complete" : "failed");
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
10
recovery.cpp
10
recovery.cpp
|
@ -455,6 +455,16 @@ static Device::BuiltinAction PromptAndWait(Device* device, InstallResult status)
|
||||||
break;
|
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_ADB_SIDELOAD:
|
||||||
case Device::APPLY_SDCARD:
|
case Device::APPLY_SDCARD:
|
||||||
case Device::ENTER_RESCUE: {
|
case Device::ENTER_RESCUE: {
|
||||||
|
|
|
@ -35,6 +35,7 @@ static std::vector<std::pair<std::string, Device::BuiltinAction>> g_menu_actions
|
||||||
{ "Apply update from SD card", Device::APPLY_SDCARD },
|
{ "Apply update from SD card", Device::APPLY_SDCARD },
|
||||||
{ "Wipe data/factory reset", Device::WIPE_DATA },
|
{ "Wipe data/factory reset", Device::WIPE_DATA },
|
||||||
{ "Wipe cache partition", Device::WIPE_CACHE },
|
{ "Wipe cache partition", Device::WIPE_CACHE },
|
||||||
|
{ "Wipe system partition", Device::WIPE_SYSTEM },
|
||||||
{ "Mount /system", Device::MOUNT_SYSTEM },
|
{ "Mount /system", Device::MOUNT_SYSTEM },
|
||||||
{ "View recovery logs", Device::VIEW_RECOVERY_LOGS },
|
{ "View recovery logs", Device::VIEW_RECOVERY_LOGS },
|
||||||
{ "Run graphics test", Device::RUN_GRAPHICS_TEST },
|
{ "Run graphics test", Device::RUN_GRAPHICS_TEST },
|
||||||
|
|
|
@ -63,6 +63,7 @@ class Device {
|
||||||
REBOOT_RESCUE = 19,
|
REBOOT_RESCUE = 19,
|
||||||
REBOOT_FROM_FASTBOOT = 20,
|
REBOOT_FROM_FASTBOOT = 20,
|
||||||
SHUTDOWN_FROM_FASTBOOT = 21,
|
SHUTDOWN_FROM_FASTBOOT = 21,
|
||||||
|
WIPE_SYSTEM = 100,
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit Device(RecoveryUI* ui);
|
explicit Device(RecoveryUI* ui);
|
||||||
|
|
Loading…
Reference in a new issue