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
diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp
index c7b36d0..3c0971b 100644
--- a/core/jni/android_util_AssetManager.cpp
+++ b/core/jni/android_util_AssetManager.cpp
@@ -750,9 +750,11 @@
}
// May be nullptr.
- const DynamicRefTable* dynamic_ref_table = assetmanager->GetDynamicRefTableForCookie(cookie);
+ std::shared_ptr<const DynamicRefTable> dynamic_ref_table =
+ assetmanager->GetDynamicRefTableForCookie(cookie);
- std::unique_ptr<ResXMLTree> xml_tree = util::make_unique<ResXMLTree>(dynamic_ref_table);
+ std::unique_ptr<ResXMLTree> xml_tree = util::make_unique<ResXMLTree>(
+ std::move(dynamic_ref_table));
status_t err = xml_tree->setTo(asset->getBuffer(true), asset->getLength(), true);
asset.reset();
@@ -785,9 +787,11 @@
ApkAssetsCookie cookie = JavaCookieToApkAssetsCookie(jcookie);
// May be nullptr.
- const DynamicRefTable* dynamic_ref_table = assetmanager->GetDynamicRefTableForCookie(cookie);
+ std::shared_ptr<const DynamicRefTable> dynamic_ref_table =
+ assetmanager->GetDynamicRefTableForCookie(cookie);
- std::unique_ptr<ResXMLTree> xml_tree = util::make_unique<ResXMLTree>(dynamic_ref_table);
+ std::unique_ptr<ResXMLTree> xml_tree = util::make_unique<ResXMLTree>(
+ std::move(dynamic_ref_table));
status_t err = xml_tree->setTo(asset->getBuffer(true), asset->getLength(), true);
asset.reset();