summaryrefslogtreecommitdiff
path: root/libs/androidfw/Idmap.cpp
AgeCommit message (Collapse)Author
2020-12-08Revert^2 "libandroidfw hardening for IncFs"Ryan Mitchell
55ef6167a2c235bd88c7216238b2001b46795b79 Change-Id: I02d4890d181655dfd0a14c188468db512559d27b Merged-In: I02d4890d181655dfd0a14c188468db512559d27b
2020-10-14Remove malloc/free for inline overlay valuesRyan Mitchell
Remove malloc/free of android::ResTable_entry for inline overlay values. Add `target_entry_inline` to the idmap format to encode inline overlay values separate from direct mapping of target resource to overlay resource. This reduces the number of bytes needed to represent a direct mapping of target resource to overlay resource from 9 bytes to 8 bytes per entry. Fixed all idmap alignment issues that required the framework to use "#pragma pack(push, 1)" when loading idmaps. Bug: 170341022 Test: idmap2_tests and libandroidfw_tests Change-Id: Iab4d3902508f02773464724913e0ee966e3689e4
2020-06-22libafw: Use std::free explicitly for overlaysRyan Mitchell
Currently we rely on libc to call std::free on the malloced pointer to the overlay table entry. Rather than relying on the libc implementation to call std::free instead of trying to delete the pointer as if it was created using "new", explicitly pass std::free as the deleter to the data held by the std::shared_ptr. Bug: 159562360 Test: Observed no heap growth while looping infinitely and retrieving a string resource overlaid using an inline xml value Change-Id: I9a2ebaf9a993ad9c44fab8f052430c8142d4347d
2020-04-07Invalidate idmap when target updatesRyan Mitchell
When the target package update, check if the idmap file must change. If so, propagate the idmap changes to the targets overlay paths, and invalidate cached overlay ApkAssets in ResourcesManager. Bug: 147794117 Bug: 150877400 Test: OverlayRemountedTest Test: libandroidfw_tests Change-Id: I6115c30bae3672b188a5ff270720a0eea15b43b5
2019-12-20Merge "Add tests for layout overlaying"TreeHugger Robot
2019-12-19idmap2: add debug information to idmap file formatMÃ¥rten Kongstad
Add a new variable length string to the idmap file format. This string will hold debug information like fulfilled policies and any warnings triggered while generating the file. Bump the idmap version to 3. Adjust the idmap header definition in ResourceType.h to take the new string into account. Example debug info: $ idmap2 create \ --target-apk-path frameworks/base/cmds/idmap2/tests/data/target/target.apk \ --overlay-apk-path frameworks/base/cmds/idmap2/tests/data/overlay/overlay.apk \ --idmap-path /tmp/a.idmap \ --policy public \ --policy oem $ idmap2 dump --idmap-path /tmp/a.idmap target apk path : frameworks/base/cmds/idmap2/tests/data/target/target.apk overlay apk path : frameworks/base/cmds/idmap2/tests/data/overlay/overlay.apk I fulfilled_policies=oem|public enforce_overlayable=true W failed to find resource "integer/not_in_target" in target resources 0x7f010000 -> 0x7f010000 integer/int1 0x7f02000c -> 0x7f020000 string/str1 [...] $ idmap2 dump --idmap-path /tmp/a.idmap --verbose 00000000: 504d4449 magic 00000004: 00000003 version 00000008: 76a20829 target crc 0000000c: c054fb26 overlay crc 00000010: ........ target path: frameworks/base/cmds/idmap2/tests/data/target/target.apk 00000110: ........ overlay path: frameworks/base/cmds/idmap2/tests/data/overlay/overlay.apk 00000210: ........ debug info: ... 00000294: 7f target package id 00000295: 7f overlay package id [...] Also, tell cpplint to accept non-const references as function parameters: they make more sense as out-parameters than pointers that are assumed to be non-null. Also, switch to regular expressions in the RawPrintVisitorTests: no more manual fixups of the stream offsets! Tell cpplint that the <regex> header is OK to use. Bug: 140790707 Test: idmap2_tests Change-Id: Ib94684a3b4001240321801e21af8e132fbcf6609
2019-12-12Add tests for layout overlayingRyan Mitchell
Add tests to ensure that findViewbyId retrieves the correct view when an id is overlaid in a RRO. Also fixes a bug that made strings hardcoded in the overlays.xml file unable to be retrieved from the string pool. Bug: 135943783 Test: atest OverlayDeviceTests Change-Id: I2bf03f151cb696d28f6bb9018eb319af29ba48f4
2019-11-13Do not look for R.class of overlaysRyan Mitchell
Now that RROs are loaded as shared libraries, LoadedApk#makeApplication is attempting to find the onResourcesLoaded method of the overlays. This is a performance hit and causes more memory than necessary to be allocated during application start up. Bug: 143314947 Test: com.android.performance.tests.HermeticMemoryTest Change-Id: I3b8cd22dae83e0164d6678c80279f9fffceb34e6
2019-10-17Allow for RRO internal referencingRyan Mitchell
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
2017-10-13AssetManager2: Implement IDMAP supportAdam Lesinski
This enables RRO (runtime resource overlays) with AssetManager2 Test: make libandroidfw_tests Test: out/host/<platform>/nativetest64/libandroidfw_tests/libandroidfw_tests --testdata=frameworks/base/libs/androidfw/tests/data Change-Id: Id8079104faefbfaa3f4017d8f7ee1a8968f151a2