aapt2 currently looks-up packages only by package name and then verifies
whether the package ID has the expected value. For pre-L we need to be able
to handle resource tables having packages of same package name but
different IDs.
Note that this CL fixes only proto->binary conversion but many other aapt2
commands are still affected. This is because many transformations still
consider package name as sufficient identifier of a package.
Bug: 72143207
Test: Manual
Change-Id: Id8a920d6cd15bec747d3124270f5bcb7f48924cf
When converting between binary and proto APKs in either direction, the
'aapt2 convert' command did not adjust FileReference type for entries
inside the resource table. This fix makes in-place changes of the resource
table passed to ConvertApk, which is safe since the resource table is
thrown away after the conversion.
Bug: 71854843
Test: Manual
Change-Id: Ide6e141269392db15b399db3566f18175f5133d5
Fixed a memory-corruption issue that led to multiple duplicate
permission entries being generated for Manifest.java.
Bug: 71641288
Test: make aapt2_tests
Change-Id: I8cd37929c4883aaba2beebbf874c7ee3234d51d8
If a resource XML file defines two compatible Attributes, they should
be merged without throwing an error. Ex:
<declare-styleable>
<attr name="conflict" format="string" />
</declare-styleable>
<declare-styleable>
<attr name="conflict" format="string|reference" />
</declare-styleable>
In this case, string|reference and string are the same, so these should
merge correctly.
Bug: 65699599
Test: make aapt2_tests
Test: make AaptBasicTest
Change-Id: I7b0f956d2332f7f0b458acd59ca0a606b2cfdf95
Delete called on non-final virtual classes but non-virtual destructor.
Fixes -Wdelete-non-virtual-dtor warning.
Test: m checkbuild
Change-Id: Ia84c118db1a53f1ac846354a6023726e394a87ed
delete called on non-final virtual classes but non-virtual destructor.
Fixes -Wdelete-non-virtual-dtor warning.
Test: m checkbuild
Change-Id: I142a2f70286a28722e462df4c160cb7aa3753c2a
- Also fixes issue where a failure checking the Java package of an attribute
would yield no error message.
Bug: 70722199
Test: make aapt2_tests
Change-Id: I417d5ffe18c8d4ba2f1638f9fb9ba29278ec8e94
Filesystem directory enumeration is platform dependent, so
sort the files lexicographically according to source path before
consuming them in the compile command.
Bug: 70680618
Test: manual
Change-Id: I6706dea2eb40cbaff8a586994dd1013976e4ced4
* changes:
AAPT2: Sort artifacts based on the Play Store rules.
AAPT2: Allow empty group definitions
AAPT2: Get list of multi-APK artifacts without APK file
Only XML files can define resources inside of them, so the fragment
R.txt will only be created for XML files. The fragment R.txt will
contain files defined inside the XML files and the file itself.
For example for res/layout/my_layout.xml that defines "@+id/myView" the
fragment R.txt will contain "default int id myView" and "default int
layout my_layout".
Resources defined with the "public" keyword will have the word "public"
in the partial R.txt, resources defined with the "java-symbol" keyword
will have the word "private, and all other resources will have the word
"default".
If a string is declared in values/strings.xml as:
'<string name="foo">text</string>'
then the partial R.txt will contain "default int string foo". If the
same string is also marked as public in the values/public.xml as:
'<public type="string" name="foo" id="0x7f000001"/>
then the partial R.txt for that file will cointain:
"public int string foo".
Also, the resource IDs will be skipped as this is only for compilation,
proper IDs will be generated at linking phase.
Test: manual
Change-Id: I37d07d5ee4a9f2e5a60a54e48579eba86ae7dd60
Sort output artifacts so that the updated versionCode manifest entry
will allow correct handling of updates from Play Store. The most
important dimension is Android SDK version. It is important that a split
based on min SDK version will allow a user to get a new APK if they
upgrade the OS on their device to support a new split.
ABI splits need to also be taken into consideration as it is possible
for a device to run in ARM emulation mode and installing an ARM APK over
a x86 APK could cause performance regressions.
The XML file format was updated to give each of the configuration groups
have their own section of the XML file. This allows the sort order to be
determined by a groups ordering. Artifacts can now be added to the
configuration file in an arbitrary order. Since this will be the common
case for developers, it will help reduce errors from inserting a new
artifact in the wrong spot.
The implementation follows the rules outlined at:
https://developer.android.com/google/play/publishing/multiple-apks.html
Test: Unit tests
Test: Manual process XML configuration
Change-Id: I0face862c6d6b9d3cd2d99088afe5b9491be0120
With ABI, screen density, and locale, it is possible to use a shorthand
notation when the group only has a single entry. The shorthand is to
leave the group empty and use a valid configuration for the group name.
Test: manually ran optimize command
Test: unit tests
Change-Id: If2d091e587474847c6c9e9be1a29196b261cc82d
Allow the optimize command to produce a list of output artifact names
without needing to read the input APK from disk. This not only saves
disk reads for a file that will not be used, it also allows the list
of outputs to be generated without having an APK file yet.
Test: unit tests
Test: split an APK
Test: print list of outputs without an APK
Change-Id: I4e18e63f298a07f26ab0de2b2f0acb769bb535ba
Resources can be marked as overlayable, which means they can
be overlaid by runtime resource overlays.
This change propagates this state to the final resource table that
is installed on device.
Future work:
- Have the idmap tool respect the overlayable state and ignore
entries that overlay anything else.
Bug: 64980941
Test: make aapt2_tests
Change-Id: Id45b1e141a281be2ee32a4ac3096fcf1114d523b
When parsing is complete, we now have a list of output artifacts that
have their referential integrity validated. This means that once the
configuration file is parsed, the only errors that can occur are related
to APK processing, and not the configuration itself.
This reduces the number of errors that could cause a partial output of
APK artifacts. It simplifies the public API and reduces the complexity of
the code to generate multiple APKs.
Test: Ran unit tests
Test: manually ran the optimize command to ensure it still works
Change-Id: I3f2d885b207a84c958f5348a4baa6718598184a4
--target-abis is never used and the same functionality works with
onfiguration files.
Test: Unit tests
Change-Id: Ic890eb0f15fade82cd85ba34d653d6cea3b79fb2
Bugs: b/70571736
Remove signer files (.SF and public key) as well as the original
manifest file from any output artifacts. Since the artifacts are not
signed, we want to remove the original signature and manifest. The APK
signer tool will add these back later.
Updated the context wrapper to enable verbose mode to be cleared. This
lets us have more specific log messages when splitting an APK as at this
point the artifacts and filters are more interesting than the files removed.
Test: Manually split an APK and verified the filles were removed while
leaving the other META-INF entries.
Test: Unit tests
Change-Id: Ia59993b5570f802130c6e3ba42398a00821061ea
Ensure that the configured min max and target SDK versions of the
android-sdk configuration item are correct. This will prevent AAPT2
crashing when it tries to dereference the Android SDK version to update
the manifest.
The test for the latest development SDK version has also been made
future proof by using the SDK constants.
Test: unit tests
Test: manually split an APK
Change-Id: I1ffa90ba2d96cab0cbfa4bd75ef37a50d986852d
A new optional flag has been added to allow a list of artifacts that
should be written as output to be provided. If the flag is provided,
only artifacts that have an output name matching an entry in the list
will be processed.
Test: manually ran against an APK with multiple artifacts in the
configuration and confirmed that only the specified artifacts were
written.
Test: Ran all unit tests.
Change-Id: Ia32b19acf1b2ef3711abf13df08dc7b1aa0cf161
Test: Built aapt2, ran optimize on gmail apk with sample whitelist
config file, and flags enabled. Added two unit tests to TableFlattener
covering obfuscation logic.
Change-Id: Iad6329d75ff440121bf1a2cdf09c5f4bf4199d9d
This change injects the 'android:compileSdkVersion' and
'android:compileSdkVersionCodename' into an app's AndroidManifest.xml,
whose values are dervied from the version name and version code of the
framework AndroidManifest.xml that is being linked against.
Bug: 63388434
Test: make aapt2_tests
Change-Id: I7b607192ecb337307c4bcb5770e7f716c6d4c9d2