Loading install/include/install/snapshot_utils.h +3 −0 Original line number Diff line number Diff line Loading @@ -28,3 +28,6 @@ bool FinishPendingSnapshotMerges(Device* device); * devices were created or there was no need to. */ bool CreateSnapshotPartitions(); // Check whether it's okay to cancel any in-progress OTAs for sideload. bool IsCancelUpdateSafe(Device* device); install/snapshot_utils.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -23,9 +23,20 @@ #include "recovery_ui/ui.h" #include "recovery_utils/roots.h" using android::snapshot::CancelResult; using android::snapshot::CreateResult; using android::snapshot::SnapshotManager; bool IsCancelUpdateSafe(Device* device) { auto sm = SnapshotManager::New(); if (!sm) { RecoveryUI* ui = device->GetUI(); ui->Print("Could not create SnapshotManager.\n"); return false; } return sm->IsCancelUpdateSafe(); } bool FinishPendingSnapshotMerges(Device* device) { if (!android::base::GetBoolProperty("ro.virtual_ab.enabled", false)) { return true; Loading recovery.cpp +25 −0 Original line number Diff line number Diff line Loading @@ -175,6 +175,25 @@ static bool ask_to_wipe_data(Device* device) { return (chosen_item == 1); } static bool ask_to_cancel_ota(Device* device) { // clang-format off std::vector<std::string> headers{ "Overwrite in-progress update?", "An update may already be in progress. If you proceed, " "the existing OS may not longer boot, and completing " "an update via ADB will be required." }; std::vector<std::string> items{ "Cancel", "Continue", }; // clang-format on size_t chosen_item = device->GetUI()->ShowMenu( headers, items, 0, true, std::bind(&Device::HandleMenuKey, device, std::placeholders::_1, std::placeholders::_2)); return (chosen_item == 1); } static InstallResult prompt_and_wipe_data(Device* device) { // Reset to normal system boot so recovery won't cycle indefinitely. std::string err; Loading Loading @@ -461,6 +480,12 @@ static Device::BuiltinAction PromptAndWait(Device* device, InstallResult status) case Device::ENTER_RESCUE: { save_current_log = true; if (!IsCancelUpdateSafe(device)) { if (!ask_to_cancel_ota(device)) { break; } } update_in_progress = true; WriteUpdateInProgress(); Loading Loading
install/include/install/snapshot_utils.h +3 −0 Original line number Diff line number Diff line Loading @@ -28,3 +28,6 @@ bool FinishPendingSnapshotMerges(Device* device); * devices were created or there was no need to. */ bool CreateSnapshotPartitions(); // Check whether it's okay to cancel any in-progress OTAs for sideload. bool IsCancelUpdateSafe(Device* device);
install/snapshot_utils.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -23,9 +23,20 @@ #include "recovery_ui/ui.h" #include "recovery_utils/roots.h" using android::snapshot::CancelResult; using android::snapshot::CreateResult; using android::snapshot::SnapshotManager; bool IsCancelUpdateSafe(Device* device) { auto sm = SnapshotManager::New(); if (!sm) { RecoveryUI* ui = device->GetUI(); ui->Print("Could not create SnapshotManager.\n"); return false; } return sm->IsCancelUpdateSafe(); } bool FinishPendingSnapshotMerges(Device* device) { if (!android::base::GetBoolProperty("ro.virtual_ab.enabled", false)) { return true; Loading
recovery.cpp +25 −0 Original line number Diff line number Diff line Loading @@ -175,6 +175,25 @@ static bool ask_to_wipe_data(Device* device) { return (chosen_item == 1); } static bool ask_to_cancel_ota(Device* device) { // clang-format off std::vector<std::string> headers{ "Overwrite in-progress update?", "An update may already be in progress. If you proceed, " "the existing OS may not longer boot, and completing " "an update via ADB will be required." }; std::vector<std::string> items{ "Cancel", "Continue", }; // clang-format on size_t chosen_item = device->GetUI()->ShowMenu( headers, items, 0, true, std::bind(&Device::HandleMenuKey, device, std::placeholders::_1, std::placeholders::_2)); return (chosen_item == 1); } static InstallResult prompt_and_wipe_data(Device* device) { // Reset to normal system boot so recovery won't cycle indefinitely. std::string err; Loading Loading @@ -461,6 +480,12 @@ static Device::BuiltinAction PromptAndWait(Device* device, InstallResult status) case Device::ENTER_RESCUE: { save_current_log = true; if (!IsCancelUpdateSafe(device)) { if (!ask_to_cancel_ota(device)) { break; } } update_in_progress = true; WriteUpdateInProgress(); Loading