summaryrefslogtreecommitdiff
path: root/libs/androidfw/ApkAssets.cpp
diff options
context:
space:
mode:
authorRyan Mitchell <rtmitchell@google.com>2019-07-01 09:48:23 -0700
committerRyan Mitchell <rtmitchell@google.com>2019-10-17 13:09:33 -0700
commit8a891d86abdf35b6703785fb3368b39510e91357 (patch)
treea58684aba049e9345ad0c1cf23f2bc4593a9892c /libs/androidfw/ApkAssets.cpp
parente753ffef5499bc0150827a06d44b50abe78b36dd (diff)
Allow for RRO internal referencing
This change allows RROs to reference their own internal resources as expected. Overlays are loaded as shared libraries so they can have their own resource id space that does not conflict with the resource id space of the target or other overlays. References to overlay resources that override target resources now appear as references to the target resources. Overlay values that are inlined into the xml file specified using android:overlayResources are now able to be used at runtime. See go/rro-references for more information. Bug: 135943783 Test: idmap2_tests Test: libandroidfw_tests Change-Id: Ie349c56d7fd3f7d94b7d595ed6d01dc6b59b6178
Diffstat (limited to 'libs/androidfw/ApkAssets.cpp')
-rw-r--r--libs/androidfw/ApkAssets.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/libs/androidfw/ApkAssets.cpp b/libs/androidfw/ApkAssets.cpp
index b309621435b5..16dbbf61351a 100644
--- a/libs/androidfw/ApkAssets.cpp
+++ b/libs/androidfw/ApkAssets.cpp
@@ -45,7 +45,7 @@ ApkAssets::ApkAssets(ZipArchiveHandle unmanaged_handle,
time_t last_mod_time,
bool for_loader)
: zip_handle_(unmanaged_handle, ::CloseArchive), path_(path), last_mod_time_(last_mod_time),
- for_loader(for_loader) {
+ for_loader_(for_loader) {
}
std::unique_ptr<const ApkAssets> ApkAssets::Load(const std::string& path, bool system,
@@ -75,7 +75,7 @@ std::unique_ptr<const ApkAssets> ApkAssets::LoadOverlay(const std::string& idmap
return {};
}
return LoadImpl({} /*fd*/, loaded_idmap->OverlayApkPath(), std::move(idmap_asset),
- std::move(loaded_idmap), system, false /*load_as_shared_library*/);
+ std::move(loaded_idmap), system, true /*load_as_shared_library*/);
}
std::unique_ptr<const ApkAssets> ApkAssets::LoadFromFd(unique_fd fd,
@@ -165,12 +165,14 @@ std::unique_ptr<const ApkAssets> ApkAssets::LoadImpl(
// Must retain ownership of the IDMAP Asset so that all pointers to its mmapped data remain valid.
loaded_apk->idmap_asset_ = std::move(idmap_asset);
+ loaded_apk->loaded_idmap_ = std::move(loaded_idmap);
const StringPiece data(
reinterpret_cast<const char*>(loaded_apk->resources_asset_->getBuffer(true /*wordAligned*/)),
loaded_apk->resources_asset_->getLength());
loaded_apk->loaded_arsc_ =
- LoadedArsc::Load(data, loaded_idmap.get(), system, load_as_shared_library, for_loader);
+ LoadedArsc::Load(data, loaded_apk->loaded_idmap_.get(), system, load_as_shared_library,
+ for_loader);
if (loaded_apk->loaded_arsc_ == nullptr) {
LOG(ERROR) << "Failed to load '" << kResourcesArsc << "' in APK '" << path << "'.";
return {};
@@ -319,7 +321,7 @@ bool ApkAssets::ForEachFile(const std::string& root_path,
bool ApkAssets::IsUpToDate() const {
// Loaders are invalidated by the app, not the system, so assume up to date
- if (for_loader) {
+ if (for_loader_) {
return true;
}