Loading Android.mk +3 −3 Original line number Diff line number Diff line Loading @@ -652,9 +652,9 @@ ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 22; echo $$?),0) include $(commands_recovery_local_path)/minadbd/Android.mk \ $(commands_recovery_local_path)/minui/Android.mk else TARGET_GLOBAL_CFLAGS += -DTW_USE_OLD_MINUI_H include $(commands_recovery_local_path)/minadbd.old/Android.mk \ $(commands_recovery_local_path)/minui.old/Android.mk TARGET_GLOBAL_CFLAGS += -DTW_USE_MINUI_21 include $(commands_recovery_local_path)/minadbd21/Android.mk \ $(commands_recovery_local_path)/minui21/Android.mk endif #includes for TWRP Loading error_code.h +22 −0 Original line number Diff line number Diff line Loading @@ -44,4 +44,26 @@ enum CauseCode { kVendorFailure = 200 }; enum UncryptErrorCode { kUncryptNoError = -1, kUncryptErrorPlaceholder = 50, kUncryptTimeoutError = 100, kUncryptFileRemoveError, kUncryptFileOpenError, kUncryptSocketOpenError, kUncryptSocketWriteError, kUncryptSocketListenError, kUncryptSocketAcceptError, kUncryptFstabReadError, kUncryptFileStatError, kUncryptBlockOpenError, kUncryptIoctlError, kUncryptReadError, kUncryptWriteError, kUncryptFileSyncError, kUncryptFileCloseError, kUncryptFileRenameError, kUncryptPackageMissingError, }; #endif install.cpp +41 −19 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include <string> #include <vector> #include <android-base/file.h> #include <android-base/parseint.h> #include <android-base/stringprintf.h> #include <android-base/strings.h> Loading @@ -54,6 +55,7 @@ static constexpr const char* AB_OTA_PAYLOAD_PROPERTIES = "payload_properties.txt static constexpr const char* AB_OTA_PAYLOAD = "payload.bin"; #define PUBLIC_KEYS_FILE "/res/keys" static constexpr const char* METADATA_PATH = "META-INF/com/android/metadata"; static constexpr const char* UNCRYPT_STATUS = "/cache/recovery/uncrypt_status"; // Default allocation of progress bar segments to operations static const int VERIFICATION_PROGRESS_TIME = 60; Loading Loading @@ -371,6 +373,14 @@ try_update_binary(const char* path, ZipArchive* zip, bool* wipe_cache, } pid_t pid = fork(); if (pid == -1) { close(pipefd[0]); close(pipefd[1]); LOGE("Failed to fork update binary: %s\n", strerror(errno)); return INSTALL_ERROR; } if (pid == 0) { umask(022); close(pipefd[0]); Loading Loading @@ -511,13 +521,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 { LOGE("failed to open last_install: %s\n", strerror(errno)); } int result; std::vector<std::string> log_buffer; if (setup_install_mounts() != 0) { Loading @@ -526,21 +529,40 @@ 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); // Measure the time spent to apply OTA update in seconds. 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); int time_total = static_cast<int>(duration.count()); for (const auto& s : log_buffer) { fprintf(install_log, "%s\n", s.c_str()); if (ensure_path_mounted(UNCRYPT_STATUS) != 0) { LOGW("Can't mount %s\n", UNCRYPT_STATUS); } else { std::string uncrypt_status; if (!android::base::ReadFileToString(UNCRYPT_STATUS, &uncrypt_status)) { LOGW("failed to read uncrypt status: %s\n", strerror(errno)); } else if (!android::base::StartsWith(uncrypt_status, "uncrypt_")) { LOGW("corrupted uncrypt_status: %s: %s\n", uncrypt_status.c_str(), strerror(errno)); } else { 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)) { LOGE("failed to write %s: %s\n", install_file, strerror(errno)); } // Write a copy into last_log. LOGI("%s\n", log_content.c_str()); return result; } Loading minadbd.old/Android.mk→minadbd21/Android.mk +0 −0 File moved. View file minadbd.old/README.txt→minadbd21/README.txt +0 −0 File moved. View file Loading
Android.mk +3 −3 Original line number Diff line number Diff line Loading @@ -652,9 +652,9 @@ ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 22; echo $$?),0) include $(commands_recovery_local_path)/minadbd/Android.mk \ $(commands_recovery_local_path)/minui/Android.mk else TARGET_GLOBAL_CFLAGS += -DTW_USE_OLD_MINUI_H include $(commands_recovery_local_path)/minadbd.old/Android.mk \ $(commands_recovery_local_path)/minui.old/Android.mk TARGET_GLOBAL_CFLAGS += -DTW_USE_MINUI_21 include $(commands_recovery_local_path)/minadbd21/Android.mk \ $(commands_recovery_local_path)/minui21/Android.mk endif #includes for TWRP Loading
error_code.h +22 −0 Original line number Diff line number Diff line Loading @@ -44,4 +44,26 @@ enum CauseCode { kVendorFailure = 200 }; enum UncryptErrorCode { kUncryptNoError = -1, kUncryptErrorPlaceholder = 50, kUncryptTimeoutError = 100, kUncryptFileRemoveError, kUncryptFileOpenError, kUncryptSocketOpenError, kUncryptSocketWriteError, kUncryptSocketListenError, kUncryptSocketAcceptError, kUncryptFstabReadError, kUncryptFileStatError, kUncryptBlockOpenError, kUncryptIoctlError, kUncryptReadError, kUncryptWriteError, kUncryptFileSyncError, kUncryptFileCloseError, kUncryptFileRenameError, kUncryptPackageMissingError, }; #endif
install.cpp +41 −19 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include <string> #include <vector> #include <android-base/file.h> #include <android-base/parseint.h> #include <android-base/stringprintf.h> #include <android-base/strings.h> Loading @@ -54,6 +55,7 @@ static constexpr const char* AB_OTA_PAYLOAD_PROPERTIES = "payload_properties.txt static constexpr const char* AB_OTA_PAYLOAD = "payload.bin"; #define PUBLIC_KEYS_FILE "/res/keys" static constexpr const char* METADATA_PATH = "META-INF/com/android/metadata"; static constexpr const char* UNCRYPT_STATUS = "/cache/recovery/uncrypt_status"; // Default allocation of progress bar segments to operations static const int VERIFICATION_PROGRESS_TIME = 60; Loading Loading @@ -371,6 +373,14 @@ try_update_binary(const char* path, ZipArchive* zip, bool* wipe_cache, } pid_t pid = fork(); if (pid == -1) { close(pipefd[0]); close(pipefd[1]); LOGE("Failed to fork update binary: %s\n", strerror(errno)); return INSTALL_ERROR; } if (pid == 0) { umask(022); close(pipefd[0]); Loading Loading @@ -511,13 +521,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 { LOGE("failed to open last_install: %s\n", strerror(errno)); } int result; std::vector<std::string> log_buffer; if (setup_install_mounts() != 0) { Loading @@ -526,21 +529,40 @@ 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); // Measure the time spent to apply OTA update in seconds. 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); int time_total = static_cast<int>(duration.count()); for (const auto& s : log_buffer) { fprintf(install_log, "%s\n", s.c_str()); if (ensure_path_mounted(UNCRYPT_STATUS) != 0) { LOGW("Can't mount %s\n", UNCRYPT_STATUS); } else { std::string uncrypt_status; if (!android::base::ReadFileToString(UNCRYPT_STATUS, &uncrypt_status)) { LOGW("failed to read uncrypt status: %s\n", strerror(errno)); } else if (!android::base::StartsWith(uncrypt_status, "uncrypt_")) { LOGW("corrupted uncrypt_status: %s: %s\n", uncrypt_status.c_str(), strerror(errno)); } else { 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)) { LOGE("failed to write %s: %s\n", install_file, strerror(errno)); } // Write a copy into last_log. LOGI("%s\n", log_content.c_str()); return result; } Loading