diff options
author | Adam Lesinski <adamlesinski@google.com> | 2016-12-29 16:08:16 -0500 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2017-01-11 17:20:36 -0800 |
commit | da431a22da38f9c4085b5d71ed9a9c6122c6a5a6 (patch) | |
tree | 7fc684c1ec3c653ff98bdc8eff50addc081a02e1 /libs/androidfw/ApkAssets.cpp | |
parent | 7ad1110ecd6a840fcd2895c62668828a1ca029c6 (diff) |
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
Diffstat (limited to 'libs/androidfw/ApkAssets.cpp')
-rw-r--r-- | libs/androidfw/ApkAssets.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
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> ApkAssets::Load(const std::string& path) { - ATRACE_NAME("ApkAssets::Load"); + return ApkAssets::LoadImpl(path, false /*load_as_shared_library*/); +} + +std::unique_ptr<ApkAssets> ApkAssets::LoadAsSharedLibrary(const std::string& path) { + return ApkAssets::LoadImpl(path, true /*load_as_shared_library*/); +} + +std::unique_ptr<ApkAssets> 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> 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 {}; } |