From d9d16297dd0cdc186ac7fbe867b61eb035e3548c Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Thu, 20 Apr 2017 18:08:21 -0700 Subject: Reboot the device on user build after the install fails Users can't do much after the install fails with the device showing "error" under recovery. So our best choice is to reboot the device since sometimes the system image is still bootable (i.e. on package verification failure). At worst the device would stuck in a boot loop where the users need the same professional knowledge to recover as before. Behaviors after installation failure (including data wipe): If recovery text is visible: No change. If recovery text is not visible: Old behavior: Wait under "error" screen. Reboot after UI timeout (120s) if not connected to usb charger. New behavior: Wait for 5s (shortens from the 120s timeout) under "error" screen and reboot (w or w/o charger). sideload-auto-reboot (only available for userdebug): Old behavior: Reboot immediately after installation failure. New behavior: Wait for 5s under "error" screen and reboot. Bug: 35386985 Test: On angler user, device auto reboots 5s after a failing OTA. Change-Id: I3ff0ead86e2ccec9445d6a2865bc2c463855f23c --- recovery.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/recovery.cpp b/recovery.cpp index b24efa963..99126eedc 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -1593,14 +1593,22 @@ int main(int argc, char **argv) { } } - if (!sideload_auto_reboot && (status == INSTALL_ERROR || status == INSTALL_CORRUPT)) { - copy_logs(); + if (status == INSTALL_ERROR || status == INSTALL_CORRUPT) { ui->SetBackground(RecoveryUI::ERROR); + if (!ui->IsTextVisible()) { + sleep(5); + } } Device::BuiltinAction after = shutdown_after ? Device::SHUTDOWN : Device::REBOOT; - if ((status != INSTALL_SUCCESS && status != INSTALL_SKIPPED && !sideload_auto_reboot) || - ui->IsTextVisible()) { + // 1. If the recovery menu is visible, prompt and wait for commands. + // 2. If the state is INSTALL_NONE, wait for commands. (i.e. In user build, manually reboot into + // recovery to sideload a package.) + // 3. sideload_auto_reboot is an option only available in user-debug build, reboot the device + // without waiting. + // 4. In all other cases, reboot the device. Therefore, normal users will observe the device + // reboot after it shows the "error" screen for 5s. + if ((status == INSTALL_NONE && !sideload_auto_reboot) || ui->IsTextVisible()) { Device::BuiltinAction temp = prompt_and_wait(device, status); if (temp != Device::NO_ACTION) { after = temp; -- cgit v1.2.3