summaryrefslogtreecommitdiff
path: root/cmds/idmap2/libidmap2/BinaryStreamVisitor.cpp
AgeCommit message (Collapse)Author
2021-02-09Add fabricated RRO generation to libidmap2Ryan Mitchell
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
2021-01-06Accept --overlay-name flag in idmap2Ryan Mitchell
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
2021-01-06Remove idmap path 256 length limitRyan Mitchell
Overlay and target package paths can be longer than 256 characters. Currently, the idmap will fail to be generated if either path is longer than 256 characters. This change removes the 256 character limit and makes parsing variable length strings easier in libandroidfw. Bug: 174676094 Test: idmap2_tests && libandroidfw_tests Change-Id: Ic240cdb8700566b2ac2ade08da58bea852e4ae0c
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-01Add policies and enforce overlayable to headerRyan Mitchell
If the fulfilled policies change without the contents of the target and overlay APKs changing, the idmap for the overlay should be regenerated. This change adds fulfilled policies and enforce overlayable to the idmap header so that idmap2d can determine if the polices or enforce overlayable changed from what was used to generate the idmap. Bug: 119328308 Test: idmap2_tests Test: atest RegenerateIdmapTest Change-Id: I96f970e82b5243be01b205ac2cb6ab249c6100bc
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-10-17Idmap format changes for bidirectional lookupRyan Mitchell
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
2019-04-15Run idmap2 static-checks and fix formatting issuesRyan Mitchell
Bug: 130324774 Test: builds Change-Id: I2cf9d3aa268ffe38e525fadee9d81fc6aefe19b1
2018-12-21idmap2: fix clang-tidy warnings [modernize-*]Mårten Kongstad
Bug: 120024673 Test: mmm frameworks/base/cmds/idmap2; check output Change-Id: I8768169fb7b541eb6b1aa3311c46a710eb71aac9
2018-12-20idmap2: fix clang-tidy warnings [readability-*]Mårten Kongstad
Bug: 120024673 Test: mmm frameworks/base/cmds/idmap2; check output Change-Id: I1565afac8d34e4347d8c946228d1134211e8b435
2018-10-30idmap2: initial code dropMårten Kongstad
idmap2 is a reboot of the idmap project. The project aims to - use modern C++ - greatly improve test and debug support - interface towards AssetManager2 (instead of AssetManager) - provide a solid foundation to add support for new features To make it easier to verify correctness, this first version of idmap2 is feature equivalent to idmap. Later versions will add support for new features such as <overlayable>. Bug: 78815803 Test: make idmap2_tests Change-Id: I1d806dc875a493e730ab55d2fdb027618e586d16