608 Commits

Author SHA1 Message Date
TreeHugger Robot
e5b3296316 Merge "Allow <adopt-permissions> tag in manifest" 2018-01-19 17:10:29 +00:00
David Chaloupka
cfd1b4b263 Merge "Handle multiple packages of same name in 'aapt2 convert'" 2018-01-19 10:57:53 +00:00
TreeHugger Robot
8f2fffd809 Merge "AAPT2: Store BinaryPrimatives in protos as oneofs" 2018-01-19 01:00:00 +00:00
David Chaloupka
e3c1a4a9d2 Handle multiple packages of same name in 'aapt2 convert'
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
2018-01-18 19:20:01 +00:00
David Chaloupka
415689bb1c Merge "Adjust file reference type in 'aapt2 convert'" 2018-01-18 10:06:01 +00:00
Michael Wachenschwanz
d06f1f38a9 AAPT2: Store BinaryPrimatives in protos as oneofs
Fixes: 69587794
Test: aapt2_tests

Change-Id: Idf5526f6b1b720b6e476bcdf8c2155e13a6ecc0f
2018-01-17 16:58:43 -08:00
TreeHugger Robot
bd56951c5b Merge "aapt2: Fix issue with Manifest duplicate handling" 2018-01-17 20:20:29 +00:00
David Chaloupka
b66db4ec4c Adjust file reference type in 'aapt2 convert'
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
2018-01-17 11:07:44 +00:00
Adam Lesinski
a4fb17bbbb aapt2: Fix issue with Manifest duplicate handling
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
2018-01-16 17:06:33 -08:00
Izabela Orlowska
3c3f9b5d07 AAPT2: always compile 9patch files
Test: existing tests
Bug: 70578281
Change-Id: I7ffcbdd664108348182e71d01b1680e2399ec37c
2018-01-12 14:26:31 +00:00
TreeHugger Robot
4f9ba20690 Merge "AAPT2: Allow compatible duplicate Attributes" 2018-01-12 02:37:13 +00:00
Adam Lesinski
73bff1e851 AAPT2: Allow compatible duplicate Attributes
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
2018-01-11 13:54:11 -08:00
Yi Kong
0556f3382b Add virtual dtor for virtual classes
Delete called on non-final virtual classes but non-virtual destructor.

Fixes -Wdelete-non-virtual-dtor warning.

Test: m checkbuild
Change-Id: Ia84c118db1a53f1ac846354a6023726e394a87ed
2018-01-10 19:59:58 -08:00
Yi Kong
95820bc4df Merge "Add virtual dtor for virtual classes" am: 27f61a94d6 am: 2d7813a4a7
am: 2807036b09

Change-Id: I3723483c2aac5580a7db3256a39eca278a3ee9fb
2018-01-08 21:22:21 +00:00
Yi Kong
2807036b09 Merge "Add virtual dtor for virtual classes" am: 27f61a94d6
am: 2d7813a4a7

Change-Id: I8787ff83ec93f5a8ae2e08e1af573d13750d9aa5
2018-01-08 21:07:09 +00:00
Alan Viverette
cf5326fae1 Allow <adopt-permissions> tag in manifest
Change-Id: Ib595ab84da3a68e6a72f203ee51e3c86c7a3a3d1
Fixes: 71640901
Test: migrate GoogleServicesFramework to AAPT2, build
2018-01-05 16:04:33 -05:00
Yi Kong
6dbd3d7a59 Add virtual dtor for virtual classes
delete called on non-final virtual classes but non-virtual destructor.

Fixes -Wdelete-non-virtual-dtor warning.

Test: m checkbuild
Change-Id: I142a2f70286a28722e462df4c160cb7aa3753c2a
2018-01-03 11:41:12 -08: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
Adam Lesinski
e6aa6d1421 AAPT2: Keep file enumeration consistent across platforms
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
2017-12-28 08:17:43 -08:00
TreeHugger Robot
d14c826c82 Merge changes I0face862,If2d091e5,I4e18e63f
* 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
2017-12-20 18:05:53 +00:00
TreeHugger Robot
54839e0d30 Merge "AAPT2: Add flag to compile command for outputting symbols" 2017-12-20 15:27:19 +00: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
Izabela Orlowska
c81d9f36ec AAPT2: Add flag to compile command for outputting symbols
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
2017-12-20 12:04:23 +00:00
Shane Farmer
78c43d7bee 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
2017-12-19 13:52:30 -08:00
Shane Farmer
39e474f4b4 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
2017-12-19 13:52:30 -08:00
Shane Farmer
2c12241fa8 AAPT2: Get list of multi-APK artifacts without APK file
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
2017-12-19 13:52:30 -08:00
Adam Lesinski
71be70507d AAPT2: Propagate SPEC_OVERLAYABLE flag to final APK
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
2017-12-18 14:16:02 -08:00
Adam Lesinski
e3b532ce0e Merge "AAPT2: Enable mangled symbol lookup in AssetManagerSymbolTable" 2017-12-14 22:27:02 +00:00
Shane Farmer
cb6c3f9b88 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
2017-12-13 12:28:39 -08:00
TreeHugger Robot
12f1b7f02d Merge "AAPT2: Remove signatures from multi-APK artifacts." 2017-12-13 05:32:41 +00:00
TreeHugger Robot
29086acac2 Merge "AAPT2: Remove unused command line option." 2017-12-13 03:06:54 +00:00
Shane Farmer
99ac3fdbd8 AAPT2: Remove unused command line option.
--target-abis is never used and the same functionality works with
onfiguration files.

Test: Unit tests
Change-Id: Ic890eb0f15fade82cd85ba34d653d6cea3b79fb2
Bugs: b/70571736
2017-12-12 16:55:31 -08:00
Shane Farmer
3ff44436a1 AAPT2: Remove signatures from multi-APK artifacts.
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
2017-12-12 16:25:26 -08:00
Shane Farmer
67e8a3074d 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
2017-12-12 16:25:26 -08:00
TreeHugger Robot
b3b66ee66b Merge "AAPT2: allow to generate R.txt without R.java" 2017-12-12 13:21:05 +00:00
Tom Dobek
725fb12c0d Aapt2 convert: skip processing resources when resource table is absent.
Test: manual

Change-Id: Iafe20f98857a29d625e7a57a9201db6279d43e45
2017-12-11 10:30:12 +00:00
Adam Lesinski
dc785052d0 AAPT2: Enable mangled symbol lookup in AssetManagerSymbolTable
Bug: 70045583
Test: make AaptTestNamespace_Split
Test: make aapt2_tests
Change-Id: I25da9d58736fc9090d1527782391c9b2220d2f8d
2017-12-07 17:23:25 -08:00
Izabela Orlowska
23a6e1e390 AAPT2: allow to generate R.txt without R.java
Bug: 69956357
Test: manual
Change-Id: If2bc32bd4efb1ea17c6cba7a17f2b2300164ede0
2017-12-05 20:59:08 +00:00
TreeHugger Robot
49639bf6cd Merge "AAPT2: Allow output artifacts to be filtered." 2017-12-05 20:36:47 +00:00
Shane Farmer
666de34a58 AAPT2: Allow output artifacts to be filtered.
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
2017-12-05 10:52:48 -08:00
TreeHugger Robot
4ab869e1e6 Merge changes I2eef812b,I7b607192
* changes:
  AAPT v1 embed compile SDK version and codename into app
  AAPT2: Embed version of framework an app was compiled against.
2017-12-05 16:03:26 +00:00
Luke Nicholson
5e50588e49 Merge "Enable obfuscation of resource names, with whitelisting support." 2017-12-05 05:20:00 +00:00
Luke Nicholson
b0643302c7 Enable obfuscation of resource names, with whitelisting support.
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
2017-12-04 17:54:05 -08: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
TreeHugger Robot
427540609f Merge "AAPT2: Fix issue where exported symbols (@+id/*) were not exported" 2017-12-02 10:05:31 +00:00
Pierre Lecesne
86edf36625 Merge "AAPT2: Use manifest parsing to determine format of APK." 2017-12-01 21:53:37 +00:00
Pierre Lecesne
f267a40400 AAPT2: Use manifest parsing to determine format of APK.
This makes it possible to load APKs that don't have a resource table.

Bug: 69355482
Test: Manual
Change-Id: I8471dbe068e836b4beea9e6934d18dd16b70ef02
2017-12-01 11:48:03 +00:00
Adam Lesinski
2427dce820 AAPT2: Fix issue where exported symbols (@+id/*) were not exported
Test: make AaptTestAppOne
Change-Id: If3218c880e83c2cfaf535a099db38504471be676
2017-11-30 16:12:29 -08:00
Dan Willemsen
1da6e70b7e Merge "Fix warning from clang+mingw" am: 7fce15dc5e am: 31bcd7acea
am: e2a0c1d062

Change-Id: I9212bf71035641d5efedf8f06627a62e9694806c
2017-11-30 23:51:04 +00:00
Dan Willemsen
e2a0c1d062 Merge "Fix warning from clang+mingw" am: 7fce15dc5e
am: 31bcd7acea

Change-Id: Ibb5c891fe3c219d75be8c124c9be215a31b2a241
2017-11-30 23:26:44 +00:00