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

Commit eb44331c authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12896565 from cfdba27d to 25Q2-release

Change-Id: I5d0876926b2f5c511a9320fd74203d66e1b41e06
parents 8c233ab8 cfdba27d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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);
+11 −0
Original line number Diff line number Diff line
@@ -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;
+25 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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();