summaryrefslogtreecommitdiff
path: root/tools/aapt2/LoadedApk.cpp
AgeCommit message (Collapse)Author
2021-03-29Prepare aapt2 for multiple ids per typeRyan Mitchell
For the SDK finalization changes, aapt2 must be able to handle resources of the same type having different type ids. The ResourceTable data structure currently stores package ids and type ids on ResourceTablePackage and ResourceTableType respectively. This prevents resource entries of the same type from having different type ids without having to create another ResourceTableType structure. JavaClassGenerator assumes each type only appears once in the ResourceTable and it would need to dedupe the types to ensure one class containing all the resource types ids is generated. TableFlattener on the other hand needs a separate ResourceTableType for each type/id combination so that the types are flattened into separate ResTable_types. This change simplifies aapt2's ResourceTable data structure: - Resource ids are stored exclusively on ResourceEntry structures meaning multiple entries can have different type ids while being stored in the same ResourceTableType. Classes like JavaClassGenerator can simply iterate over a type to see all the resources of the type regardless of what their type id is. - ResourceTable::GetPartitionedView() retrieves a list of resources sorted and partitioned by package id, type id, and entry id. Classes like TableFlattener can use this view to get separate ResourceTavleTypes for each different type id that a type has. These changes will also make it easy to have a resource span multiple type ids if it exhausts all of the entry ids in one type id. The new NewResourcesBuilder replaces the numerous setter methods on ResourceTable. Bug: 183102797 Test: aapt2_tests Change-Id: I60dbcb24143bb958333899cafa7d41faa226d203
2020-03-31Enable --collapse-resource-names on bundlesMohamed Heikal
This cl enables aapt2 optimize and convert to handle collapsed resource names optimization. Test: make aapt2_test Change-Id: I160d7e5bbd94580b52c00b648918e47beb4674f1
2018-12-20Resource Path ObfuscationMohamed Heikal
This CL allows aapt2 to obfuscate resource paths within the output apk and move resources to shorter obfuscated paths. This reduces apk size when there is a large number of resources since the path metadata exists in 4 places in the apk. This CL adds two arguments to aapt2, one to enable resource path obfuscation and one to point to a path to output the path map to (for later debugging). Test: make aapt2_tests Bug: b/75965637 Change-Id: I9cacafe1d17800d673566b2d61b0b88f3fb8d60c
2018-10-17Fix incorrect proto apk loadingRyan Mitchell
If a proto apk is missing resources.pb, AAPT2 would fail to detrmine the apk format because of an incorrect check. This fixes that check and removes the checking fuction from the LoadedApk header. Bug: 117820549 Test: removed resources.pb from proto apks and confirmed that loading in apks still works Change-Id: If3628a821e7b59c7dfcbefb502b6080be083cec1
2018-09-19Merge "AAPT2: Increase maximum proto size"Ryan Mitchell
2018-09-18AAPT2: Added badging and permissionRyan Mitchell
Added the remaining dump commands to aapt2. aapt2 dump badging [apk] aapt2 dump permissions [apk] Bug: 73351292 Test: Diffing aapt and aapt2 output across apps from the Android tree Change-Id: Idee820db410ad8d777d0d250c2657e7b83112a00
2018-09-12AAPT2: Increase maximum proto sizeRyan Mitchell
Deserializing a proto form a string throws an error when 64MB have been read from the stream. This change removes the maximum size but shows a warning when a proto is larger than 64MB. Bug: 114020398 Test: manual test with resources.pb greater than 64MB Change-Id: Iee397b6709d79a9338133a6136fe6e8f70a4964c
2018-08-16Merge "AAPT2: Compile --zip flag"Ryan Mitchell
2018-08-14AAPT2: Reformatted dump command invocationsRyan Mitchell
Use with: aapt2 dump apc [apc] aapt2 dump configurations [apk] aapt2 dump strings [apk] aapt2 dump resources [apk] aapt2 dump xmlstrings [apk] --file [file] aapt2 dump xmltree [apk] --file [file] Will add permissions and badging in a later commit. Bug: 73351292 Test: Manual tests of the commands Change-Id: I97eec01222af14053a98bd70255f1bfecd16b1c4
2018-08-14AAPT2: Compile --zip flagRyan Mitchell
Added a --zip flag similar to --dir that allows resources to be passed into "aapt2 compile" using a zip file. Also refactored Compile.cpp to be easier to mock and test in the future. Bug: 74574557 Test: aapt2_tests Change-Id: Idb90cb97e23a219525bdead38220cbf7bc6f3cab
2018-08-09AAPT2: Loosen loading apk format requirementsRyan Mitchell
The Android runtime and AAPT are more lenient of apk format, allowing for duplicate enty, types, and configs. This change loosens the ResourceTable's checks on resource uniqueness when apks are loaded; not when ResourceTables are being created by aapt2. Bug: 36051266 Test: Tested using apks in bug with allow_duplicates on and off Change-Id: I9296417bf2dc53e1e891479a53679a0388210d50
2018-03-29Check the size of the strings in the StringPool before flattening.Ryan Mitchell
Test: Tested for normal functionality when string does not exceed maximum length and tests for detection of string that is too lonhg for UTF8i Bug: b/74176037 Change-Id: Ic71d3671a069e7012e8ca107e79e071499eebbf6
2018-03-18Writes the resource table proto out when writing a LoadedApk.corysmith@google.com
Small fixes for consistancy to use constants instead of strings. Change-Id: I33439c376e1634b7957730ce16e241b0f5bb92f8 Fixes: 74594854 Test: Manual, tested against blaze test //javatests/com/google/devtools/build/android:UnitTests
2018-02-14AAPT2: Fix compatible-screens element in AndroidManifest.xmlShane Farmer
Fix an issue where the compatible-screens element was not being populated correctly. The previous version was missing the screenSize attribute which is mandatory. The attributes were also missing the resource ID from the framework library as these are a part of the public API. Change-Id: I2f594c2259831dbbd96c58db4ba55e8288d4231e Test: unit tests Test: manually split an APK and dumped with aapt
2017-12-11Aapt2 convert: skip processing resources when resource table is absent.Tom Dobek
Test: manual Change-Id: Iafe20f98857a29d625e7a57a9201db6279d43e45
2017-12-01AAPT2: Use manifest parsing to determine format of APK.Pierre Lecesne
This makes it possible to load APKs that don't have a resource table. Bug: 69355482 Test: Manual Change-Id: I8471dbe068e836b4beea9e6934d18dd16b70ef02
2017-11-13AAPT2 - Convert command to copy all the files.Pierre Lecesne
Test: Manual Change-Id: I8705966cb34ff41eb362126a35956720147fae91
2017-11-01AAPT2: Add convert commandAdam Lesinski
This command allows a developer to convert their proto APK (generated from the link phase using --proto-format) into a binary APK suitable for use on device. aapt2 convert -o output.apk input.apk Test: manual + make aapt2_tests Change-Id: I10a7c33bb4b57006d01fe00a8bf92f78e04e7e50
2017-10-19AAPT2: Define and Implement AAPT Container FormatAdam Lesinski
AAPT Container Format (.apc) is a simple container that enumerates the various intermediate files that AAPT2 generates during the compile phase. The format is defined in formats.md. For now, continue using the .flat extension for the container file, and keep making use of the .flata zip for storing multiple files. This will allow easier integration with existing build systems and allow the evolution of the APC format to better handle arbitrarily large files. Test: make aapt2_tests Change-Id: Id7216e5b76316bdd683f0fa4eaf2d2da273ba815
2017-10-04AAPT2: Move format related files under same directoryAdam Lesinski
Test: make aapt2_tests Change-Id: Id72cdfc12ba3add294048e60c55f2461344464bf
2017-10-03AAPT2: Set the minSdkVersion when generating multiple APKs.Shane Farmer
When generating multiple APKs from a configuration file, check to see if we have filtered resource by minSdkVersion and update the manifest to reflect this. We only want to inflate and modify the manifest file if there is an update to be applied. Bug: 37944703 Bug: 67005138 Test: Ran unit tests Test: Manually split an APK and verified the manifest by dumping with AAPT (both xmltree and badging). Change-Id: I64a0e4889d7d9e57373369b044a091287b06cc35
2017-08-16AAPT2: Add a APK filtering.Shane Farmer
Allow resource files to be removed from the final artifact based on the density and locale configuration in the config file. The APK is split along the density, locale and ABI axis. Each split is generated from the original APK without modifying the original. The new resource table is written back to the file system with unneeded assets etc removed. Test: Unit tests Test: Manually run optimize command against an APK and inspect results Test: Installed split searchlite APK (after resigning) and ran on N6 Change-Id: If73597dcfd88c02d2616518585d0e25a5c6a84d1
2017-08-03Fix clang-tidy performance warnings in aapt2.Chih-Hung Hsieh
* Use const reference parameter type to avoid unnecessary copy. * Use more efficient overloaded string methods. Bug: 30407689 Bug: 30411878 Test: build with WITH_TIDY=1 Change-Id: Iaa0a6f18f64cf573bee49dd1466281ea4d37b410
2017-06-21AAPT2: Split APK by ABI.Shane Farmer
Added a FilterChain that can apply multiple filter steps to an APK file as it is being written to disk. The first filter applied is by ABI. If a library in the APK does not match the filter it is skipped. Added an AbiFilter that keeps files that are either not native libs or are for the set of wanted ABIs Test: ran unit tests locally Test: ran against an APK with ARM and x68 libs and diffed the results Change-Id: I3fb901d3de3513e85f2a2763a8e4487a28ed4881
2017-04-10AAPT2: Share split functionality between link and optimizeAdam Lesinski
Generating splits should be possible to do from the optimize command. This means that a lot of infrastructure around split APKs can be shared by both the optimize and link phase. Bug: 35925830 Change-Id: Ia88b9e4bff300a56353b2f7a4a2547c8eb43a299 Test: manual
2017-03-20AAPT2: Fix up file IOAdam Lesinski
This also enables an AAPT behavior that CTS tests have come to depend on. Small files that compress negatively (get larger) are stored uncompressed. Some CTS tests assume this and try to open these files by mmapping them, which is only possible if they are uncompressed. Bug: 35461578 Test: make aapt2_tests Change-Id: Id622a6150fe72477ad65d67d1bad897a8ee2ffb9
2017-02-22AAPT2: Rename strip phase to optimizeAdam Lesinski
- Allow resource deduping, version collapsing, and sparse resource encoding. Test: manual Change-Id: Ia4aa892ab5b06ba1d5ea4a6efb51b00bc3a980c4
2017-02-15Add ResTable_sparseTypeEntry supportAdam Lesinski
Benchmarks on bullhead-userdebug show that there is a negligent performance impact when using sparse entries on a 30% loaded sparse type of 1000 resources. Benchmark Time CPU Iterations ----------------------------------------------------------------------------------- BM_SparseEntryGetResourceSparseLarge 255 ns 254 ns 2751408 BM_SparseEntryGetResourceNotSparseLarge 254 ns 254 ns 2756534 Bug: 27381711 Test: make libandroidfw_tests aapt2_tests Change-Id: I051ea22f2f6b2bc3696e446adc9e2a34be18009f
2017-02-03Only compress files that were already compressed in the original APK.Pierre Lecesne
Also fix a log message. Test: Manually. Unit tests pass. Change-Id: Iea236bbcfbe1a0a0894ce1bfce09c19208c5a0bc
2017-02-02Add a method LoadedApk::WriteToArchive.Pierre Lecesne
Test: Manually. Change-Id: I61717204e58ca2bbfba9a52c7aecf27882a853f8
2017-02-01Moving the LoadedApk class to its own file.Pierre Lecesne
Test: Unit tests pass. Change-Id: Id706f9ad1f3406bb73a60a33139a04745d5d72c0