From 162558382b768a4120b3e41090a4c7b53f11469a Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Sat, 30 Apr 2016 11:49:59 -0700 Subject: 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 --- install.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'install.cpp') diff --git a/install.cpp b/install.cpp index d725c7b88..57328528c 100644 --- a/install.cpp +++ b/install.cpp @@ -27,7 +27,11 @@ #include #include +#include +#include + #include "common.h" +#include "error_code.h" #include "install.h" #include "minui/minui.h" #include "minzip/SysUtil.h" @@ -253,6 +257,8 @@ really_install_package(const char *path, bool* wipe_cache, bool needs_mount, ui->Print("Update package verification took %.1f s (result %d).\n", duration.count(), err); if (err != VERIFY_SUCCESS) { LOGE("signature verification failed\n"); + log_buffer.push_back(android::base::StringPrintf("error: %d", kZipVerificationFailure)); + sysReleaseMap(&map); return INSTALL_CORRUPT; } @@ -262,6 +268,8 @@ really_install_package(const char *path, bool* wipe_cache, bool needs_mount, err = mzOpenZipArchive(map.addr, map.length, &zip); if (err != 0) { LOGE("Can't open %s\n(%s)\n", path, err != -1 ? strerror(err) : "bad"); + log_buffer.push_back(android::base::StringPrintf("error: %d", kZipOpenFailure)); + sysReleaseMap(&map); return INSTALL_CORRUPT; } @@ -280,7 +288,7 @@ really_install_package(const char *path, bool* wipe_cache, bool needs_mount, int install_package(const char* path, bool* wipe_cache, const char* install_file, - bool needs_mount) + bool needs_mount, int retry_count) { modified_flash = true; auto start = std::chrono::system_clock::now(); @@ -300,13 +308,14 @@ install_package(const char* path, bool* wipe_cache, const char* install_file, } else { result = really_install_package(path, wipe_cache, needs_mount, log_buffer); } - if (install_log) { + if (install_log != nullptr) { fputc(result == INSTALL_SUCCESS ? '1' : '0', install_log); fputc('\n', install_log); std::chrono::duration duration = std::chrono::system_clock::now() - start; int count = static_cast(duration.count()); // Report the time spent to apply OTA update in seconds. fprintf(install_log, "time_total: %d\n", count); + fprintf(install_log, "retry: %d\n", retry_count); for (const auto& s : log_buffer) { fprintf(install_log, "%s\n", s.c_str()); -- cgit v1.2.3