From 8cf5c8f60f51049278b08ae4cbc31df397b651fd Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Thu, 8 Sep 2016 20:10:11 -0700 Subject: Replace minzip with libziparchive Clean up the duplicated codes that handle the zip files in bootable/recovery; and rename the library of the remaining utility functions to libotautil. Test: Update package installed successfully on angler. Bug: 19472796 Change-Id: Iea8962fcf3004473cb0322b6bb3a9ea3ca7f679e --- otafault/Android.mk | 2 +- otafault/config.cpp | 20 ++++++++++++-------- otafault/config.h | 4 ++-- 3 files changed, 15 insertions(+), 11 deletions(-) (limited to 'otafault') diff --git a/otafault/Android.mk b/otafault/Android.mk index 82c267101..71c2c62f6 100644 --- a/otafault/Android.mk +++ b/otafault/Android.mk @@ -17,7 +17,7 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) otafault_static_libs := \ - libminzip \ + libziparchive \ libz \ libselinux \ libbase \ diff --git a/otafault/config.cpp b/otafault/config.cpp index b4567392d..ee4ef8911 100644 --- a/otafault/config.cpp +++ b/otafault/config.cpp @@ -21,21 +21,21 @@ #include #include +#include -#include "minzip/Zip.h" #include "config.h" #include "ota_io.h" #define OTAIO_MAX_FNAME_SIZE 128 -static ZipArchive* archive; +static ZipArchiveHandle archive; static std::map should_inject_cache; static std::string get_type_path(const char* io_type) { return android::base::StringPrintf("%s/%s", OTAIO_BASE_DIR, io_type); } -void ota_io_init(ZipArchive* za) { +void ota_io_init(ZipArchiveHandle za) { archive = za; ota_set_fault_files(); } @@ -50,9 +50,11 @@ bool should_fault_inject(const char* io_type) { if (should_inject_cache.find(type_path) != should_inject_cache.end()) { return should_inject_cache[type_path]; } - const ZipEntry* entry = mzFindZipEntry(archive, type_path.c_str()); - should_inject_cache[type_path] = entry != nullptr; - return entry != NULL; + ZipString zip_type_path(type_path.c_str()); + ZipEntry entry; + int status = FindEntry(archive, zip_type_path, &entry); + should_inject_cache[type_path] = (status == 0); + return (status == 0); } bool should_hit_cache() { @@ -63,7 +65,9 @@ std::string fault_fname(const char* io_type) { std::string type_path = get_type_path(io_type); std::string fname; fname.resize(OTAIO_MAX_FNAME_SIZE); - const ZipEntry* entry = mzFindZipEntry(archive, type_path.c_str()); - mzReadZipEntry(archive, entry, &fname[0], OTAIO_MAX_FNAME_SIZE); + ZipString zip_type_path(type_path.c_str()); + ZipEntry entry; + int status = FindEntry(archive, zip_type_path, &entry); + ExtractToMemory(archive, &entry, reinterpret_cast(&fname[0]), OTAIO_MAX_FNAME_SIZE); return fname; } diff --git a/otafault/config.h b/otafault/config.h index 4430be3fb..c048617c2 100644 --- a/otafault/config.h +++ b/otafault/config.h @@ -41,7 +41,7 @@ #include -#include "minzip/Zip.h" +#include #define OTAIO_BASE_DIR ".libotafault" #define OTAIO_READ "READ" @@ -52,7 +52,7 @@ /* * Initialize libotafault by providing a reference to the OTA package. */ -void ota_io_init(ZipArchive* za); +void ota_io_init(ZipArchiveHandle zip); /* * Return true if a config file is present for the given IO type. -- cgit v1.2.3