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

Unverified Commit a11e95ff authored by LuK1337's avatar LuK1337 Committed by Michael Bestas
Browse files

recovery: Ask to reboot before installing anything after A/B update

Change-Id: Id3e44ddbe11119fcc66d379216f8f5e683979a9f
parent e4997a23
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@

using namespace std::chrono_literals;

bool ask_to_ab_reboot(Device* device);
bool ask_to_continue_unverified(Device* device);
bool ask_to_continue_downgrade(Device* device);

@@ -428,6 +429,14 @@ static InstallResult TryUpdateBinary(Package* package, bool* wipe_cache,
    return INSTALL_ERROR;
  }

  static bool ab_package_installed = false;
  if (ab_package_installed) {
    if (ask_to_ab_reboot(device)) {
      Reboot("userrequested,recovery,ui");
    }
    return INSTALL_ERROR;
  }

  if (package_is_ab) {
    CHECK(package->GetType() == PackageType::kFile);
  }
@@ -613,7 +622,11 @@ static InstallResult TryUpdateBinary(Package* package, bool* wipe_cache,
    LOG(FATAL) << "Invalid status code " << status;
  }
  if (package_is_ab) {
    ab_package_installed = true;
    PerformPowerwashIfRequired(zip, device);
    if (ask_to_ab_reboot(device)) {
      Reboot("userrequested,recovery,ui");
    }
  }

  return INSTALL_SUCCESS;
+6 −0
Original line number Diff line number Diff line
@@ -171,6 +171,12 @@ static bool yes_no(Device* device, const char* question1, const char* question2)
  return (chosen_item == 1);
}

bool ask_to_ab_reboot(Device* device) {
  device->GetUI()->SetProgressType(RecoveryUI::EMPTY);
  return yes_no(device, "To install additional packages, you need to reboot recovery first",
                "Do you want to reboot to recovery now?");
}

bool ask_to_continue_unverified(Device* device) {
  if (get_build_type() == "user") {
    return false;