From da431a22da38f9c4085b5d71ed9a9c6122c6a5a6 Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Thu, 29 Dec 2016 16:08:16 -0500 Subject: libandroidfw: Add new support for shared libraries This adds support for shared resource libraries in the new ResTable/AssetManager implementation. The dynamic package map encoded in resources.arsc is parsed and stored with LoadedArsc, and combined to form a resolved table in AssetManager2. Benchmarks show that this implementation is an order of magnitude faster on angler-userdebug (make libandroidfw_benchmarks). Test: libandroidfw_tests Change-Id: I57c80248728b63b162bf8269ac9495b53c3e7fa0 --- libs/androidfw/ApkAssets.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'libs/androidfw/ApkAssets.cpp') diff --git a/libs/androidfw/ApkAssets.cpp b/libs/androidfw/ApkAssets.cpp index 55f4c3ce6e76..9a08f638f230 100644 --- a/libs/androidfw/ApkAssets.cpp +++ b/libs/androidfw/ApkAssets.cpp @@ -28,7 +28,16 @@ namespace android { std::unique_ptr ApkAssets::Load(const std::string& path) { - ATRACE_NAME("ApkAssets::Load"); + return ApkAssets::LoadImpl(path, false /*load_as_shared_library*/); +} + +std::unique_ptr ApkAssets::LoadAsSharedLibrary(const std::string& path) { + return ApkAssets::LoadImpl(path, true /*load_as_shared_library*/); +} + +std::unique_ptr ApkAssets::LoadImpl(const std::string& path, + bool load_as_shared_library) { + ATRACE_CALL(); ::ZipArchiveHandle unmanaged_handle; int32_t result = ::OpenArchive(path.c_str(), &unmanaged_handle); if (result != 0) { @@ -61,7 +70,7 @@ std::unique_ptr ApkAssets::Load(const std::string& path) { loaded_apk->path_ = path; loaded_apk->loaded_arsc_ = LoadedArsc::Load(loaded_apk->resources_asset_->getBuffer(true /*wordAligned*/), - loaded_apk->resources_asset_->getLength()); + loaded_apk->resources_asset_->getLength(), load_as_shared_library); if (loaded_apk->loaded_arsc_ == nullptr) { return {}; } -- cgit v1.2.3-59-g8ed1b