aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'recovery.cpp')
-rw-r--r--recovery.cpp30
1 files changed, 19 insertions, 11 deletions
diff --git a/recovery.cpp b/recovery.cpp
index c1a31b6a..852f1e86 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -40,7 +40,6 @@
40#include <string> 40#include <string>
41#include <vector> 41#include <vector>
42 42
43#include <adb.h>
44#include <android-base/file.h> 43#include <android-base/file.h>
45#include <android-base/logging.h> 44#include <android-base/logging.h>
46#include <android-base/parseint.h> 45#include <android-base/parseint.h>
@@ -114,8 +113,9 @@ static const char *TEMPORARY_LOG_FILE = "/tmp/recovery.log";
114static const char *TEMPORARY_INSTALL_FILE = "/tmp/last_install"; 113static const char *TEMPORARY_INSTALL_FILE = "/tmp/last_install";
115static const char *LAST_KMSG_FILE = "/cache/recovery/last_kmsg"; 114static const char *LAST_KMSG_FILE = "/cache/recovery/last_kmsg";
116static const char *LAST_LOG_FILE = "/cache/recovery/last_log"; 115static const char *LAST_LOG_FILE = "/cache/recovery/last_log";
117// We will try to apply the update package 5 times at most in case of an I/O error. 116// We will try to apply the update package 5 times at most in case of an I/O error or
118static const int EIO_RETRY_COUNT = 4; 117// bspatch | imgpatch error.
118static const int RETRY_LIMIT = 4;
119static const int BATTERY_READ_TIMEOUT_IN_SEC = 10; 119static const int BATTERY_READ_TIMEOUT_IN_SEC = 10;
120// GmsCore enters recovery mode to install package when having enough battery 120// GmsCore enters recovery mode to install package when having enough battery
121// percentage. Normally, the threshold is 40% without charger and 20% with charger. 121// percentage. Normally, the threshold is 40% without charger and 20% with charger.
@@ -1157,7 +1157,7 @@ static Device::BuiltinAction prompt_and_wait(Device* device, int status) {
1157 { 1157 {
1158 bool adb = (chosen_action == Device::APPLY_ADB_SIDELOAD); 1158 bool adb = (chosen_action == Device::APPLY_ADB_SIDELOAD);
1159 if (adb) { 1159 if (adb) {
1160 status = apply_from_adb(ui, &should_wipe_cache, TEMPORARY_INSTALL_FILE); 1160 status = apply_from_adb(&should_wipe_cache, TEMPORARY_INSTALL_FILE);
1161 } else { 1161 } else {
1162 status = apply_from_sdcard(device, &should_wipe_cache); 1162 status = apply_from_sdcard(device, &should_wipe_cache);
1163 } 1163 }
@@ -1528,9 +1528,9 @@ int main(int argc, char **argv) {
1528 } 1528 }
1529 if (status != INSTALL_SUCCESS) { 1529 if (status != INSTALL_SUCCESS) {
1530 ui->Print("Installation aborted.\n"); 1530 ui->Print("Installation aborted.\n");
1531 // When I/O error happens, reboot and retry installation EIO_RETRY_COUNT 1531 // When I/O error happens, reboot and retry installation RETRY_LIMIT
1532 // times before we abandon this OTA update. 1532 // times before we abandon this OTA update.
1533 if (status == INSTALL_RETRY && retry_count < EIO_RETRY_COUNT) { 1533 if (status == INSTALL_RETRY && retry_count < RETRY_LIMIT) {
1534 copy_logs(); 1534 copy_logs();
1535 set_retry_bootloader_message(retry_count, args); 1535 set_retry_bootloader_message(retry_count, args);
1536 // Print retry count on screen. 1536 // Print retry count on screen.
@@ -1582,7 +1582,7 @@ int main(int argc, char **argv) {
1582 if (!sideload_auto_reboot) { 1582 if (!sideload_auto_reboot) {
1583 ui->ShowText(true); 1583 ui->ShowText(true);
1584 } 1584 }
1585 status = apply_from_adb(ui, &should_wipe_cache, TEMPORARY_INSTALL_FILE); 1585 status = apply_from_adb(&should_wipe_cache, TEMPORARY_INSTALL_FILE);
1586 if (status == INSTALL_SUCCESS && should_wipe_cache) { 1586 if (status == INSTALL_SUCCESS && should_wipe_cache) {
1587 if (!wipe_cache(false, device)) { 1587 if (!wipe_cache(false, device)) {
1588 status = INSTALL_ERROR; 1588 status = INSTALL_ERROR;
@@ -1604,14 +1604,22 @@ int main(int argc, char **argv) {
1604 } 1604 }
1605 } 1605 }
1606 1606
1607 if (!sideload_auto_reboot && (status == INSTALL_ERROR || status == INSTALL_CORRUPT)) { 1607 if (status == INSTALL_ERROR || status == INSTALL_CORRUPT) {
1608 copy_logs();
1609 ui->SetBackground(RecoveryUI::ERROR); 1608 ui->SetBackground(RecoveryUI::ERROR);
1609 if (!ui->IsTextVisible()) {
1610 sleep(5);
1611 }
1610 } 1612 }
1611 1613
1612 Device::BuiltinAction after = shutdown_after ? Device::SHUTDOWN : Device::REBOOT; 1614 Device::BuiltinAction after = shutdown_after ? Device::SHUTDOWN : Device::REBOOT;
1613 if ((status != INSTALL_SUCCESS && status != INSTALL_SKIPPED && !sideload_auto_reboot) || 1615 // 1. If the recovery menu is visible, prompt and wait for commands.
1614 ui->IsTextVisible()) { 1616 // 2. If the state is INSTALL_NONE, wait for commands. (i.e. In user build, manually reboot into
1617 // recovery to sideload a package.)
1618 // 3. sideload_auto_reboot is an option only available in user-debug build, reboot the device
1619 // without waiting.
1620 // 4. In all other cases, reboot the device. Therefore, normal users will observe the device
1621 // reboot after it shows the "error" screen for 5s.
1622 if ((status == INSTALL_NONE && !sideload_auto_reboot) || ui->IsTextVisible()) {
1615 Device::BuiltinAction temp = prompt_and_wait(device, status); 1623 Device::BuiltinAction temp = prompt_and_wait(device, status);
1616 if (temp != Device::NO_ACTION) { 1624 if (temp != Device::NO_ACTION) {
1617 after = temp; 1625 after = temp;