From 1fca8e91f32dc8b13d3129b7ef4a0194839736e6 Mon Sep 17 00:00:00 2001 From: Brian Carlstrom Date: Fri, 23 May 2014 02:47:28 -0700 Subject: [PATCH] Fix ExtractToMemMap to show original zip file name in ashmem Change-Id: I630a870a8cc38475f12dd158bdc57e76efa17491 --- dex2oat/dex2oat.cc | 5 +++-- runtime/dex_file.cc | 2 +- runtime/zip_archive.cc | 9 +++++---- runtime/zip_archive.h | 3 ++- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index f0b575041..212662583 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -295,8 +295,9 @@ class Dex2Oat { zip_filename, error_msg->c_str()); return nullptr; } - std::unique_ptr image_classes_file(zip_entry->ExtractToMemMap(image_classes_filename, - error_msg)); + std::unique_ptr image_classes_file(zip_entry->ExtractToMemMap(zip_filename, + image_classes_filename, + error_msg)); if (image_classes_file.get() == nullptr) { *error_msg = StringPrintf("Failed to extract '%s' from '%s': %s", image_classes_filename, zip_filename, error_msg->c_str()); diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc index 43ae3081d..9cb2f1ba0 100644 --- a/runtime/dex_file.cc +++ b/runtime/dex_file.cc @@ -245,7 +245,7 @@ const DexFile* DexFile::Open(const ZipArchive& zip_archive, const std::string& l if (zip_entry.get() == NULL) { return nullptr; } - std::unique_ptr map(zip_entry->ExtractToMemMap(kClassesDex, error_msg)); + std::unique_ptr map(zip_entry->ExtractToMemMap(location.c_str(), kClassesDex, error_msg)); if (map.get() == NULL) { *error_msg = StringPrintf("Failed to extract '%s' from '%s': %s", kClassesDex, location.c_str(), error_msg->c_str()); diff --git a/runtime/zip_archive.cc b/runtime/zip_archive.cc index 841c01a76..c02f3106b 100644 --- a/runtime/zip_archive.cc +++ b/runtime/zip_archive.cc @@ -50,13 +50,14 @@ bool ZipEntry::ExtractToFile(File& file, std::string* error_msg) { return true; } -MemMap* ZipEntry::ExtractToMemMap(const char* entry_filename, std::string* error_msg) { +MemMap* ZipEntry::ExtractToMemMap(const char* zip_filename, const char* entry_filename, + std::string* error_msg) { std::string name(entry_filename); name += " extracted in memory from "; - name += entry_filename; + name += zip_filename; std::unique_ptr map(MemMap::MapAnonymous(name.c_str(), - NULL, GetUncompressedLength(), - PROT_READ | PROT_WRITE, false, error_msg)); + NULL, GetUncompressedLength(), + PROT_READ | PROT_WRITE, false, error_msg)); if (map.get() == nullptr) { DCHECK(!error_msg->empty()); return nullptr; diff --git a/runtime/zip_archive.h b/runtime/zip_archive.h index c0e2f2f86..865af515d 100644 --- a/runtime/zip_archive.h +++ b/runtime/zip_archive.h @@ -37,7 +37,8 @@ class MemMap; class ZipEntry { public: bool ExtractToFile(File& file, std::string* error_msg); - MemMap* ExtractToMemMap(const char* entry_filename, std::string* error_msg); + MemMap* ExtractToMemMap(const char* zip_filename, const char* entry_filename, + std::string* error_msg); virtual ~ZipEntry(); uint32_t GetUncompressedLength(); -- 2.11.0