summaryrefslogtreecommitdiffstats
path: root/otafault/config.cpp
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2016-10-18 23:13:07 +0200
committerTianjie Xu <xunchang@google.com>2016-10-18 23:31:04 +0200
commit8176cf232e9f613a2e500f09461fc3f448267d07 (patch)
tree7bef9898660d13fc74dbe528bc0331950fe19604 /otafault/config.cpp
parentMerge "Change StringValue to use std::string" (diff)
parentMerge "Replace minzip with libziparchive" (diff)
downloadandroid_bootable_recovery-8176cf232e9f613a2e500f09461fc3f448267d07.tar
android_bootable_recovery-8176cf232e9f613a2e500f09461fc3f448267d07.tar.gz
android_bootable_recovery-8176cf232e9f613a2e500f09461fc3f448267d07.tar.bz2
android_bootable_recovery-8176cf232e9f613a2e500f09461fc3f448267d07.tar.lz
android_bootable_recovery-8176cf232e9f613a2e500f09461fc3f448267d07.tar.xz
android_bootable_recovery-8176cf232e9f613a2e500f09461fc3f448267d07.tar.zst
android_bootable_recovery-8176cf232e9f613a2e500f09461fc3f448267d07.zip
Diffstat (limited to 'otafault/config.cpp')
-rw-r--r--otafault/config.cpp20
1 files changed, 12 insertions, 8 deletions
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 <unistd.h>
#include <android-base/stringprintf.h>
+#include <ziparchive/zip_archive.h>
-#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<std::string, bool> 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<uint8_t*>(&fname[0]), OTAIO_MAX_FNAME_SIZE);
return fname;
}