From 60b242cfd58a234727f5d339e2f6fa4e91ffe1fa Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Tue, 30 Jul 2019 16:48:52 -0700 Subject: Simulator: add the argument to keep the updated images Add the command line option to select the work directory and save the updated image files. Because some people might have interested in getting updated images from an ota file. Also, fix a minor issue that the destination of package_extract_file needs to be updated if it's a block device. Otherwise, an unintended file may be extracted in the callers' directory. Test: run simulation, run unit tests Change-Id: Ic6a7db0580bc1748d6e080102e4654da4e41fd8c --- updater/install.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'updater/install.cpp') diff --git a/updater/install.cpp b/updater/install.cpp index c82351ec4..be0ceb06c 100644 --- a/updater/install.cpp +++ b/updater/install.cpp @@ -113,7 +113,7 @@ Value* PackageExtractFileFn(const char* name, State* state, argv.size()); } const std::string& zip_path = args[0]; - const std::string& dest_path = args[1]; + std::string dest_path = args[1]; ZipArchiveHandle za = state->updater->GetPackageHandle(); ZipEntry entry; @@ -122,6 +122,13 @@ Value* PackageExtractFileFn(const char* name, State* state, return StringValue(""); } + // Update the destination of package_extract_file if it's a block device. During simulation the + // destination will map to a fake file. + if (std::string block_device_name = state->updater->FindBlockDeviceName(dest_path); + !block_device_name.empty()) { + dest_path = block_device_name; + } + android::base::unique_fd fd(TEMP_FAILURE_RETRY( open(dest_path.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR))); if (fd == -1) { -- cgit v1.2.3