diff options
author | Tao Bao <tbao@google.com> | 2016-09-27 22:24:22 +0200 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-09-27 22:24:22 +0200 |
commit | 64b92dfb5d67cb0641524ad2988767c97e2029ce (patch) | |
tree | be7ff570cc94b1f91956dcdacd5c38a097066860 /recovery.cpp | |
parent | DO NOT MERGE Fail gracefully when we fail to fork the update binary (diff) | |
parent | DO NOT MERGE Duplicate the last_install content into last_log. (diff) | |
download | android_bootable_recovery-64b92dfb5d67cb0641524ad2988767c97e2029ce.tar android_bootable_recovery-64b92dfb5d67cb0641524ad2988767c97e2029ce.tar.gz android_bootable_recovery-64b92dfb5d67cb0641524ad2988767c97e2029ce.tar.bz2 android_bootable_recovery-64b92dfb5d67cb0641524ad2988767c97e2029ce.tar.lz android_bootable_recovery-64b92dfb5d67cb0641524ad2988767c97e2029ce.tar.xz android_bootable_recovery-64b92dfb5d67cb0641524ad2988767c97e2029ce.tar.zst android_bootable_recovery-64b92dfb5d67cb0641524ad2988767c97e2029ce.zip |
Diffstat (limited to 'recovery.cpp')
-rw-r--r-- | recovery.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/recovery.cpp b/recovery.cpp index ccb2d223b..0f0b978e7 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -1429,15 +1429,18 @@ static bool bootreason_in_blacklist() { } static void log_failure_code(ErrorCode code, const char *update_package) { - FILE* install_log = fopen_path(TEMPORARY_INSTALL_FILE, "w"); - if (install_log != nullptr) { - fprintf(install_log, "%s\n", update_package); - fprintf(install_log, "0\n"); - fprintf(install_log, "error: %d\n", code); - fclose(install_log); - } else { - LOGE("failed to open last_install: %s\n", strerror(errno)); + std::vector<std::string> log_buffer = { + update_package, + "0", // install result + "error: " + std::to_string(code), + }; + std::string log_content = android::base::Join(log_buffer, "\n"); + if (!android::base::WriteStringToFile(log_content, TEMPORARY_INSTALL_FILE)) { + LOGE("failed to write %s: %s\n", TEMPORARY_INSTALL_FILE, strerror(errno)); } + + // Also write the info into last_log. + LOGI("%s\n", log_content.c_str()); } static ssize_t logbasename( |