History log of /frameworks/base/tools/aapt2/configuration/ConfigurationParser.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
11cdc1cf7ab2e915611e2bb7264bd312012a9b64 01-Feb-2018 Shane Farmer <safarmer@google.com> AAPT2: Add order attribute to groups

Require explicit ordering of groups in the configuration file to ensure
that the correct version code is set. Ordering based on a single ABI is
straight forward to ensure Play Store delivers the correct APK, but when
an APK needs more than one ABI things get messy quickly. This also goes
for screen density etc. The only thing that is easily sorted without
this attribute is android-sdk since an artifact can only reference a
single SDK.

Test: unit tests
Test: manually split an APK with update config.xml
Change-Id: I37a2b8b8a8409d6d6ff27c7142d4c8c8065a7a51
/frameworks/base/tools/aapt2/configuration/ConfigurationParser.cpp
78c43d7bee2a476d6edffe0a4368eb6fcef38c31 04-Dec-2017 Shane Farmer <safarmer@google.com> AAPT2: Sort artifacts based on the Play Store rules.

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
/frameworks/base/tools/aapt2/configuration/ConfigurationParser.cpp
39e474f4b4a975d8befa1e8f4cbedab5f47a43fa 18-Dec-2017 Shane Farmer <safarmer@google.com> AAPT2: Allow empty group definitions

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
/frameworks/base/tools/aapt2/configuration/ConfigurationParser.cpp
cb6c3f9b880160c35785b1780b282fdf92952b90 27-Nov-2017 Shane Farmer <safarmer@google.com> AAPT2: Push more configuration code into the parser

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
/frameworks/base/tools/aapt2/configuration/ConfigurationParser.cpp
67e8a3074d7ef42734d44f3a8d87635e201bd660 06-Dec-2017 Shane Farmer <safarmer@google.com> AAPT2: Add validation for SDK version strings.

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
/frameworks/base/tools/aapt2/configuration/ConfigurationParser.cpp
004511660671511ae88e0e837a6f92db28eadaef 03-Oct-2017 Adam Lesinski <adamlesinski@google.com> AAPT2: Define and Implement AAPT Container Format

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
/frameworks/base/tools/aapt2/configuration/ConfigurationParser.cpp
810fd184356a76fc0fa35d07212df10b7e058063 21-Sep-2017 Shane Farmer <safarmer@google.com> AAPT2: Update versionCode in multi-APKs.

Set versionCode in the AndroidManifest.xml so each artifact has a unique
version code. This will allow the play store to serve up the correct
APKs.

The versionCode is determined by taking the versionCode from the input
APK and adding the configured version to that. If an artifact does not
have a version, the next version is used based on the order in the
configuration file. If the firs artifact does not have a version, it
starts at 1, so that all artifacts have a different version code to the
base APK.

Bug: 64972562

Test: unit tests
Test: manually optimized an APK into multiple APKs and confirmed versions:
aapt dump badging ${apk} | grep versionCode

Change-Id: Ie12b3e42bbd8ce9a2819712c2c56b24c0a901e6b
/frameworks/base/tools/aapt2/configuration/ConfigurationParser.cpp
3edd47264335cf609ac6e733db77522f7c959c3f 01-Sep-2017 Shane Farmer <safarmer@google.com> AAPT2: Set the minSdkVersion when generating multiple APKs.

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
/frameworks/base/tools/aapt2/configuration/ConfigurationParser.cpp
efe45392c300f922e8328281a0aab8260c1d171d 21-Aug-2017 Shane Farmer <safarmer@google.com> AAPT2: Multi APK generator by version

- Added an additional axis for generating a multi-apk split by minimum
Android SDK version. This removes any resources that will not be used
for the desired minimum SDK version. If there are multiple resources
that would be valid for any version newer than the requested minimum,
then all would be kept so that the best match can be found.

- Added a context wrapper to set the appropriate Android SDK version for
each generated artifact.

- Split out the FilterTable method to allow it to be directly tested
without the need to mock the APK writing steps.

Test: Unit tests
Test: manually run optimize command

Change-Id: I7e6018df081af9ed5d9e8aaf40ed216c1275f138
/frameworks/base/tools/aapt2/configuration/ConfigurationParser.cpp
9ecc0751e30086c0668c8fe5758f14fc5acf5ae8 25-Aug-2017 Shane Farmer <safarmer@google.com> AAPT2: Add flag to print multi APK artifact names.

- Added new flag that exits after printing the list of artifact names
that would be generated from the combination of the configuration file
and input APK.

- Cleaned up the code to generate the artifact names which also involved
adding some more test cases for corner cases.

Test: Unit tests
Test: Manually ran new command
Test: Manually ran old command
Change-Id: I8d30e7a4a070af26945b8f544a13f23bdf1ba169
/frameworks/base/tools/aapt2/configuration/ConfigurationParser.cpp
2def7dcf22abbe4a2f419a82b080a7bcf2c8684d 17-Aug-2017 Adam Lesinski <adamlesinski@google.com> Merge "AAPT2: Change XmlDom to exclude Namespace as a node"
6b372991296c9f2bd6f8f8847dcd23d50970d06d 09-Aug-2017 Adam Lesinski <adamlesinski@google.com> AAPT2: Change XmlDom to exclude Namespace as a node

In preparation for exporting an XML proto format for UAM to consume,
this change brings the XML DOM API more in line with other APIs that
do not make the Namespace a separate node.

Treating Namespace declarations as just properties of an Element
node makes the implementation of algorithms much simpler, as
the constraints that Namespace nodes have only one child
are now built in and traversing to find Element nodes
is much simpler.

Also made a bunch of quality of life improvements, like formatting and
comment style.

Test: make aapt2_tests
Change-Id: Ib97ff1c4252b7907e2cc1f13a448dc4ca3b809a4
/frameworks/base/tools/aapt2/configuration/ConfigurationParser.cpp
0a5b201156f1dd01a7da7b7674798ed57cfafc5a 22-Jun-2017 Shane Farmer <safarmer@google.com> AAPT2: Add a APK filtering.

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
/frameworks/base/tools/aapt2/configuration/ConfigurationParser.cpp
efeb7af13be4446ce4a511a2ca707691e9a67c1e 02-Aug-2017 Adam Lesinski <adamlesinski@google.com> AAPT2: Fix windows unicode path issues

Mingw64 was being difficult, so instead of defining a wmain entrypoint,
the command line parameters are parsed manually using built-in Windows
methods that support Unicode. The results are converted to UTF8 and
handled just like the rest of the linux/mac version of the code.

This also removes dependencies on std::istream in favour of a
FileInputStream which calls the appropriate unicode version of
open to read a file.

No speed regressions found on Linux or MacOS.

Bug: 62336414
Bug: 63830502
Test: manual
Change-Id: I597da51e33729ed1b98bf246e7e773337fd3fee8
/frameworks/base/tools/aapt2/configuration/ConfigurationParser.cpp
1a21b8c04153b5b73a477ebd0622b24f3bbfc603 21-Jul-2017 Shane Farmer <safarmer@google.com> AAPT2: Update ReplacePlaceholder for artifact name parser

Update the artifact name parser to ensure that duplicate placeholders
are treated as an error.

Also applied suggested changes from ag/2447777.

Test: ran unit tests
Change-Id: Iab8fd9d9b81aa3008177141256ecd16ef04b0c34
/frameworks/base/tools/aapt2/configuration/ConfigurationParser.cpp
9f0e7f1dbade4b35b85e23954fa2b7c31d5f2009 22-Jun-2017 Shane Farmer <safarmer@google.com> AAPT2: Parse artifact names from template.

Add a helper method to convert a templated artifact name to file name
based on the values present in an Artifact struct. The Artifact
validates that all required template paramters are present.

Test: Unit tests
Change-Id: Id97ff606bb41c72a31c2d769104966be9cbca1a0
/frameworks/base/tools/aapt2/configuration/ConfigurationParser.cpp
280be34fa6311de90dff6c595a147fd5a182223d 22-Jun-2017 Shane Farmer <safarmer@google.com> AAPT2: Update the name of the configuration struct.

Make the Configuration struct name less ambiguous. Also ran clang-format
on the change since some lines were too long and this resulted in a
bigger diff than expected.

Test: built manually
Test: ran existing unit tests
Change-Id: I85e78041fa78d913d47a26c85ad48b05bf935a6a
/frameworks/base/tools/aapt2/configuration/ConfigurationParser.cpp
5766943f558c8fccc714bb3d0a96af70816a5545 19-Jun-2017 Shane Farmer <safarmer@google.com> AAPT2: Split APK by ABI.

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
/frameworks/base/tools/aapt2/configuration/ConfigurationParser.cpp
b102727771b9ac3d28d4f9b0a4a54b98bd1af958 14-Jun-2017 Shane Farmer <safarmer@google.com> AAPT2: Read config from disk

Implement the todo left from last change to read the contents of the
configuration file from disk. Since this is an operation that may fail
the API was changed to take return a Maybe to indicate errors reading
the file.

Test: unit test for error condition
Test: ran aapt2 optimize with the new code path wired in

Change-Id: I93d532b4a57af9520231225eee4fc5f2b1a046b9
/frameworks/base/tools/aapt2/configuration/ConfigurationParser.cpp
74cdea34cd6dce8bf9b4adaa2cd7cb02330120d5 13-May-2017 Shane Farmer <safarmer@google.com> AAPT2: XML configuration file parser.

The XML file is parsed with the aapt::xml::XmlDom parser and actions are
used for the elements we are interested in. This means that there are
cases where a user could add aditional tags/elements to the document
that are technically invalid (acording to the schema) but are ignored by
the parser. This allows us to be more lenient which probably isn't a bad
thing.

Documents have the namespace stripped before processing as the
XmlActionExecutor ignores any elements with a namespace. The namespace
is validated before being removed.

The test cases are all based off the previous example XML file.

Test: Unit tests

Change-Id: I86d7e0dc6347ace3eaa60c1842d59f3cd0d4f749
/frameworks/base/tools/aapt2/configuration/ConfigurationParser.cpp