From eb6f13aeb68368c0d0776173d63a29cf36fb17e8 Mon Sep 17 00:00:00 2001 From: Hridya Valsaraju Date: Wed, 12 Sep 2018 10:25:01 -0700 Subject: Allow switch to fastbootd when userdata wipe is required Bug: 114065789 Test: Able to use 'adb reboot fastboot' to switch to fastboot from recovery when a userdata wipe is required to boot. Change-Id: Ice6950444656f8d8857808531af030078f544b88 --- install.h | 11 +++++++++-- recovery.cpp | 18 +++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/install.h b/install.h index 0f6670a35..1d3d0cd27 100644 --- a/install.h +++ b/install.h @@ -23,8 +23,15 @@ #include -enum { INSTALL_SUCCESS, INSTALL_ERROR, INSTALL_CORRUPT, INSTALL_NONE, INSTALL_SKIPPED, - INSTALL_RETRY }; +enum InstallResult { + INSTALL_SUCCESS, + INSTALL_ERROR, + INSTALL_CORRUPT, + INSTALL_NONE, + INSTALL_SKIPPED, + INSTALL_RETRY, + INSTALL_KEY_INTERRUPTED +}; // Installs the given update package. If INSTALL_SUCCESS is returned and *wipe_cache is true on // exit, caller should wipe the cache partition. diff --git a/recovery.cpp b/recovery.cpp index 01bd83b5e..247cbf968 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -388,7 +388,7 @@ static bool wipe_data(Device* device) { return success; } -static bool prompt_and_wipe_data(Device* device) { +static InstallResult prompt_and_wipe_data(Device* device) { // Use a single string and let ScreenRecoveryUI handles the wrapping. std::vector headers{ "Can't load Android system. Your data may be corrupt. " @@ -409,13 +409,17 @@ static bool prompt_and_wipe_data(Device* device) { // If ShowMenu() returned RecoveryUI::KeyError::INTERRUPTED, WaitKey() was interrupted. if (chosen_item == static_cast(RecoveryUI::KeyError::INTERRUPTED)) { - return false; + return INSTALL_KEY_INTERRUPTED; } if (chosen_item != 1) { - return true; // Just reboot, no wipe; not a failure, user asked for it + return INSTALL_SUCCESS; // Just reboot, no wipe; not a failure, user asked for it } if (ask_to_wipe_data(device)) { - return wipe_data(device); + if (wipe_data(device)) { + return INSTALL_SUCCESS; + } else { + return INSTALL_ERROR; + } } } } @@ -1188,10 +1192,10 @@ Device::BuiltinAction start_recovery(Device* device, const std::vectorShowText(true); ui->SetBackground(RecoveryUI::ERROR); - if (!prompt_and_wipe_data(device)) { - status = INSTALL_ERROR; + status = prompt_and_wipe_data(device); + if (status != INSTALL_KEY_INTERRUPTED) { + ui->ShowText(false); } - ui->ShowText(false); } else if (should_wipe_cache) { if (!wipe_cache(false, device)) { status = INSTALL_ERROR; -- cgit v1.2.3