summaryrefslogtreecommitdiffstats
path: root/recovery.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2016-09-27 00:20:15 +0200
committerandroid-build-merger <android-build-merger@google.com>2016-09-27 00:20:15 +0200
commit13414c6a0430358f6f5631481017cc677a53e4b2 (patch)
tree4894ba778a43e4e9e48a841a5c4ef834808ce437 /recovery.cpp
parentresolve merge conflicts of d5c7d6b to nyc-mr1-dev-plus-aosp (diff)
parentDuplicate the last_install content into last_log. (diff)
downloadandroid_bootable_recovery-13414c6a0430358f6f5631481017cc677a53e4b2.tar
android_bootable_recovery-13414c6a0430358f6f5631481017cc677a53e4b2.tar.gz
android_bootable_recovery-13414c6a0430358f6f5631481017cc677a53e4b2.tar.bz2
android_bootable_recovery-13414c6a0430358f6f5631481017cc677a53e4b2.tar.lz
android_bootable_recovery-13414c6a0430358f6f5631481017cc677a53e4b2.tar.xz
android_bootable_recovery-13414c6a0430358f6f5631481017cc677a53e4b2.tar.zst
android_bootable_recovery-13414c6a0430358f6f5631481017cc677a53e4b2.zip
Diffstat (limited to 'recovery.cpp')
-rw-r--r--recovery.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/recovery.cpp b/recovery.cpp
index e0f5a2ee3..c7d840dd6 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -1431,15 +1431,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 {
- PLOG(ERROR) << "failed to open last_install";
+ 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)) {
+ PLOG(ERROR) << "failed to write " << TEMPORARY_INSTALL_FILE;
}
+
+ // Also write the info into last_log.
+ LOG(INFO) << log_content;
}
static ssize_t logbasename(