aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTianjie Xu2016-04-30 13:49:59 -0500
committerTianjie Xu2016-05-20 15:56:53 -0500
commit162558382b768a4120b3e41090a4c7b53f11469a (patch)
tree7e0d268233fc6bea07a361cf6913fc3a5e524063 /recovery.cpp
parentdd874b1c87eb04f28db0db2629df0adde568a74c (diff)
downloadplatform-bootable-recovery-162558382b768a4120b3e41090a4c7b53f11469a.tar.gz
platform-bootable-recovery-162558382b768a4120b3e41090a4c7b53f11469a.tar.xz
platform-bootable-recovery-162558382b768a4120b3e41090a4c7b53f11469a.zip
Allow recovery to return error codes
Write error code, cause code, and retry count into last_install. So we can have more information about the reason of a failed OTA. Example of new last_install: @/cache/recovery/block.map package name 0 install result retry: 1 retry count (new) error: 30 error code (new) cause: 12 error cause (new) Details in: go/android-ota-errorcode Bug: 28471955 Change-Id: I00e7153c821e7355c1be81a86c7f228108f3dc37
Diffstat (limited to 'recovery.cpp')
-rw-r--r--recovery.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/recovery.cpp b/recovery.cpp
index 9873f976..6b6643fa 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -50,6 +50,7 @@
50#include "bootloader.h" 50#include "bootloader.h"
51#include "common.h" 51#include "common.h"
52#include "device.h" 52#include "device.h"
53#include "error_code.h"
53#include "fuse_sdcard_provider.h" 54#include "fuse_sdcard_provider.h"
54#include "fuse_sideload.h" 55#include "fuse_sideload.h"
55#include "install.h" 56#include "install.h"
@@ -1000,7 +1001,7 @@ static int apply_from_sdcard(Device* device, bool* wipe_cache) {
1000 } 1001 }
1001 1002
1002 result = install_package(FUSE_SIDELOAD_HOST_PATHNAME, wipe_cache, 1003 result = install_package(FUSE_SIDELOAD_HOST_PATHNAME, wipe_cache,
1003 TEMPORARY_INSTALL_FILE, false); 1004 TEMPORARY_INSTALL_FILE, false, 0/*retry_count*/);
1004 break; 1005 break;
1005 } 1006 }
1006 1007
@@ -1455,10 +1456,21 @@ int main(int argc, char **argv) {
1455 if (!is_battery_ok()) { 1456 if (!is_battery_ok()) {
1456 ui->Print("battery capacity is not enough for installing package, needed is %d%%\n", 1457 ui->Print("battery capacity is not enough for installing package, needed is %d%%\n",
1457 BATTERY_OK_PERCENTAGE); 1458 BATTERY_OK_PERCENTAGE);
1459 // Log the error code to last_install when installation skips due to
1460 // low battery.
1461 FILE* install_log = fopen_path(LAST_INSTALL_FILE, "w");
1462 if (install_log != nullptr) {
1463 fprintf(install_log, "%s\n", update_package);
1464 fprintf(install_log, "0\n");
1465 fprintf(install_log, "error: %d\n", kLowBattery);
1466 fclose(install_log);
1467 } else {
1468 LOGE("failed to open last_install: %s\n", strerror(errno));
1469 }
1458 status = INSTALL_SKIPPED; 1470 status = INSTALL_SKIPPED;
1459 } else { 1471 } else {
1460 status = install_package(update_package, &should_wipe_cache, 1472 status = install_package(update_package, &should_wipe_cache,
1461 TEMPORARY_INSTALL_FILE, true); 1473 TEMPORARY_INSTALL_FILE, true, retry_count);
1462 if (status == INSTALL_SUCCESS && should_wipe_cache) { 1474 if (status == INSTALL_SUCCESS && should_wipe_cache) {
1463 wipe_cache(false, device); 1475 wipe_cache(false, device);
1464 } 1476 }