DexFileLoader: Preserve some old overloads for app-compat.
Some apps were using the internal methods directly.
Temporarily add the methods back.
Test: Try to open some of the apps.
Change-Id: I52b90115d6cfe3b4f90836983f3de891c98d54c7
diff --git a/libdexfile/dex/dex_file_loader.cc b/libdexfile/dex/dex_file_loader.cc
index 4395474..d375aac 100644
--- a/libdexfile/dex/dex_file_loader.cc
+++ b/libdexfile/dex/dex_file_loader.cc
@@ -481,4 +481,65 @@
return true;
}
+std::unique_ptr<const DexFile> DexFileLoader::Open(
+ const uint8_t* base,
+ size_t size,
+ const std::string& location,
+ uint32_t location_checksum,
+ const OatDexFile* oat_dex_file,
+ bool verify,
+ bool verify_checksum,
+ std::string* error_msg,
+ std::unique_ptr<DexFileContainer> container) const {
+ return OpenCommon(base,
+ size,
+ /*data_base=*/nullptr,
+ /*data_size=*/0,
+ location,
+ location_checksum,
+ oat_dex_file,
+ verify,
+ verify_checksum,
+ error_msg,
+ std::move(container),
+ /*verify_result=*/nullptr);
+}
+
+std::unique_ptr<DexFile> DexFileLoader::OpenCommon(const uint8_t* base,
+ size_t size,
+ const uint8_t* data_base,
+ size_t data_size,
+ const std::string& location,
+ uint32_t location_checksum,
+ const OatDexFile* oat_dex_file,
+ bool verify,
+ bool verify_checksum,
+ std::string* error_msg,
+ std::unique_ptr<DexFileContainer> old_container,
+ VerifyResult* verify_result) {
+ CHECK(data_base == base || data_base == nullptr);
+ CHECK(data_size == size || data_size == 0);
+ CHECK(verify_result == nullptr);
+
+ // The provided container probably does implent the new API.
+ // We don't use it, but let's at least call its destructor.
+ struct NewContainer : public MemoryDexFileContainer {
+ using MemoryDexFileContainer::MemoryDexFileContainer; // ctor.
+ std::unique_ptr<DexFileContainer> old_container_ = nullptr;
+ };
+ auto new_container = std::make_shared<NewContainer>(base, size);
+ new_container->old_container_ = std::move(old_container);
+
+ return OpenCommon(std::move(new_container),
+ base,
+ size,
+ location,
+ location_checksum,
+ oat_dex_file,
+ verify,
+ verify_checksum,
+ error_msg,
+ /*error_code=*/nullptr);
+}
+
} // namespace art
diff --git a/libdexfile/dex/dex_file_loader.h b/libdexfile/dex/dex_file_loader.h
index 75ef9f7..532445a 100644
--- a/libdexfile/dex/dex_file_loader.h
+++ b/libdexfile/dex/dex_file_loader.h
@@ -212,6 +212,32 @@
std::string* error_msg,
DexFileLoaderErrorCode* error_code);
+ // Old signature preserved for app-compat.
+ std::unique_ptr<const DexFile> Open(const uint8_t* base,
+ size_t size,
+ const std::string& location,
+ uint32_t location_checksum,
+ const OatDexFile* oat_dex_file,
+ bool verify,
+ bool verify_checksum,
+ std::string* error_msg,
+ std::unique_ptr<DexFileContainer> container) const;
+
+ // Old signature preserved for app-compat.
+ enum VerifyResult {};
+ static std::unique_ptr<DexFile> OpenCommon(const uint8_t* base,
+ size_t size,
+ const uint8_t* data_base,
+ size_t data_size,
+ const std::string& location,
+ uint32_t location_checksum,
+ const OatDexFile* oat_dex_file,
+ bool verify,
+ bool verify_checksum,
+ std::string* error_msg,
+ std::unique_ptr<DexFileContainer> container,
+ VerifyResult* verify_result);
+
// Open .dex files from the entry_name in a zip archive.
bool OpenFromZipEntry(const ZipArchive& zip_archive,
const char* entry_name,