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 --- updater/updater.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'updater/updater.cpp') diff --git a/updater/updater.cpp b/updater/updater.cpp index 1693fa1db..b5db71e2a 100644 --- a/updater/updater.cpp +++ b/updater/updater.cpp @@ -156,11 +156,28 @@ int main(int argc, char** argv) { printf("script aborted: %s\n", state.errmsg); char* line = strtok(state.errmsg, "\n"); while (line) { + // Parse the error code in abort message. + // Example: "E30: This package is for bullhead devices." + if (*line == 'E') { + if (sscanf(line, "E%u: ", &state.error_code) != 1) { + printf("Failed to parse error code: [%s]\n", line); + } + } fprintf(cmd_pipe, "ui_print %s\n", line); line = strtok(NULL, "\n"); } fprintf(cmd_pipe, "ui_print\n"); } + + if (state.error_code != kNoError) { + fprintf(cmd_pipe, "log error: %d\n", state.error_code); + // Cause code should provide additional information about the abort; + // report only when an error exists. + if (state.cause_code != kNoCause) { + fprintf(cmd_pipe, "log cause: %d\n", state.cause_code); + } + } + free(state.errmsg); return 7; } else { -- cgit v1.2.3