218 Commits

Author SHA1 Message Date
Adam Lesinski
fb6312fe93 AAPT2: Add version collapsing
When an app specifies (or imports) resources with various
configurations for different SDK versions, specifying
a minSdk will make many of those resources unreachable.

Version collapsing will prune out the resources specified
for SDK versions less than the minSdk.

If, however, there is no exact matching resource for the
minSdk version, the next smallest SDK version is kept.

Change-Id: Ic7bcab6c59d65c97c67c8767358abb57cdec60a4
2016-06-29 17:02:19 -07:00
Roozbeh Pournader
112373006f Remove LocaleValue::toDirName() from AAPT2
There was no user, and the code was incorrect too.

Bug: 25599046
Change-Id: I50d14f58995ac611385a6fb17661a357bf473687
2016-06-24 17:01:07 -07:00
Adam Lesinski
1e21ff00b0 AAPT2: accept argument file list for -R
Bug:29462255
Change-Id: Ia83919a3e7de7fe2056a3f7613621972cccd49cb
2016-06-24 14:57:58 -07:00
Adam Lesinski
5d84ad5487 AAPT2: Allow <meta-data> in <application> tag
Change-Id: Ica3e7d5c1ce587eba58d8171e0f8d5cdb598e7b3
2016-06-23 13:18:16 -07:00
Adam Lesinski
b2106687e1 Fix pseudolocalizer at end of string
The accent pseudolocalizer would incorrectly process
the byte after the end of the string, which would end
up inserting null characters into the resulting
output.

Change-Id: I5cdabd6b0272d94073f06e180b8cbe7abafa3888
2016-06-23 13:03:15 -07:00
Adam Lesinski
32852a575b AAPT2: Use hash map for StringPool indices
Hash map has better locality and average case performance

Change-Id: Ic2d111c3cff1d5c0e7e9cbe36714669e6508c275
2016-06-18 01:10:34 +00:00
Adam Lesinski
5fcfdab573 Merge "Allow uses-library under <application>" into nyc-mr1-dev am: c878fb0cb8
am: b80680af78

* commit 'b80680af787dfb27e5a4b1b0edae8502373c4935':
  Allow uses-library under <application>

Change-Id: I078857ace29f7f35b9efbee99f4278b7c7ba9c9e
2016-06-03 00:44:51 +00:00
Adam Lesinski
fee32d4d5f Allow uses-library under <application>
Bug:29106952
Change-Id: I2e780323d86e7050038d34426a30e66a4bbfcc23
2016-06-02 23:57:55 +00:00
Michael Wright
0935d0132b Merge "Stop emitting javadoc for @removed attributes." into nyc-dev am: c4033e7c66 am: 1d10d94396
am: fab894efde

* commit 'fab894efdece38ec9f3df1adedf79eb148bc6bda':
  Stop emitting javadoc for @removed attributes.

Change-Id: Icbaa4eb19326d2ec41be78016665553a1b7beef0
2016-05-16 13:33:17 +00:00
Michael Wright
fab894efde Merge "Stop emitting javadoc for @removed attributes." into nyc-dev am: c4033e7c66
am: 1d10d94396

* commit '1d10d9439635dd19fbb581d852dc0bf7bace364a':
  Stop emitting javadoc for @removed attributes.

Change-Id: Iefa1290cea72c3ddecb57157e61c39af7ce8383b
2016-05-16 13:29:52 +00:00
Michael Wright
365eaeef5f Merge "Stop emitting javadoc for @removed attributes." into nyc-dev
am: c4033e7c66

* commit 'c4033e7c668abc1e671a130f70f58f885c63b176':
  Stop emitting javadoc for @removed attributes.

Change-Id: If48d0299c6d4d7179a366d902f23ada17315e42c
2016-05-16 13:26:58 +00:00
Adam Lesinski
33e74b7ece Merge "AAPT2: Add diff command" into nyc-mr1-dev am: 1a1461058e
am: 894f96a117

* commit '894f96a117a9ba942b9486317f6852c7472443a6':
  AAPT2: Add diff command

Change-Id: Ic53915ac3c04d151f55c159a170d46da7a1f6c17
2016-05-11 00:11:55 +00:00
Michael Wright
feaf99fa1b Stop emitting javadoc for @removed attributes.
We need the attributes to remain public because people might still be
linking against them, but we don't want them showing up in the
documentation any more. Them showing up in the documentation also had
the side effect that it would accidentally mark the parent class of
attributes as @removed, which was not intended.

Bug: 28663748

Change-Id: I2f6eb09455fddf1086e6b24bc3bea5292e8e32b7
2016-05-09 14:51:41 +01:00
Chih-Hung Hsieh
d53e3bed1c Fix google-explicit-constructor warnings.
Bug: 28341362
Change-Id: I080090d50f1a368a4e7c1a0732297bb6a295e34f
2016-05-03 10:02:51 -07:00
Adam Lesinski
458b877488 AAPT2: Add diff command
Adds the diff command and various small fixes to issues
discovered when diffing old AAPT built APKs with new AAPT2
built APKS.

Bug:22775504
Change-Id: I682a7fe1cf4b3efa7cbd5d18b333cf2d1046fe1b
2016-04-30 01:36:12 +00:00
Adam Lesinski
5fcf5d4fec Merge "AAPT2: Accept a file with arguments when argument list is too long" into nyc-dev am: 28d6c1e493 am: 461be97e30
am: e59d48398f

* commit 'e59d48398f983b822191ea3096499bdd0793840a':
  AAPT2: Accept a file with arguments when argument list is too long

Change-Id: Iad1d2b91109b0d1c78739c3fa3f31da5e0704f12
2016-04-28 20:05:24 +00:00
Adam Lesinski
c51562cf5a AAPT2: Accept a file with arguments when argument list is too long
Bug:22775504
Change-Id: Ife73d4e4611016c9ee7b56264bc6a765c54beba3
2016-04-28 11:14:38 -07:00
Chih-Hung Hsieh
c6baf563ba Fix google-explicit-constructor warnings.
Bug: 28341362
Change-Id: Ibdd6a210bb7ff228e3624cc319169f77aca3b51e
2016-04-27 11:38:12 -07:00
Rohit Agrawal
e49bb30dab AAPT2: ProGuard config for components in main dex.
Create an analogue of "aapt2 --proguard" which outputs a proguard
configuration that keeps only components which need to be in the main
dex.

Bug: 27383099

Change-Id: I61d652bfcdfc18e1614e852bd6f7540efd15f780
2016-04-22 14:40:40 -07:00
Adam Lesinski
5ff3ad6312 SettingsLib: Build with AAPT2
Bug:22775504
Change-Id: I2e5015235384d124418d32186daa190f38e1c5b3
2016-04-14 14:45:21 -07:00
Adam Lesinski
626b3dbf74 AAPT2: Clean up R JavaDoc generation
- Don't generate private attributes in public R.java
- Strip out @SystemApi from comment when generating @android.annotation.SystemApi
- Only emit a single line (up to the first period) of an attribute's comment within
  a styleable's attribute table.

Change-Id: Id6316a6861540325934133958939a12074ad4428
2016-04-07 16:26:14 -07:00
Adam Lesinski
f22df48067 Merge "AAPT2: Enable windows build and make sure it builds" into nyc-dev 2016-04-07 17:03:55 +00:00
Adam Lesinski
c728c3daba AAPT2: Allow <protected-broadcast> and <eat-comment> in AndroidManifest.xml
Change-Id: I38c49a2a31e560dec963d44d94e067035fd59150
2016-04-06 17:40:25 -07:00
Adam Lesinski
803c7c8079 AAPT2: Enable windows build and make sure it builds
Mingw32 4.8 is kind of picky with macros and some complicated template
stuff. Luckily there was another way to represent the
SFINAE code that works on all platforms. Yay!

Change-Id: Idc2e38f47bfdc57b394550bfa0f53cc0b825df25
2016-04-06 16:24:02 -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
3524a23edb AAPT2: Add option to add JavaDoc annotations to Java classes
Change-Id: I7ee8c20cdd91380927a65c41097ffd3a6ffa2df5
2016-04-04 12:42:05 -07:00
Adam Lesinski
6cbfb1de49 AAPT2: Change how we generate Java classes
Previously we would be writing out the Manifest.java file as we
processed the AndroidManifest.xml. This would lead to empty
Manifest classes if there were no permissions or permission groups
defined in the AndroidManifest.xml.

This would pose problems for processes that checked for public classes
and considered them part of the API (support lib).

Now we collect the structure of the Java class in memory before deciding
if a file should be created.

Change-Id: I6b909f28d74356414c6ef5ad005180d6ea5e44ca
2016-03-31 16:43:04 -07:00
Andrew Johnson
08a3fa7dea Merge "Removing assignments to localeScriptWasComputed in aapt." into nyc-dev 2016-03-31 13:52:10 +00:00
Andrew Johnson
299e488ee2 Removing assignments to localeScriptWasComputed in aapt.
On certain devices running Android M with unknown vendor
modifications. Setting the localeScriptWasComputed bit in
the resource parameters struct causes the translations
for many languages to fail to load. The app then
defaults to English.

This has been reported on the following devices:
Motorola XT1086, XT1096, and XT1586, HTC One, and Huawei
MediaPad 10 LINK.

This change works around the issue by never setting
localeScriptWasComputed in aapt and instead always
writing the default value of false.

Bug: 27872476
Change-Id: Id638d1d0e5f9dcb1c02e65d67667d76174c69b9e
2016-03-30 20:24:48 -04:00
Ying Wang
5e92c429ec Fix compilation using javac.
We still need to be able to compile all the Java source code in the tree
using javac, though the compiled code never ends up running on device.

Bug: 25958912
Change-Id: Id76663cdf768db579517515d7b7f51519b515fa8
2016-03-30 10:33:47 -07:00
Adam Lesinski
52db414176 Merge "AAPT2: statically link protobuf library" into nyc-dev 2016-03-11 21:33:34 +00:00
Adam Lesinski
330c57dbd1 Merge "AAPT2: Add descriptions of Attributes in Styleables for R.java" into nyc-dev 2016-03-11 09:16:44 +00:00
Adam Lesinski
7656554f91 AAPT2: Add descriptions of Attributes in Styleables for R.java
Change-Id: I69e7b73cbdfe4baf502348397435c501ae29ff5e
2016-03-11 00:22:52 -08:00
Adam Lesinski
f4ab612684 AAPT2: statically link protobuf library
Change-Id: I0bce42dfef2f11181c6407839875c97f88445dbd
2016-03-11 07:20:49 +00:00
Adam Lesinski
96917c25f0 AAPT2: Fix file::mkdirs when given absolute paths
file::mkdirs would try to extract the first part of the
path '/path' which would be the empty string ''. Mkdir would
fail creating the empty string directory.

Change-Id: Ice8ba92135f145f52f3663499a2c49eebe797328
2016-03-09 13:23:12 -08:00
Adam Lesinski
c53244db5e Remove accidentally committed core dump file
Change-Id: I610abfbce62585c25e98b5c36ac9f496861e66e7
2016-03-04 22:30:32 -08:00
Adam Lesinski
74605cd402 AAPT2: Emit proper doclava comments in R.java
Bug:25958912
Change-Id: I663f2eb5bd54e3c3288ce9bc186c928f0a014f93
2016-03-04 20:06:05 -08:00
Adam Lesinski
626a69f345 AAPT2: Support --no-version-vectors
Change-Id: I8029b2f9e2f7ab8e37a49565f95210f47a7be609
2016-03-04 17:02:42 -08: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
Roozbeh Pournader
7960898f6f Fix script-related parts of locale resource matching
Previously, a bit was kept to find if the script of a locale was
explicitly "provided" in a resource. This was not backward
compatible, and failed in some edge cases when the package was
created with older versions of AAPT that did not set the bit.

The cases would happen when the old resource had an explicit script
specified in its locale, but since the "provided" bit was not set in
the package, we would assume that the script was computed by us.

This CL replaces the "provided" bit with a "computed" bit, so the
default value of the bit (set to "false" for old packages) would be
correct.

Bug: 27156990
Change-Id: I99e7f1ad8f70c90e25ab3640ed34cc1a6f8d1d64
2016-03-03 15:19:37 -08:00
Adam Lesinski
144c5eabe5 AAPT2: Fix segfault when showing error in 9-patch
Change-Id: I8f457212efc27480758a7157455d98b5e316f772
2016-03-01 09:05:11 -08:00
Adam Lesinski
355f285ffd AAPT2: Implement density stripping and initial Split support
When a preferred density is supplied, the closest matching densities
will be selected, the rest stripped from the APK.

Split support will be enabled in a later CL. Command line support is still
needed, but the foundation is ready.

Bug:25958912
Change-Id: I56d599806b4ec4ffa24e17aad48d47130ca05c08
2016-02-17 18:17:25 -08:00
Adam Lesinski
5f7c461be6 AAPT2: Fix source output when error occurs in style
We were serializing the wrong Source when writing to protobuf

Change-Id: Ib65e962ebc1244ddf4af0e5666aaaebe5f7864a8
2016-02-12 23:38:08 -08:00
Adam Lesinski
e4bb9eb5af AAPT2: Introduce notion of 'product' to ResourceTable
This allows us to preserve the various product definitions during the compile
phase, and allows us to select the product in the link phase.

This allows compiled files to remain product-independent, so that they do not need
to be recompiled when switching targets.

Bug:25958912
Change-Id: Iaa7eed25c834b67a39cdc9be43613e8b5ab6cdd7
2016-02-12 22:21:48 -08:00
Adam Lesinski
59e04c6f92 AAPT2: Switch to protobuf for intermediate format
Without needing to conform to the runtime data format,
it is much easier to add new features such as debugging symbols
and carrying over product data to link time.

This also simplifies the runtime format parser and serializer,
which will change much less frequently than the protobuf intermediate
format.

Change-Id: I209787bbf087db0a58a534cb8511c51d21133e00
2016-02-09 19:59:17 +00:00
Adam Lesinski
6a008170cb AAPT2: Support -c configuration filtering
Change-Id: I1e5855ca73440bdc30c21bcbc1dfdd31a9842363
2016-02-02 17:02:58 -08:00
Adam Lesinski
8900aa8b44 AAPT2: Add -x and -z flags to minimize changes in build scripts
The -z flag will be supported soon anyway and -x is legacy.

Change-Id: I710467d35066d267dea8dfe7c521737fc768ede9
2016-01-25 22:48:15 -08:00
Adam Lesinski
ac7c606c90 Merge "AAPT2: Allow specifying non-final IDS when building 'legacy' style libraries" 2016-01-22 22:12:01 +00:00
Adam Lesinski
ef9c50120d AAPT2: Allow specifying non-final IDS when building 'legacy' style libraries
Real libraries will be built correctly, but since we are not doing that
yet, support the old way and allow a flag --non-final-ids to remove
the final modifier from R.java.

Change-Id: Iad55fb9140e55dbb0f41d0d55f2e2bd958294c8e
2016-01-22 14:09:53 -08:00
Roozbeh Pournader
2d05094209 Merge "Implement smarter locale resource selection" 2016-01-21 22:17:31 +00:00