Skip to content

Commit

Permalink
recovery: Add wipe system partition option
Browse files Browse the repository at this point in the history
Change-Id: Id606cef249a7464037443de6265055803c290d82
  • Loading branch information
mikeNG authored and Steve Kondik committed Sep 4, 2016
1 parent 9062cac commit c664a11
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ static const char* ADVANCED_MENU_NAMES[] = {
#endif
#ifndef RELEASE_BUILD
"Mount /system",
"Wipe system partition",
#endif
"View recovery logs",
"Run graphics test",
Expand All @@ -83,6 +84,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::RUN_GRAPHICS_TEST } },
Expand Down
1 change: 1 addition & 0 deletions device.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class Device : public VoldWatcher {
VIEW_RECOVERY_LOGS,
MOUNT_SYSTEM,
RUN_GRAPHICS_TEST,
WIPE_SYSTEM,
};

// Return the list of menu items (an array of strings,
Expand Down
18 changes: 18 additions & 0 deletions recovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,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) {
if (!has_cache) {
ui->Print("No /cache partition found.\n");
Expand Down Expand Up @@ -1382,6 +1396,10 @@ prompt_and_wait(Device* device, int status) {
}
}
break;

case Device::WIPE_SYSTEM:
wipe_system(device);
break;
}
if (status == Device::kRefresh) {
status = 0;
Expand Down

0 comments on commit c664a11

Please sign in to comment.