recovery: Ask to reboot before installing anything after A/B update
Change-Id: Id3e44ddbe11119fcc66d379216f8f5e683979a9f
This commit is contained in:
parent
d735cd0f68
commit
d2eaf6e562
2 changed files with 20 additions and 0 deletions
|
@ -62,6 +62,8 @@
|
|||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
bool ask_to_ab_reboot(Device* device);
|
||||
|
||||
static constexpr int kRecoveryApiVersion = 3;
|
||||
// We define RECOVERY_API_VERSION in Android.mk, which will be picked up by build system and packed
|
||||
// into target_files.zip. Assert the version defined in code and in Android.mk are consistent.
|
||||
|
@ -417,6 +419,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);
|
||||
}
|
||||
|
@ -602,7 +612,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;
|
||||
|
|
|
@ -175,6 +175,12 @@ static bool ask_to_wipe_data(Device* device) {
|
|||
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?");
|
||||
}
|
||||
|
||||
static InstallResult prompt_and_wipe_data(Device* device) {
|
||||
// Reset to normal system boot so recovery won't cycle indefinitely.
|
||||
std::string err;
|
||||
|
|
Loading…
Reference in a new issue