From a6f49bd9520e02d84026e31a53a6c98db59d91a3 Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Mon, 26 Mar 2018 14:32:11 -0700 Subject: Do not skip the update installation if it's a retry We used to skip the update installation if the battery doesn't reach the threshold or the boot reason is in blacklist. Afterwards, we just cleared the BCB and reboot/shutdown the device. However, this leaves the device in a brick state if the update is a retry; because a subsequent reboot won't resume the update after the BCB gets cleared. This CL skips the battery and bootreason check on retries. An alternative solution is to conduct the check and shutdown the device without clearing the BCB on INSTALL_SKIPPED; but users who don't have context may reboot the device manually anyway. Bug: 65288661 Test: Trigger the INSTALL_SKIPPED with insufficient battery, and check the behavior with retry_count. Change-Id: I0bd8ae9cee0e35aeeec3df469a78cec9ee1b8db8 --- recovery.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recovery.cpp b/recovery.cpp index 6bd291463..910cd8296 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -1537,14 +1537,14 @@ int main(int argc, char **argv) { // to log the update attempt since update_package is non-NULL. modified_flash = true; - if (!is_battery_ok()) { + if (retry_count == 0 && !is_battery_ok()) { ui->Print("battery capacity is not enough for installing package, needed is %d%%\n", BATTERY_OK_PERCENTAGE); // Log the error code to last_install when installation skips due to // low battery. log_failure_code(kLowBattery, update_package); status = INSTALL_SKIPPED; - } else if (bootreason_in_blacklist()) { + } else if (retry_count == 0 && bootreason_in_blacklist()) { // Skip update-on-reboot when bootreason is kernel_panic or similar ui->Print("bootreason is in the blacklist; skip OTA installation\n"); log_failure_code(kBootreasonInBlacklist, update_package); -- cgit v1.2.3