Loading install.cpp +13 −1 Original line number Diff line number Diff line Loading @@ -27,10 +27,11 @@ #include <string> #include <vector> #include <android-base/file.h> #include <android-base/logging.h> #include <android-base/parseint.h> #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/logging.h> #include "common.h" #include "error_code.h" Loading @@ -47,6 +48,7 @@ extern RecoveryUI* ui; #define ASSUMED_UPDATE_BINARY_NAME "META-INF/com/google/android/update-binary" #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 @@ -384,6 +386,16 @@ install_package(const char* path, bool* wipe_cache, const char* install_file, fprintf(install_log, "%s\n", s.c_str()); } if (ensure_path_mounted(UNCRYPT_STATUS) != 0) { LOG(WARNING) << "Can't mount " << UNCRYPT_STATUS; } else { std::string uncrypt_status; if (!android::base::ReadFileToString(UNCRYPT_STATUS, &uncrypt_status)) { PLOG(WARNING) << "failed to read uncrypt status"; } else { fprintf(install_log, "%s\n", android::base::Trim(uncrypt_status).c_str()); } } fclose(install_log); } return result; Loading uncrypt/uncrypt.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -130,6 +130,7 @@ // devices, on which /cache partitions always exist. static const std::string CACHE_BLOCK_MAP = "/cache/recovery/block.map"; static const std::string UNCRYPT_PATH_FILE = "/cache/recovery/uncrypt_file"; static const std::string UNCRYPT_STATUS = "/cache/recovery/uncrypt_status"; static const std::string UNCRYPT_SOCKET = "uncrypt"; static struct fstab* fstab = nullptr; Loading Loading @@ -461,12 +462,32 @@ static bool uncrypt_wrapper(const char* input_path, const char* map_file, const input_path = package.c_str(); } CHECK(map_file != nullptr); #define UNCRYPT_TIME_HOLDER 0x7FFFFFFF // Intialize the uncrypt time cost to a huge number so that we can tell from // the statistics if an uncrypt fails to finish. if (!android::base::WriteStringToFile(android::base::StringPrintf( "uncrypt_time: %d\n", UNCRYPT_TIME_HOLDER), UNCRYPT_STATUS)) { PLOG(WARNING) << "failed to write to " << UNCRYPT_STATUS; } auto start = std::chrono::system_clock::now(); int status = uncrypt(input_path, map_file, socket); if (status != 0) { write_status_to_socket(-1, socket); return false; } std::chrono::duration<double> duration = std::chrono::system_clock::now() - start; int count = static_cast<int>(duration.count()); // Overwrite the uncrypt_time if uncrypt finishes successfully. if (!android::base::WriteStringToFile( android::base::StringPrintf("uncrypt_time: %d\n", count), UNCRYPT_STATUS)) { PLOG(WARNING) << "failed to write to " << UNCRYPT_STATUS; } write_status_to_socket(100, socket); return true; } Loading Loading
install.cpp +13 −1 Original line number Diff line number Diff line Loading @@ -27,10 +27,11 @@ #include <string> #include <vector> #include <android-base/file.h> #include <android-base/logging.h> #include <android-base/parseint.h> #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/logging.h> #include "common.h" #include "error_code.h" Loading @@ -47,6 +48,7 @@ extern RecoveryUI* ui; #define ASSUMED_UPDATE_BINARY_NAME "META-INF/com/google/android/update-binary" #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 @@ -384,6 +386,16 @@ install_package(const char* path, bool* wipe_cache, const char* install_file, fprintf(install_log, "%s\n", s.c_str()); } if (ensure_path_mounted(UNCRYPT_STATUS) != 0) { LOG(WARNING) << "Can't mount " << UNCRYPT_STATUS; } else { std::string uncrypt_status; if (!android::base::ReadFileToString(UNCRYPT_STATUS, &uncrypt_status)) { PLOG(WARNING) << "failed to read uncrypt status"; } else { fprintf(install_log, "%s\n", android::base::Trim(uncrypt_status).c_str()); } } fclose(install_log); } return result; Loading
uncrypt/uncrypt.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -130,6 +130,7 @@ // devices, on which /cache partitions always exist. static const std::string CACHE_BLOCK_MAP = "/cache/recovery/block.map"; static const std::string UNCRYPT_PATH_FILE = "/cache/recovery/uncrypt_file"; static const std::string UNCRYPT_STATUS = "/cache/recovery/uncrypt_status"; static const std::string UNCRYPT_SOCKET = "uncrypt"; static struct fstab* fstab = nullptr; Loading Loading @@ -461,12 +462,32 @@ static bool uncrypt_wrapper(const char* input_path, const char* map_file, const input_path = package.c_str(); } CHECK(map_file != nullptr); #define UNCRYPT_TIME_HOLDER 0x7FFFFFFF // Intialize the uncrypt time cost to a huge number so that we can tell from // the statistics if an uncrypt fails to finish. if (!android::base::WriteStringToFile(android::base::StringPrintf( "uncrypt_time: %d\n", UNCRYPT_TIME_HOLDER), UNCRYPT_STATUS)) { PLOG(WARNING) << "failed to write to " << UNCRYPT_STATUS; } auto start = std::chrono::system_clock::now(); int status = uncrypt(input_path, map_file, socket); if (status != 0) { write_status_to_socket(-1, socket); return false; } std::chrono::duration<double> duration = std::chrono::system_clock::now() - start; int count = static_cast<int>(duration.count()); // Overwrite the uncrypt_time if uncrypt finishes successfully. if (!android::base::WriteStringToFile( android::base::StringPrintf("uncrypt_time: %d\n", count), UNCRYPT_STATUS)) { PLOG(WARNING) << "failed to write to " << UNCRYPT_STATUS; } write_status_to_socket(100, socket); return true; } Loading