summaryrefslogtreecommitdiffstats
path: root/recovery.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2016-09-27 03:45:12 +0200
committerandroid-build-merger <android-build-merger@google.com>2016-09-27 03:45:12 +0200
commitbfee61bf28ea72b67a41f4e0c2c6f739f3928ee3 (patch)
tree88ffd7187b8dc906d4ebb516fc43a14347ff3e9a /recovery.cpp
parentMerge "Switch to <android-base/properties.h>." am: cc02f9652f (diff)
parentDuplicate the last_install content into last_log. (diff)
downloadandroid_bootable_recovery-bfee61bf28ea72b67a41f4e0c2c6f739f3928ee3.tar
android_bootable_recovery-bfee61bf28ea72b67a41f4e0c2c6f739f3928ee3.tar.gz
android_bootable_recovery-bfee61bf28ea72b67a41f4e0c2c6f739f3928ee3.tar.bz2
android_bootable_recovery-bfee61bf28ea72b67a41f4e0c2c6f739f3928ee3.tar.lz
android_bootable_recovery-bfee61bf28ea72b67a41f4e0c2c6f739f3928ee3.tar.xz
android_bootable_recovery-bfee61bf28ea72b67a41f4e0c2c6f739f3928ee3.tar.zst
android_bootable_recovery-bfee61bf28ea72b67a41f4e0c2c6f739f3928ee3.zip
Diffstat (limited to 'recovery.cpp')
-rw-r--r--recovery.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/recovery.cpp b/recovery.cpp
index bd06aaffa..91c18b529 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -1554,15 +1554,19 @@ int main(int argc, char **argv) {
BATTERY_OK_PERCENTAGE);
// Log the error code to last_install when installation skips due to
// low battery.
- FILE* install_log = fopen_path(LAST_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", kLowBattery);
- 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(kLowBattery),
+ };
+ std::string log_content = android::base::Join(log_buffer, "\n");
+ if (!android::base::WriteStringToFile(log_content, LAST_INSTALL_FILE)) {
+ PLOG(ERROR) << "failed to write " << LAST_INSTALL_FILE;
}
+
+ // Also write the info into last_log.
+ LOG(INFO) << log_content;
+
status = INSTALL_SKIPPED;
} else {
status = install_package(update_package, &should_wipe_cache,