Currently more config values are being kept than necessesary. For
example, given config values for a string resource:
Config: default Value: "keep"
Config: ldrtl Value: "dedupe"
Config: ldrtl-night Value: "dedupe"
Config: land Value: "keep2"
The ldrtl-night config value will fail to be removed despite being
equivalent to the ldrtl value. This is because the value for the land
configuration is not equivalent to the ldrtl-night value. Instead of
checking that every compatible config value not related by dominance
should have quivalent values, only check sibling config values within
the dominator tree.
Bug: 137230022
Test: aapt2_tests
Change-Id: I965365d1a9433ae595eab48d82837ac102148334
Information about where resources are defined can make having
reproducible builds more difficult, makes the generates resources.pb
large, and can exposes details about the machines that compiled the
resources.
The --exclude-sources flags can only be used when building a proto APK
and prevents source information from being included in the generated
resources protobuf.
Bug: 134929532
Test: checked debug string with and without the string
Change-Id: Ia345f067fe781ea82a4bcad37eb55576c72c44d7
Following up to change 7938786; if an APK had platformBuildVersionCode
compiled as *both* integer and string, it would be output twice. This
then confuses anything that tries to parse the output.
With this change, the value will be printed at most once, with the
string version taking priority.
Bug: 138666693
Test: manually built SDK28 APK and ran aapt2 dump badging
Change-Id: Icf6eb656ac0cb263969bb2f0c5ca03139985f6ca
ResourcePathShortener appends one digit at the end of colliding short
file names to disambiguate them. This cl sorts the list of file paths so
that colliding files always get the same disambiguating digit from one
run to the next rather than possibly alternating.
Test: make aapt2_tests
Change-Id: I983a1448c21f2c79d7cdb1de232e7758c04fc256
This change adds support for a new <queries> tag as a child of the
<manifest> tag, allowing a package to declare the intents it intends to
use to query for other apps on device.
Bug: 136675067
Test: build and boot
Change-Id: Ic8b40cabddee4b6404c220901efeaae680661c0c
It does not make sense for aapt2 to calculate the optimal number of
chars in the shortened path when it only depends on the number of
resources rather than anything apk specific. This cl precalculates the
number of chars and uses if conditions instead.
Test: manual testing + aapt2_tests still passes.
Change-Id: If2dc86952a6b6e01ce02dc42754c037d07d57325
"aapt2 optimize" without --enable-resource-path-shortening should not do
resource-path-shortening.
Bug: 75965637
Change-Id: Ibcbf325e66ed7992bf81184260abd63711b2af2a
aapt2 optimize --enable-resource-path-shortening should ignore res/color
resources since android uses the path while loading them. This cl fixes
a bug where res/color-* (eg: res/color-v21) resource paths are shortened
when they should not be.
Test: make aapt2_tests
Bug: b/75965637
Change-Id: Ibbc3fe4d2e6bd4f31765a5aa85980907dc013ecd
Add uses-split dependencies to AppInfo. At link time, this is used
and allows features to reference other features, before
resource namespacing is implemented in Android Studio.
bug:135681292
Test: Link_test, ReferenceLinker_test, and integration tests.
Change-Id: Ifdf0067e7370552b6b9d4d6d4713d4484b6ea154
Add a new option for skipping resource references validation when
building a static library. This pushes resource reference validation
to the final link step (creating an installable APK), but allows a lib
to be linked without having the static libs of its dependencies.
More context: go/autonamespace-transform
Test: MergeOnlyTest + manually verified
Bug: 128824820
Change-Id: I1f3e3b7715a5244b8633c85519d94334c76ff664
When a developer specifies an adaptive application icon,
and a non-adaptive round application icon, create an alias
from the round icon to the regular icon for v26 APIs and up.
We do this because certain devices prefer android:roundIcon over
android:icon regardless of the API levels of the drawables set for
either.
This auto-aliasing behaviour allows an app to prefer the
android:roundIcon on API 25 devices, and prefer the adaptive icon on
API 26 devices.
Bug: 34829129
Test: manual
Change-Id: Ifac49455da749afde636fd4bb8cf32308f8b1e0a
For normal app development, the desired linking semantics are:
* styleables - take union of all definitions
* all other resources - take last non-weak definition
This differs from the semantics needed in other scenarios, where
merging/overlaying styles is desired.
Bug: 134525082
Change-Id: Iac0c43ca2ecf1f3fddc9c3367f8914c12c9258e1
Tested: aapt2_tests
There exists a discrepancy between how aapt1 and aapt2 prevent the
compression of assets using the -0 flag. aapt1 checked if the file name
ended with an argument, but aapt2 is checking if the file extension
exactly matches the argument. This change makes aapt2 behave the same as
aapt1 for asset compression using the -0 flag.
Bug: 132823799
Test: aapt2_tests
Change-Id: I641b3ebce29e4407b543faea373a5ce516b70cda
If the value of an attribute enum is defined as a hexadecimal integer,
flatten uses of the attribute as with the
android::Res_value::TYPE_INT_HEX type.
This change adds a "type" field to pb::Attribute::Symbol, which if left
unset, will have a default value of android::Res_value::TYPE_INT_DEC
when deserialized by aapt2.
Bug: 124474141
Test: aapt2_tests and manual compilation of files and inspection using
`aapt2 dump chunks`
Change-Id: Ibf12394284fdbe3a8047f7ecf4fe68517dfc3abb
aapt::ManifestFixer might add attributes from
http://schemas.android.com/apk/res/android when none existed previously.
When that happens, something needs to ensure that the schema has a
declared xmlns prefix, otherwise this:
bdb3e97c47/src/tools/android/java/com/google/devtools/build/android/aapt2/ResourceLinker.java (L560)
will crash. It's a bit odd that Bazel converts back and forth between
protobuf and XML, but as long as the fields exist in Resources.proto,
they should be set.
Bug: 133004752
Change-Id: I73fb3f713be34c9f81753fde2fd24c4524656b7d
Tested: aapt2_tests
aapt2 saves space by compiling all raw xml strings to the Res_value
structure. This causes the platformBuildVersionCode and
platformBuildVersionCodename attributes on the <manifest> tag to be
compilled as integers. aapt2 and aapt dump badging assumed these values
would be strings and is failing to print the value for these attributes.
With this change, the value will be printed regardless if it is encoded
as an integer or string.
Bug: 130830770
Test: manualy build APK and run aapt2 dump badging
Change-Id: I89487db36c6bc4d0fde3a410b7a64debfec5021e
std::set only works correctly when the < comparator is a strict weak
ordering, while UsageLocation::operator< was actually implementing !=.
Bug: 134190468
Change-Id: Icb9407e9c8451f9fcb4eb9b2cea310e3bcaf159e
Tested: aapt2_tests, and b/134190468#comment1
In aapt1, if you specified the value of an attribute in a style as an
empty string (eg. <item name="my_attr"></item>), the encoded value would
be an empty string. In aapt2 currently, @null is encoded instead. This
change restores aapt1 behavior. Use @null explicitly if the desired
value is to be @null.
Bug: 133450400
Test: manual comparison of APK created by aapt1 and aapt2
<attr name="my_attr" format="string|reference" />
<style name="MyName">
<item name="my_attr"></item>
</style>
$ aapt p -M AndroidManifest.xml -F out1.apk -S res -f
$ aapt2 compile --dir res-o compiled.flata
$ aapt2 link --manifest AndroidManifest.xml -o out2.apk compiled.flata
$ aapt2 dump out2.apk
Change-Id: I8aa0ba30379dac0b1229da525abbc5482f40114b
aapt2 does not require the lite runtime optimization to reduce binary
size. Removing the allows for the protos to be optimized for speed
instead of binary size and grants access to refelctive operations.
Test: aapt2_tests on linux and windows
Change-Id: Ie7ed9df4061e2eb60adbd300eb358d4c3f32c80c
This reverts commit 60c71cee6e.
Reason for revert: Rolling forward for Q-Finalization
Bug: 131429032
Bug: 129975435
Change-Id: Idd812d93b767d8a672b9ada58c8bcc2441395847
This is needed by the build system to update soong_build_number.
On a local build, "aapt2 version" used to print:
Android Asset Packaging Tool (aapt) 2.19-SOONG BUILD NUMBER PLACEHOLDER
Now it prints:
Android Asset Packaging Tool (aapt) 2.19-eng.dchai.20190511.023434
Bug: 132476779
Bug: 123663089
Change-Id: I5bc5adc9f5b2a7a30bdc649e3c073868b55f17df
Tested: manual, see above