summaryrefslogtreecommitdiff
path: root/cmds/idmap2/tests/ResourceMappingTests.cpp
Commit message (Collapse)AuthorAgeFilesLines
* idmap2: Remove more redundant "using" statementsYi Kong2022-02-201-2/+0
| | | | | | Test: presubmit Bug: 219872355 Change-Id: I74e5b38400060477f9d50b51b1f261ec6a181dd1
* Add fabricated RRO generation to libidmap2Ryan Mitchell2021-02-091-34/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fabricated Runtime Resource Overlays are overlays that are generated at runtime and are stored in the data/ partition. The system can fabricate RROs at runtime to dynamically theme the device. Idmaps can now be created from APK RROs and fabricated RROs. Rather than operating on ApkAssets, libidmap2 now operates on abstract resource "containers" that supply resource values. Target resource containers implement methods needed to query overlayable and target overlay information. Currently only APKs can be loaded as target resource containers. Overlay resource containers implement methods to supply the mapping of target resource to overlay value and other overlay information. The format of a fabricated RRO is as follows: 0x00 - 0x04 : fabricated overlay magic (always FRRO) 0x04 - 0x08 : file format version 0x08 - 0x0c : crc of version + proto data 0x0c - EOF : proto fabricated overlay data The magic is used to quickly detect if the file is a fabricated overlay. The version is incremented whenever backwards incompatible changes are made to the proto file format. Idmap must always be able to upgrade fabricated overlays from previous versions to new versions, so all previous versions must be checked into the tree. Bug: 172471315 Test: libidmap2_tests && libandroidfw_tests Change-Id: I4c9f29da278672e5695fb57d131a44c11a835180
* Accept --overlay-name flag in idmap2Ryan Mitchell2021-01-061-123/+77
| | | | | | | | | | | | | | | | | | To support allowing for multiple <overlay> tags in one package, idmap2 must be able to generate an idmap for an individual <overlay> tag. `idmap2 create` now accepts a --overlay-name flag that specifies which tag to use to generate the idmap. The value of --overlay-name should be set to the value of the android:name attribute on the <overlay> tag to use. If the flag is not present, idmap2 will look for an <overlay> tag with no value for android:name. Bug: 162841629 Test: libandroidfw_tests Test: libidmap2_tests Change-Id: I02316d0b88773f02c04a5d462be9825016fa496d
* Remove malloc/free for inline overlay valuesRyan Mitchell2020-10-141-77/+103
| | | | | | | | | | | | | | | | | | 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
* OMS: Add config_signature policy handlingZoran Jovanovic2020-10-141-4/+14
| | | | | | | | | | | | | | Alongside SIGNATURE and ACTOR_SIGNATURE policies, add CONFIG_SIGNATURE policy to overlayable that overlay fulfills if it is signed with the same certificate as the reference package whose package name is declared in 'config-signature' tag of SystemConfig and is vetted by OMS that it's a system pre-installed package. BUG: 158726924 TEST: regular aapt2, idmap2, OMS tests Merged-In: I645ee72271496008742886274be0d63a2985201b Change-Id: I645ee72271496008742886274be0d63a2985201b
* Revert "Persist implicit overlay configurator actor policy"Ryan Mitchell2020-06-041-15/+55
| | | | | | | | | | | | | | | This reverts commit af93f5de66f09797345d2171306c9de2951bf85c. The overlays.xml file version should not be reverted to 3. Increasing the version caused b/158054824 so for devices that have not upgraded to version 4, do not ignore a version 3 overlay file when restoring settings. In a future change, we must create testing so that version upgrades always migrate old overlays.xml files to new overlays.xml files. Bug: 157266239 Bug: 158054824 Change-Id: I3f8c49d30a1961a756bbed9b2ab01aeb1f887e55
* Persist implicit overlay configurator actor policyRyan Mitchell2020-05-281-55/+15
| | | | | | | | | | | | | | | | | | | | | | | | | This change does three things: 1) If an overlay targets a package that does not declare an overlayable and the overlay fulfills the actor policy, the overlay can override any resource in the target, 2) The actor policy is now implicitly granted to overlays signed with the same signature as the configurator that target white-listed target packages regardless of whether or not the target defines an overlayable. 3) If an overlay was previously granted the actor policy through the mechanism specified in (2), the overlay will continue to fulfill the actor policy even if the configurator is removed, changes signature, changes to a different package, or the list of configurator targets changes. If the overlay target package or target overlayable name changes, the persisted setting will be reset. Bug: 157244814 Bug: 157266239 Test: atest OverlayManagerServiceImplTests Test: idmap2_tests Change-Id: Iff3937849ad898b1b2d74c2c632a4cdf7690fe10
* Actor signature overlayable policyWinson2020-02-261-2/+8
| | | | | | | | | | | | | | | | | | There are cases where an app can ship overlays for itself, but the "signature" policy as described would open up a vulnerability by allowing the system actor to create and sign any arbitrary overlay that will apply to the target. To prevent this, redefine "signature" as target package only, and introduce "actor" for checking against the actor signature. Any app that wishes to use both can include both policies. Bug: 130563563 Test: m aapt2_tests idmapt2_tests and run from host test output Test: atest libandroidfw_tests Change-Id: I1c583a5b37f4abbeb18fc6a35c502377d8977a41
* Refactor overlayable policyWinson2020-02-261-102/+123
| | | | | | | | | | | | | | | | | | | | To make it easier to add the actor policy in a follow up CL, move most of the policy handling to a central location. The strings and transformation between strings and flags is now handled in libidmap2policies, with libandroidfw containing the single source of policy flags. This also extracts all the test resource IDs into an R.h so they can be swapped without having to edit a dozen files each time. Bug: 130563563 Test: m aapt2_tests idmapt2_tests and run from host test output Test: atest libandroidfw_tests Change-Id: Ie533c9cebf938215df7586f00c38763ae467e606
* idmap2: add debug information to idmap file formatMÃ¥rten Kongstad2019-12-191-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Idmap format changes for bidirectional lookupRyan Mitchell2019-10-171-72/+73
| | | | | | | | | | | | | | | | | | This change modifies the idmap file format to allow for target resources to map to arbitrary type/value combinations and to allow overlay resources to be mapped back to target resource ids so references to overlay resources can appear as references to target resources at runtime. The mappings of target resources to overlay resources and vice-versa are both encoded as sparse arrays. Instead of looking up a resource by indexing into an array that maps to the overlay resource id, the runtime will binary search over the sparse array to find the type and value that overlays the target resource. Bug: 135943783 Test: idmap2_tests Change-Id: I5d5344cdb7fe35f4f2e8d6781016299dea5d1e20
* Parse <overlay> and abstract resource mappingRyan Mitchell2019-10-041-0/+322
This change introduces idmap parsing of <overlay> tags. The <overlay> tag allows one to explicitly map resources in the target to either a resource in the overlay or an inline attribute value. Use the android:resourcesMap atttribute on the <overlay> tag in the android manifest to specify a file to provide the resource mapping. Bug: 135943783 Bug: 135051420 Test: idmap2_tests Change-Id: I1740dcdc01849c43b1f2cb8c6645d666dbb05dba