25 Commits

Author SHA1 Message Date
Ryan Mitchell
704090e02a AAPT2: Version code major flag
Adds flag --version-code-major that injects android:versionCodeMajor
into the manifest if none is present or when overriding.

Bug: 109883459
Test: aapt2_tests
Change-Id: I10b27abb8fa8a99a41976c42c4d684b99978b4f9
2018-07-31 22:06:24 +00:00
Colin Cross
dcd58c4207 Add support for --replace-version to aapt2
Implement --replace-version to match aapt1.

Bug: 79755007
Test: aapt2_tests
Change-Id: Iee2bd9a3981c7d4681509f18b735c6e9e6c1a336
2018-05-30 14:48:52 -07:00
Ryan Mitchell
7cb82a86be AAPT2: Insert platformBuild information
Inserts platformBuildVersionName and platformBuildVersionName when the
attributes are not currrently present. The attributes are set to
the values of versionName and versionCode.

Bug: 77541121
Test: Build apk using aapt and appt2 and dumped using xmltree to confirm
the presence of the attributes
Change-Id: I5330381905c878fb877214b42f83d7e2e48cd062
2018-05-10 15:37:37 -07:00
Ryan Mitchell
e5b38a676c Added --debug-mode flag to AAPT2
Bug: 74968793
Test: Tested for correct debuggable attribute presense with and without
flag

Change-Id: I0148d1caba62db8cf258926f1d9e87a849aa283f
(cherry picked from commit 444f9bb6a18ff34b69cba504c8658b7013eaa53a)
2018-04-04 15:51:53 +00:00
Adam Lesinski
fca5e427e2 AAPT2: <uses-library /> and <library /> don't need to be Java packages
- 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
2017-12-28 08:17:51 -08:00
Izabela Orlowska
ad9e1324ff AAPT2: treat manifest validation errors as warnings when asked
Bug: 65670329
Test: updated
Change-Id: Ic554cc20134fce66aa9ddf8d16ddffe0131c50e9
2017-12-20 13:25:59 +00:00
Adam Lesinski
c6284379a5 AAPT2: Embed version of framework an app was compiled against.
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
2017-12-04 17:19:44 -08:00
Adam Lesinski
23034b911c AAPT2: Fix overzealous AndroidManifest fully qualified class names
ManifestFixer would go and fully qualify all elements with the attribute
'android:name', which is not correct, especially for cases like

  <uses-split android:name="foo" />

Test: make aapt2_tests
Change-Id: I4bea2550d0025179d2d48dca8c64e0cbf4451e99
2017-11-29 16:29:08 -08:00
Adam Lesinski
6b37299129 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
2017-08-17 17:43:08 +00:00
Adam Lesinski
87f1e0fd31 AAPT2: Allow <key-sets> tags in AndroidManifest.xml
Bug: 62839863
Test: make aapt2_tests
Change-Id: Ic38fadf3b204bf603f6770643735635cd1f1df7e
2017-06-28 10:27:06 -07:00
Adam Lesinski
63699b128e AAPT2: Ignore namespaced elements in AndroidManifest.xml
Some third party stores/tools expect manifest elements
under their namespace, and AAPT2 shouldn't fail if these
are present.

Bug: 37943705
Test: make aapt2_tests
Change-Id: I87b7500c7da5e8e79fc2a78b30e8e4334124af3d
2017-05-08 18:36:33 -07:00
Adam Lesinski
86d67df8d5 AAPT2: Support CtsContentTestCases build
- Add <feature-group> to ManifestFixer.
- Support <meta-data> in <instrumentation>
- Add support for <bag> and type="configVarying". Some CTS tests use this
  old notation, we need to support it (even though configVarying isn't
  anything supported by the framework convention).

Change-Id: I6946fa633ce513ea8437c1496db883cf27dcf6de
Test: make aapt2_tests
2017-02-01 15:28:23 -08:00
Adam Lesinski
d5083f6f6b Move StringPiece to libandroidfw
libandroidfw needs to make use of StringPiece, so
move it to libandroidfw and update all code referencing
StringPiece in aapt2.

Test: make libandroidfw_tests libaapt2_tests
Change-Id: I68d7f0fc7c651b048d9d1f5e7971f10ef5349fa1
2017-01-17 18:55:51 -08:00
Adam Lesinski
5119e51730 AAPT2: Allow <meta-data> in <manifest>
Bug:32171613
Test: libaapt2_tests
Change-Id: I30fdd9475ff7dff6ceb0ff46a4a00991b72db68b
2016-12-05 21:09:52 -08:00
Adam Lesinski
e343eb145c AAPT2: Insert <uses-sdk> element before <application>
PackageParser on the device uses the targetSdkVersion of the
app while it parses <application>. That means that if the
<uses-sdk> tag comes after <application>, the targetSdkVersion
is assumed to be 0.

Test: make libaapt2_tests
Change-Id: I60f2179a7ff44e7419217afb53f3d24f8c030f6e
2016-10-27 16:31:58 -07:00
Adam Lesinski
ce5e56e243 AAPT2: Rename to match new style
Use Google3 naming style to match new
projects' and open source google projects' style.

Preferred to do this in a massive CL so as to avoid
style inconsistencies that plague legacy code bases.
This is a relatively NEW code base, may as well keep
it up to date.

Test: name/style refactor - existing tests pass
Change-Id: Ie80ecb78d46ec53efdfca2336bb57d96cbb7fb87
2016-10-26 19:30:23 -07:00
Adam Lesinski
cacb28f2d6 Use Google3 style guide with .clang-format
Test: style change only, builds ok
Change-Id: I885180e24cb2e7b58cfb4967c3bcb40058ce4078
2016-10-19 12:18:14 -07:00
Adam Lesinski
6b17d2cec2 AAPT2: Parse coreApp in <manifest> as boolean
Bug:30751662
Change-Id: I283be5725426ee084944c1921df40d1bd6188028
2016-08-10 11:37:06 -07:00
Adam Lesinski
58a20a6482 AAPT2: Change accepted notation for resource names in tests
Previously the way to name resources in tests was to use reference
notation (@[package:][type/]name). Now we use name notation (no @).

Change-Id: I68f0a36562d89cc78c582d128f370d9556c58707
2016-07-25 17:56:58 -07:00
Adam Lesinski
d0f116b619 AAPT2: Remove usage of u16string
For legacy reasons, we kept around the use of UTF-16 internally
in AAPT2. We don't need this and this CL removes all instances of
std::u16string and StringPiece16. The only places still needed
are when interacting with the ResTable APIs that only operate in
UTF16.

Change-Id: I492475b84bb9014fa13bf992cff447ee7a5fe588
2016-07-13 17:45:28 -07:00
Adam Lesinski
cc5609d8e4 AAPT2: Implement XmlActionExecutor to verify manifest
Defines a set of actions to perform on XML elements defined by their
hierarchy, eg: manifest -> application -> activity.

This can be used to easily add rules to check more tags in AndroidManifest.xml

Change-Id: I76c6916a98b6403075a7e56e16230979dc6cbee1
2016-04-06 11:37:05 -07:00
Adam Lesinski
64587af817 AAPT2: Support building, linking, and merging static libraries
Android static libraries are like APKs but they contain much more debugging
and source information. We need to treat them differently in 3 ways:

1) When building a static library, we skip things like ID assignment and
   product/config stripping. Source information is emitted as well.
2) When building a static library and linking against another
   static library, we don't want to merge, we want to simply reference.
3) When building an app that uses static libraries, we want to merge
   the static library under the same package with or without mangling.

Bug:25958912
Change-Id: I425e032857936a3e83173c1edc2a6cdc6020b842
2016-03-04 14:39:01 -08:00
Adam Lesinski
52364f7ae3 AAPT2: Variety of small fixes to get the build working
- Add option to rename package in AndroidManifest.xml
- Support default versionName and versionCode
- Accept True and False as valid booleans

Change-Id: I400e350b9dcd0fd1c197d1929144299c7823617d
2016-01-13 18:48:24 -08:00
Adam Lesinski
467f171315 AAPT2: Fail compiling when private symbols are referenced
Also moved some XML specific stuff into its own directory,
and refactored ReferenceLinker a bit.

Change-Id: I912247a82023c1bbf72dc191fbdaf62858cbec0c
2015-11-19 14:46:53 -08:00
Adam Lesinski
2ae4a877d1 AAPT2: Add Manifest fixing/validation
Change-Id: I7f6d8b74d1c590adc356b4da55cb6cb777cdf1da
2015-11-02 16:56:34 -08:00