summaryrefslogtreecommitdiff
path: root/tools/aapt2/cmd
AgeCommit message (Collapse)Author
2025-03-19Fix typo in aapt2 CLI --help Adam Soutar
Hi, just noticed this difference while reading through docs and then invoking `aapt2 --help` The updated spelling matches the public documentation for this CLI switch: https://developer.android.com/tools/aapt2 Change-Id: I37788ab78d7ec6df409b3aa2e1e365626a47ab72 Flag: EXEMPT log only update
2025-03-17Merge "Fix persisting which resources use feature flags" into main Jeremy Meyer
2025-03-14Fix persisting which resources use feature flags Jeremy Meyer
File resources get into the table a different way when they haven't been modified by the FlaggedXmlVersioner or XmlCompatVersioner and this addresses that path. With this change, during compile we now find if an xml resource uses flags and store that in the XmlResource which is then persisted to and retrieved from the proto. This means the FlaggedXmlVersioner doesn't have to look for them in the case that the file config or minsdk is >= baklava. This also moved the FeatureFlagsFilter to before we version the files. The FeatureFlagsFilter is what strips elements behind disabled read only flags at compile time and removed the featureFlag attribute when the element is behind an enabled read only flag. This is so that the FlaggedXmlVersioner doesn't have to worry if the flags it sees are read/write or readonly. It should only ever encounter read/write flags. Test: Automation Bug: 377974898 Flag: android.content.res.layout_readwrite_flags Change-Id: Ia6cbf55bc9f8d594eeb5c44c143565e93684ae2c
2025-03-12aapt2: Ensure sparse encoding isn't used on unsupported platforms Mark Punzalan
Current behavior: - When --enable-sparse-encoding is used, sparse encode when minSdkVersion is missing or is >= 32 (S_v2) - When --force-sparse-encoding is used, always sparse encode regardless of minSdkVersion New behavior: - When --enable-sparse-encoding is used, sparse encode when minSdkVersion is >= 32 (S_v2) - When --force-sparse-encoding is used, sparse encode when minSdkVersion is missing or is >= 32 (S_v2) Bug: 398187461 Test: build + boot on Pixel 6 Pro Flag: EXEMPT build tool Change-Id: Ide4e37f565107a33ecafc269ed81633e616b1a19
2025-03-06Persist whether xml resources have flags Jeremy Meyer
This stores whether an xml document has feature flags in it in a ResTable_entry so that at runtime we can know not to do extra work looking for flags. Test: Automation Bug: 377974898 Flag: android.content.res.layout_readwrite_flags Change-Id: Id43b2d9941d1fab8c654d081bf19df5a33a464f3
2025-02-25Only have featureFlag attr in xml when v>baklava Jeremy Meyer
This makes it so that if there are xml files that use the featureFlag attribute they are split into a pre-B file where all flags are assumed false and a B version that is the file as is. Test: Automation Bug: 377974898 Flag: android.content.res.layout_readwrite_flags Change-Id: Iab1a69a6d0b3e7efd7033887c351430fb2aabd19
2025-02-19Add flag to not compress fonts in the APK Shai Barack
Font assets can be mmap'ed if they're not compressed. This is much more efficient than decompressing them first. Bug: 395153140 Bug: 393177415 Flag: EXEMPT Aconfig not supported on host tools Change-Id: I7163746e05a637962d48c0c5a1eb47517435ebf7
2025-02-12Merge "[aapt2] Fix aapt2 diff for added/removed resources" into main Treehugger Robot
2025-02-11[aapt2] Fix aapt2 diff for added/removed resources Yurii Zubrytskyi
The old implementation used to iterate over both apks in parallel, making the whole output wrong as soon as they get out of sync because of an added or removed resource. New code performs a lookup for each resource, making it much less efficient (quadratic complexity), but actually produces useful output. Performance is enough to run a framework-res.apk diff in milliseconds - no need to make a lookup table. + print the output into STDOUT instead of STDERR, as it's supposed to be + add a --ignore-id-shift command line flag to skip printing differences in IDs if those are the only differences. Any added or removed resource will make all subsequent IDs change, making the output almost unusable Bug: 396020063 Flag: EXEMPT bugfix Test: manual on framework-res.apk Change-Id: I8d13038b5e4ddccd465393529e17809245c3b9ad
2025-02-07Merge "Revert "Always enable sparse encoding if minSdk >= 32"" into main Mark Punzalan
2025-02-07Revert "Always enable sparse encoding if minSdk >= 32" Mark Punzalan
This reverts commit c9c3150896e1b637df6c8ecc485cb0e3384448c7. Reason for revert: Sparse encoding got enabled for minSdk < 32 (b/395135057). Keeping the minor version bump to 2.20. Change-Id: I8e143038a2e2a59be84669787764a9bf69210cd0
2025-02-06Allow read/write flags on xml elements Jeremy Meyer
This changes aapt2 so that it now allows xml elements with the android:featureFlag attribute even when that attribute is read/write (or not found altogether). This also makes it so that attribute is removed when the flag is read only. Bug: 377974898 Test: Automated Flag: EXEMPT Aconfig not supported on host tools Change-Id: I330eefe897ab6dd1301b073d7f69443e3428b5b6
2025-01-09Always enable sparse encoding if minSdk >= 32 Mark Punzalan
Sparse encoding has been enabled in the framework since T QPR2 with no major issues. It should be safe to enable by default for any app with minSdk >= 32 (S_V2) which is when the last fix for sparse encoding was made. This CL makes the `--enable-sparse-encoding` flag a no-op. As such, we are also bumping the version to 2.20. Bug: 302179337 Change-Id: Ia886a0da9d61175d00c24e30f4e263f7e5df511a Test: build + boot on Pixel 6 Pro Flag: EXEMPT command line tool
2024-12-20[aapt2] Add a way to set command line from environment Yurii Zubrytskyi
Sometimes one needs to test or alter aapt2 behavior inside the system build. This CL allows for a simple way of adding command line flags when you're not the one running it directly: _AAPT2_FLAG_NAME adds the '--flag-name' command line parameter before all actual parameters passed through the command line, while AAPT2_FLAG_NAME_ adds it after all of those. This way it's easy to either add a default value, or a hard override to whatever you need. + Allow '-h' shorthands for the long '--help' switches when it's unambiguous Test: build + boot Flag: EXEMPT command line tool Change-Id: I3effd25ec207d671ba87200b530601525382240d
2024-10-30Merge changes Ibe5f47b8,I845f6730 into main Yurii Zubrytskyi
* changes: [aapt2] Add a compression control option to 'compile' [aapt2] Allow --flag=value command line options
2024-10-29[aapt2] Add a compression control option to 'compile' Yurii Zubrytskyi
aapt2 recompresses all PNGs it compiles, and by default it uses the best (and slowest) zlib compression level, 9. This change adds a command line option --png-compression-level to control that, so it's possible to set it to something faster e.g. 6 which is usually 5x faster and around 101% of the size of level 9 PNGs Test: manual, compile Framework Flag: EXEMPT tool Change-Id: Ibe5f47b82e1c13be0a4ffff0e07e675871abc956
2024-10-29[aapt2] Allow --flag=value command line options Yurii Zubrytskyi
+ fix a wrong return value for a missing argument Flag: EXEMPT tiny tool feature Test: unit tests Change-Id: I845f673081ec3b3c395bbe0355ced07fa45a5586
2024-10-25Have aapt2 handle quoted filepaths Jeremy Meyer
Fixes: 374827548 Test: Automated Flag: EXEMPT Aconfig not supported on host tools Change-Id: I053b40a8e1a5586695cfb8a64587e6b4ef1df2eb
2024-09-25Add support for flagging xml and png files Jeremy Meyer
This extends the previous change that added the ability to flag resource directories so that xml and png files are now supported. Test: Automated Bug: 329436914 Flag: EXEMPT Aconfig not supported on host tools Change-Id: I9f2b6b15ba0078ea33188f1a554377784cff9786
2024-09-25Add support for flag in resource directory names Jeremy Meyer
This only applies it to the xml files with the top level element of resources. Other file support will be in a later CL. Test: Automated Bug: 329436914 Flag: EXEMPT Aconfig not supported on host tools Change-Id: I5e1e341e9de61073d05d9098b1b8b836025910b3
2024-09-25Error on duplicate resource with same disabled flag Jeremy Meyer
Also realized I hadn't handled flag negation so added that as well. Test: Automated Bug: 329436914 Flag: EXEMPT Aconfig not supported on host tools Change-Id: If90ae71070306f8e0c367be7e652da9c7bd0bb22
2024-08-21resource flagging on xml elements Jeremy Meyer
This removes xml elements that are behind disabled flags Test: Automated Bug: 329436914 Flag: EXEMPT Aconfig not supported on host tools Change-Id: Ie8ede5796f9fd0cbaa7f6aa337ddbba1a5588dca
2024-08-15Merge "Flag support for bag resource types" into main Treehugger Robot
2024-08-15Flag support for bag resource types Jeremy Meyer
Test: Automated Bug: 329436914 Flag: EXEMPT Aconfig not supported on host tools Change-Id: I891c93c3ffcab172d28701b44a80c50f1e24d99e
2024-08-09Merge changes I7b0844fb,I8ecd60e8 into main Treehugger Robot
* changes: [aapt] Add --verbose support to 'aapt2 convert [res] Zero big buffer memory on backing up
2024-08-09[aapt] Add --verbose support to 'aapt2 convert Yurii Zubrytskyi
Bug: 336758568 Bug: 342579978 Test: build Flag: EXEMPT bugfix Change-Id: I7b0844fb29e8630d9b4d63ac174ce4b4ca4ba47b
2024-08-07Keep disabled resources out of final apk Jeremy Meyer
Test: Automated Bug: 329436914 Flag: EXEMPT Aconfig not supported on host tools Change-Id: Id5fdb025f004788ea40bdbd0b0df0dbda181f2c7
2024-08-01Remove flag disabled strings from string pool Jeremy Meyer
Test: Automated Bug: 329436914 Flag: EXEMPT Aconfig not supported on host tools Change-Id: I627feff5774f44a398a8337733498ede601d07a4
2024-07-17Merge "Update how flag read only status is passed to aapt2" into main am: ↵ Jeremy Meyer
5494b51ea4 am: 99f73943e6 Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/3177524 Change-Id: I1eebe5e130bc638a7d5890f45d8c8f143465f5aa Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-07-17Update how flag read only status is passed to aapt2 Jeremy Meyer
Now in addition to name:ro we also support name:READ_ONLY and name:READ_WRITE Test: Automatic Bug: atest 344979955 Flag: EXEMPT Aconfig not supported on host tools Change-Id: I0b581ac250f36b209d5151d0caa0a5c3c2d311cc
2024-07-16Add ability to pass flag read only status to aapt2 Jeremy Meyer
Also adds the ability to pass flags to the compile command Test: automated Bug: 344979955 Flag: EXEMPT tools change (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:b5c0ef0843f1426b9237b050994e8753b0921617) Merged-In: I29997712d262be6d89eef16daf67d37cbafe3cba Change-Id: I29997712d262be6d89eef16daf67d37cbafe3cba
2024-07-12First pass at flagged resources Jeremy Meyer
This gets the main parts of resource flagging in place and the basic use case of flagging with an xml attribute working. Test: Automated Bug: 329436914 Flag: EXEMPT Aconfig not supported on host tools Change-Id: Id2b5ba450d05da00a922e98ca204b6e5aa6c6c24
2024-07-10[aapt2] Add --enable-compact-entries to optimize Yurii Zubrytskyi
The optimize command should have the same switches as convert and link, so adding the missing one here Test: build Flag: EXEMPT minor change Change-Id: I9e5f3d7fb65db97a14fc952c30407d594057c5bc
2024-07-03[aapt2] Improve dump chunks for string pools, fix diff Yurii Zubrytskyi
- `dump chunks` command now prints extra header data for the string pool, and outputs all style information for styled strings. - `diff` command used to only correctly compare the first span in the StyledString data type, making them appear different if there was a string with more than one span Flag: EXEMPT bugfix Test: atest aapt2_tests Change-Id: I377718c03d6a464cb4db22399b0f067e6a6e04d6
2024-06-25Add ability to pass flag read only status to aapt2 Jeremy Meyer
Also adds the ability to pass flags to the compile command Test: automated Bug: 344979955 Flag: EXEMPT tools change Change-Id: I29997712d262be6d89eef16daf67d37cbafe3cba
2024-04-29[aapt2] Add --non-updatable-system flag Mark Punzalan
This adds `updatableSystem="false"` to the root <manifest> tag if no versionCode is specified (either explicitly or through --version-code). This attribute makes the APK not updatable (see b/266131956). Bug: 328302305 Test: atest aapt2_tests Test: Manually ran `aapt2 link --non-updatable-system` and verified the resulting APK. Change-Id: I51cdbcdac7c03de10aac9bc22f5081e12fa142ab
2024-01-30Merge Android 24Q1 Release (ab/11220357) Xin Li
Bug: 319669529 Merged-In: I46c7859ff042ee7aa9193757e5df8269f4892362 Change-Id: I0c7b5036c0b0f5f2caad551edb063350f6eb87e7
2024-01-24[aapt2] Always generate code for permissions Mark Punzalan
We will generate the String constant in Manifest.java for a permission or permission group even if it is removed via feature flag. This is so that code referencing the string will still compile. Bug: 297373084 Bug: 318014882 Test: atest aapt2_tests Test: Modified framework-res to build with SDK version 34 and forced removal of a permission with a disabled feature flag. The entire Android source could still be built even if the framework-res.apk no longer had the removed permission in the manifest. Change-Id: I982a8988e35e09e73bcbe065f0d7cf47c2907d54
2024-01-05[aapt2] Use FeatureFlagsFilter in link command Mark Punzalan
The behavior of the filter depends on the minSdkVersion. If > UDC, manifest elements will be untouched. Otherwise, they will be removed depending on the value of the flag in the `android:featureFlag` attribute. Bug: 297373084 Test: atest aapt2_tests Change-Id: Ib07c45752a4cc00bfdae7fedc745ce267ec7082a
2023-12-06Merge "Fix -Wunused-variable compiler warning" into main am: 76a85e9218 am: ↵ Yi Kong
a862458648 am: 4314f1e460 Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2858973 Change-Id: Ide1c481ea8dbca73761d2da1558ab1b305b2da5f Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-06Merge "Fix -Wunused-variable compiler warning" into main am: 76a85e9218 Yi Kong
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2858973 Change-Id: Ie5bd3e2d561a863c50b6e4310f02b0a2785cbd45 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-06Merge "Fix -Wunused-variable compiler warning" into main am: 76a85e9218 Yi Kong
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2858973 Change-Id: I410629f0feab6cb37bd27b1aca300b3b0b22f2d0 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-05Fix -Wunused-variable compiler warning Yi Kong
frameworks/base/tools/aapt2/link/ManifestFixer.cpp:341:23: error: unused variable 'attr' [-Werror,-Wunused-variable] 341 | if (xml::Attribute* attr = el->FindAttribute(xml::kSchemaAndroid, "glEsVersion")) { | ^~~~ Test: presubmit Change-Id: Icec4737a5f8076173a2aff54532a79fa123df326
2023-11-30Revert^2 "Move some image/9patch code to androidfw" Jeremy Meyer
This reverts commit 917043bc2586743afda5a21386893fa8c787800b. Reason for revert: Roll forward with fix Test: Automatic Bug: 296324826 Change-Id: I42a0b48c02fd497b2174c0c65f300265202f7ab1
2023-11-14Merge "[aapt2] Parse --feature-flags parameter values" into main am: ↵ Mark Punzalan
21bbfb8754 am: 3ded596720 am: 7b65ed0487 Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2813074 Change-Id: I7e95d4f810d305affdf090755e515551a3fc5bcb Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-13Merge "[aapt2] Parse --feature-flags parameter values" into main am: 21bbfb8754 Mark Punzalan
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2813074 Change-Id: Iaf2ce67ed91d09e587a8e367349d3510e25e72cf Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-13Merge "[aapt2] Parse --feature-flags parameter values" into main am: 21bbfb8754 Mark Punzalan
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2813074 Change-Id: If9be16e1daadbdcc660ab39e469f0bfa3ca52e00 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-13Merge "[aapt2] Parse --feature-flags parameter values" into main Mark Punzalan
2023-11-09[aapt2] Parse --feature-flags parameter values Mark Punzalan
Bug: 297373084 Test: atest aapt2_tests Change-Id: I7567aa8f41e6fde7334430446a940eb6b04c1446
2023-11-01Merge "Implement filter-product" into main am: 0092cae047 Treehugger Robot
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2813934 Change-Id: I08e3e25ac26b83a9a635a29fa624e8351a49cfe9 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>