diff options
Diffstat (limited to '')
-rw-r--r-- | uncrypt/uncrypt.cpp | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/uncrypt/uncrypt.cpp b/uncrypt/uncrypt.cpp index 96edfd781..b7867edc5 100644 --- a/uncrypt/uncrypt.cpp +++ b/uncrypt/uncrypt.cpp @@ -110,7 +110,7 @@ #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/unique_fd.h> -#include <bootloader_message_writer.h> +#include <bootloader_message/bootloader_message.h> #include <cutils/android_reboot.h> #include <cutils/properties.h> #include <cutils/sockets.h> @@ -130,7 +130,6 @@ // 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; @@ -462,32 +461,12 @@ 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; } @@ -519,14 +498,31 @@ static bool setup_bcb(const int socket) { return false; } LOG(INFO) << " received command: [" << content << "] (" << content.size() << ")"; + std::vector<std::string> options = android::base::Split(content, "\n"); + std::string wipe_package; + for (auto& option : options) { + if (android::base::StartsWith(option, "--wipe_package=")) { + std::string path = option.substr(strlen("--wipe_package=")); + if (!android::base::ReadFileToString(path, &wipe_package)) { + PLOG(ERROR) << "failed to read " << path; + return false; + } + option = android::base::StringPrintf("--wipe_package_size=%zu", wipe_package.size()); + } + } // c8. setup the bcb command std::string err; - if (!write_bootloader_message({content}, &err)) { + if (!write_bootloader_message(options, &err)) { LOG(ERROR) << "failed to set bootloader message: " << err; write_status_to_socket(-1, socket); return false; } + if (!wipe_package.empty() && !write_wipe_package(wipe_package, &err)) { + PLOG(ERROR) << "failed to set wipe package: " << err; + write_status_to_socket(-1, socket); + return false; + } // c10. send "100" status write_status_to_socket(100, socket); return true; |