summaryrefslogtreecommitdiff
path: root/tools/aapt2/configuration/ConfigurationParser_test.cpp
AgeCommit message (Collapse)Author
2020-07-31Make aapt2 terminology more inclusiveRyan Mitchell
Update language to comply with Android's inclusive language guidance See https://source.android.com/setup/contribute/respectful-code for reference Bug: 162364131 Bug: 162536543 Test: aapt2_tests Change-Id: I4eef925d6319b40a395fc8d59a3f2912a02ca03b
2018-12-11Merge "Fix cert-dcl16-c clang-tidy warnings." am: 20b64c4bc7 am: 3038f743bfChih-hung Hsieh
am: 82b999a59c Change-Id: Ie4bb31fc7366d65e92209c31f6721e20c8538e9a
2018-12-11Fix cert-dcl16-c clang-tidy warnings.Chih-Hung Hsieh
Bug: 120614316 Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,cert-dcl16-c Change-Id: I2dc262d3407aafa969e921236dc3fc3ae60eb9d4
2018-10-08libandroidfw: move ConfigDescription from aapt2 to libandroidfwMårten Kongstad
This is to allow idmap2 to access ConfigDescription. Test: libandroidfw_tests Test: aapt2_tests Change-Id: I54210bbbd8dad5903cb7100807df977efa394ad5 Merged-In: I54210bbbd8dad5903cb7100807df977efa394ad5
2018-10-08libandroidfw: move ConfigDescription from aapt2 to libandroidfwMårten Kongstad
This is to allow idmap2 to access ConfigDescription. Test: libandroidfw_tests Test: aapt2_tests Change-Id: I54210bbbd8dad5903cb7100807df977efa394ad5
2018-08-14AAPT2: Update SDK development codename to QRyan Mitchell
Test: aapt2_tests Change-Id: I815e0bfc786660d6ad70897287fb5fb21023068c
2018-02-02AAPT2: Add order attribute to groupsShane Farmer
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
2017-12-19AAPT2: Sort artifacts based on the Play Store rules.Shane Farmer
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
2017-12-19AAPT2: Allow empty group definitionsShane Farmer
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
2017-12-13AAPT2: Push more configuration code into the parserShane Farmer
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
2017-12-12AAPT2: Add validation for SDK version strings.Shane Farmer
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
2017-11-02AAPT2: Update tests to reflect new development API 'P'Adam Lesinski
Bug: 68346913 Test: make aapt2_tests Change-Id: Ic1435c529b6c80206d2326ac0da076777dffcc9a
2017-10-03AAPT2: Update versionCode in multi-APKs.Shane Farmer
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
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-31AAPT2: Multi APK generator by versionShane Farmer
- 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
2017-08-31AAPT2: Add flag to print multi APK artifact names.Shane Farmer
- 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
2017-08-17Merge "AAPT2: Change XmlDom to exclude Namespace as a node"Adam Lesinski
2017-08-17AAPT2: Change XmlDom to exclude Namespace as a nodeAdam Lesinski
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
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-07-25AAPT2: Update ReplacePlaceholder for artifact name parserShane Farmer
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
2017-07-18AAPT2: Parse artifact names from template.Shane Farmer
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
2017-06-21AAPT2: Update the name of the configuration struct.Shane Farmer
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
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-06-19AAPT2: Read config from diskShane Farmer
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
2017-05-31AAPT2: XML configuration file parser.Shane Farmer
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