Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c664a119 authored by Michael Bestas's avatar Michael Bestas Committed by Steve Kondik
Browse files

recovery: Add wipe system partition option

Change-Id: Id606cef249a7464037443de6265055803c290d82
parent 9062cace
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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",
@@ -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 } },
+1 −0
Original line number Diff line number Diff line
@@ -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,
+18 −0
Original line number Diff line number Diff line
@@ -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");
@@ -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;