Loading install.cpp +30 −30 Original line number Diff line number Diff line Loading @@ -358,13 +358,6 @@ install_package(const char* path, bool* wipe_cache, const char* install_file, modified_flash = true; auto start = std::chrono::system_clock::now(); FILE* install_log = fopen_path(install_file, "w"); if (install_log) { fputs(path, install_log); fputc('\n', install_log); } else { PLOG(ERROR) << "failed to open last_install"; } int result; std::vector<std::string> log_buffer; if (setup_install_mounts() != 0) { Loading @@ -373,18 +366,10 @@ install_package(const char* path, bool* wipe_cache, const char* install_file, } else { result = really_install_package(path, wipe_cache, needs_mount, log_buffer, retry_count); } if (install_log != nullptr) { fputc(result == INSTALL_SUCCESS ? '1' : '0', install_log); fputc('\n', install_log); std::chrono::duration<double> duration = std::chrono::system_clock::now() - start; int count = static_cast<int>(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()); } // Measure the time spent to apply OTA update in seconds. std::chrono::duration<double> duration = std::chrono::system_clock::now() - start; int time_total = static_cast<int>(duration.count()); if (ensure_path_mounted(UNCRYPT_STATUS) != 0) { LOG(WARNING) << "Can't mount " << UNCRYPT_STATUS; Loading @@ -395,10 +380,25 @@ install_package(const char* path, bool* wipe_cache, const char* install_file, } else if (!android::base::StartsWith(uncrypt_status, "uncrypt_time:")) { PLOG(WARNING) << "corrupted uncrypt_status: " << uncrypt_status; } else { fprintf(install_log, "%s\n", android::base::Trim(uncrypt_status).c_str()); log_buffer.push_back(android::base::Trim(uncrypt_status)); } } fclose(install_log); // The first two lines need to be the package name and install result. std::vector<std::string> log_header = { path, result == INSTALL_SUCCESS ? "1" : "0", "time_total: " + std::to_string(time_total), "retry: " + std::to_string(retry_count), }; std::string log_content = android::base::Join(log_header, "\n") + "\n" + android::base::Join(log_buffer, "\n"); if (!android::base::WriteStringToFile(log_content, install_file)) { PLOG(ERROR) << "failed to write " << install_file; } // Write a copy into last_log. LOG(INFO) << log_content; return result; } recovery.cpp +12 −8 Original line number Diff line number Diff line Loading @@ -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, Loading Loading
install.cpp +30 −30 Original line number Diff line number Diff line Loading @@ -358,13 +358,6 @@ install_package(const char* path, bool* wipe_cache, const char* install_file, modified_flash = true; auto start = std::chrono::system_clock::now(); FILE* install_log = fopen_path(install_file, "w"); if (install_log) { fputs(path, install_log); fputc('\n', install_log); } else { PLOG(ERROR) << "failed to open last_install"; } int result; std::vector<std::string> log_buffer; if (setup_install_mounts() != 0) { Loading @@ -373,18 +366,10 @@ install_package(const char* path, bool* wipe_cache, const char* install_file, } else { result = really_install_package(path, wipe_cache, needs_mount, log_buffer, retry_count); } if (install_log != nullptr) { fputc(result == INSTALL_SUCCESS ? '1' : '0', install_log); fputc('\n', install_log); std::chrono::duration<double> duration = std::chrono::system_clock::now() - start; int count = static_cast<int>(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()); } // Measure the time spent to apply OTA update in seconds. std::chrono::duration<double> duration = std::chrono::system_clock::now() - start; int time_total = static_cast<int>(duration.count()); if (ensure_path_mounted(UNCRYPT_STATUS) != 0) { LOG(WARNING) << "Can't mount " << UNCRYPT_STATUS; Loading @@ -395,10 +380,25 @@ install_package(const char* path, bool* wipe_cache, const char* install_file, } else if (!android::base::StartsWith(uncrypt_status, "uncrypt_time:")) { PLOG(WARNING) << "corrupted uncrypt_status: " << uncrypt_status; } else { fprintf(install_log, "%s\n", android::base::Trim(uncrypt_status).c_str()); log_buffer.push_back(android::base::Trim(uncrypt_status)); } } fclose(install_log); // The first two lines need to be the package name and install result. std::vector<std::string> log_header = { path, result == INSTALL_SUCCESS ? "1" : "0", "time_total: " + std::to_string(time_total), "retry: " + std::to_string(retry_count), }; std::string log_content = android::base::Join(log_header, "\n") + "\n" + android::base::Join(log_buffer, "\n"); if (!android::base::WriteStringToFile(log_content, install_file)) { PLOG(ERROR) << "failed to write " << install_file; } // Write a copy into last_log. LOG(INFO) << log_content; return result; }
recovery.cpp +12 −8 Original line number Diff line number Diff line Loading @@ -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, Loading