From a86dddbfa593ae1227806af9692fbb6223d4e435 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 3 May 2019 22:52:37 -0700 Subject: Track libziparchive API change. Bug: http://b/129068177 Test: treehugger Change-Id: Ie5b2b0cff087f2e9e65a4e77c187e3173357f3ad --- install/install.cpp | 15 +++++---------- install/wipe_device.cpp | 3 +-- tests/unit/install_test.cpp | 3 +-- tests/unit/package_test.cpp | 5 ++--- tests/unit/zip_test.cpp | 3 +-- updater/blockimg.cpp | 4 ++-- updater/install.cpp | 6 ++---- updater/updater.cpp | 3 +-- 8 files changed, 15 insertions(+), 27 deletions(-) diff --git a/install/install.cpp b/install/install.cpp index 5d514fa23..d62bffc59 100644 --- a/install/install.cpp +++ b/install/install.cpp @@ -73,9 +73,8 @@ bool ReadMetadataFromPackage(ZipArchiveHandle zip, std::map GetWipePartitionList(Package* wipe_package) { constexpr char RECOVERY_WIPE_ENTRY_NAME[] = "recovery.wipe"; std::string partition_list_content; - ZipString path(RECOVERY_WIPE_ENTRY_NAME); ZipEntry entry; - if (FindEntry(zip, path, &entry) == 0) { + if (FindEntry(zip, RECOVERY_WIPE_ENTRY_NAME, &entry) == 0) { uint32_t length = entry.uncompressed_length; partition_list_content = std::string(length, '\0'); if (auto err = ExtractToMemory( diff --git a/tests/unit/install_test.cpp b/tests/unit/install_test.cpp index c1d77fb7b..4ec409908 100644 --- a/tests/unit/install_test.cpp +++ b/tests/unit/install_test.cpp @@ -271,9 +271,8 @@ static void VerifyAbUpdateCommands(const std::string& serialno, bool success = t ZipArchiveHandle zip; ASSERT_EQ(0, OpenArchive(temp_file.path, &zip)); - ZipString payload_name("payload.bin"); ZipEntry payload_entry; - ASSERT_EQ(0, FindEntry(zip, payload_name, &payload_entry)); + ASSERT_EQ(0, FindEntry(zip, "payload.bin", &payload_entry)); std::map metadata; ASSERT_TRUE(ReadMetadataFromPackage(zip, &metadata)); diff --git a/tests/unit/package_test.cpp b/tests/unit/package_test.cpp index a735a699e..5e31f7fa5 100644 --- a/tests/unit/package_test.cpp +++ b/tests/unit/package_test.cpp @@ -105,10 +105,9 @@ TEST_F(PackageTest, GetZipArchiveHandle_extract_entry) { ASSERT_TRUE(zip); // Check that we can extract one zip entry. - std::string entry_name = "dir1/file3.txt"; - ZipString path(entry_name.c_str()); + std::string_view entry_name = "dir1/file3.txt"; ZipEntry entry; - ASSERT_EQ(0, FindEntry(zip, path, &entry)); + ASSERT_EQ(0, FindEntry(zip, entry_name, &entry)); std::vector extracted(entry_name.size()); ASSERT_EQ(0, ExtractToMemory(zip, &entry, extracted.data(), extracted.size())); diff --git a/tests/unit/zip_test.cpp b/tests/unit/zip_test.cpp index dfe617ebe..0753d64e1 100644 --- a/tests/unit/zip_test.cpp +++ b/tests/unit/zip_test.cpp @@ -37,10 +37,9 @@ TEST(ZipTest, OpenFromMemory) { ASSERT_EQ(0, OpenArchiveFromMemory(map.addr, map.length, zip_path.c_str(), &handle)); static constexpr const char* BINARY_PATH = "META-INF/com/google/android/update-binary"; - ZipString binary_path(BINARY_PATH); ZipEntry binary_entry; // Make sure the package opens correctly and its entry can be read. - ASSERT_EQ(0, FindEntry(handle, binary_path, &binary_entry)); + ASSERT_EQ(0, FindEntry(handle, BINARY_PATH, &binary_entry)); TemporaryFile tmp_binary; ASSERT_NE(-1, tmp_binary.fd); diff --git a/updater/blockimg.cpp b/updater/blockimg.cpp index 07c3c7b52..b008c28b4 100644 --- a/updater/blockimg.cpp +++ b/updater/blockimg.cpp @@ -1680,7 +1680,7 @@ static Value* PerformBlockImageUpdate(const char* name, State* state, return StringValue(""); } - ZipString path_data(patch_data_fn->data.c_str()); + std::string_view path_data(patch_data_fn->data); ZipEntry patch_entry; if (FindEntry(za, path_data, &patch_entry) != 0) { LOG(ERROR) << name << "(): no file \"" << patch_data_fn->data << "\" in package"; @@ -1688,7 +1688,7 @@ static Value* PerformBlockImageUpdate(const char* name, State* state, } params.patch_start = ui->package_zip_addr + patch_entry.offset; - ZipString new_data(new_data_fn->data.c_str()); + std::string_view new_data(new_data_fn->data); ZipEntry new_entry; if (FindEntry(za, new_data, &new_entry) != 0) { LOG(ERROR) << name << "(): no file \"" << new_data_fn->data << "\" in package"; diff --git a/updater/install.cpp b/updater/install.cpp index 8eba64f5d..c30f63960 100644 --- a/updater/install.cpp +++ b/updater/install.cpp @@ -130,9 +130,8 @@ Value* PackageExtractFileFn(const char* name, State* state, const std::string& dest_path = args[1]; ZipArchiveHandle za = static_cast(state->cookie)->package_zip; - ZipString zip_string_path(zip_path.c_str()); ZipEntry entry; - if (FindEntry(za, zip_string_path, &entry) != 0) { + if (FindEntry(za, zip_path, &entry) != 0) { LOG(ERROR) << name << ": no " << zip_path << " in package"; return StringValue(""); } @@ -174,9 +173,8 @@ Value* PackageExtractFileFn(const char* name, State* state, const std::string& zip_path = args[0]; ZipArchiveHandle za = static_cast(state->cookie)->package_zip; - ZipString zip_string_path(zip_path.c_str()); ZipEntry entry; - if (FindEntry(za, zip_string_path, &entry) != 0) { + if (FindEntry(za, zip_path, &entry) != 0) { return ErrorAbort(state, kPackageExtractFileFailure, "%s(): no %s in package", name, zip_path.c_str()); } diff --git a/updater/updater.cpp b/updater/updater.cpp index 7b5a3f938..a020699ca 100644 --- a/updater/updater.cpp +++ b/updater/updater.cpp @@ -101,9 +101,8 @@ int main(int argc, char** argv) { return 3; } - ZipString script_name(SCRIPT_NAME); ZipEntry script_entry; - int find_err = FindEntry(za, script_name, &script_entry); + int find_err = FindEntry(za, SCRIPT_NAME, &script_entry); if (find_err != 0) { LOG(ERROR) << "failed to find " << SCRIPT_NAME << " in " << package_filename << ": " << ErrorCodeString(find_err); -- cgit v1.2.3