9 Commits

Author SHA1 Message Date
Adam Lesinski
90919978e7 DO NOT MERGE: AAPT2: Allow undefined resources (placeholders)
A resource defined like so:

<item type="drawable" name="foo" />

should be assigned the value @null.

The only exception is for <string> resources, which are given the
empty string value (since <string></string> is ambiguous). The decision
to use "" is based off the fact that old AAPT used to assign "" to all
undefined resources, even non-string ones.

Bug: 38425050
Test: make aapt2_tests
Change-Id: Ib3e0f6f83d16ddd8b279c9fd44a07a37867b85e9
2017-06-02 16:51:59 -07:00
Adam Lesinski
5924d8c9ab AAPT2: Allow merging of Style attributes from overlays
Previously style overlays would completely override an existing style.
To be compatible with AAPT, styles now merge with the overlay, allowing
the overlay's attributes and parent to take precedence.

Bug: 38355988
Test: make aapt2_tests
Change-Id: Id25c7240050a43e6a4a177c6e3d51e048d0cceb5
2017-05-31 10:09:06 -07:00
Adam Lesinski
c744ae8aca AAPT2: Implement attribute compat versioning
This change defines some hardcoded rules to degrade
attributes in newer SDKs to specific older attributes.

An attribute with a degrade rule will generate a new XML for the API
in which the attribute resulting from the degradation was introduced.

Since API 22 (Lollipop MR1), attributes are correctly ignored and do
not need to be versioned. In XML files defined for APIs 22+, the
original and degraded attributes coexist in the same XML file.

One such example is paddingHorizontal, introduced in API 26.
paddingHorizontal degrades to paddingLeft and paddingRight, which
were both introduced in API 1.

Bug: 35763493
Test: make aapt2_tests
Change-Id: I4aa8755a9ee2c0cc5afdc55c3d30093fd3a47f3d
2017-05-24 15:14:29 -07:00
Adam Lesinski
d0f492db03 AAPT2: Share split functionality between link and optimize
Generating splits should be possible to do from the optimize command.
This means that a lot of infrastructure around split APKs can be
shared by both the optimize and link phase.

Bug: 35925830
Change-Id: Ia88b9e4bff300a56353b2f7a4a2547c8eb43a299
Test: manual
2017-04-10 11:59:18 -07:00
Adam Lesinski
06460ef0d7 AAPT2: Fix up file IO
This also enables an AAPT behavior that CTS tests have
come to depend on.

Small files that compress negatively (get larger) are stored
uncompressed. Some CTS tests assume this and try to open these
files by mmapping them, which is only possible if they are
uncompressed.

Bug: 35461578
Test: make aapt2_tests
Change-Id: Id622a6150fe72477ad65d67d1bad897a8ee2ffb9
2017-03-20 16:53:46 -07:00
Adam Lesinski
d48944a745 AAPT2: Rename strip phase to optimize
- Allow resource deduping, version collapsing, and sparse resource
  encoding.

Test: manual
Change-Id: Ia4aa892ab5b06ba1d5ea4a6efb51b00bc3a980c4
2017-02-22 11:41:55 -08:00
Pierre Lecesne
8a7b4cb992 Backbone of the new aapt2 strip command.
The strip command takes an APK as argument and a --target-densities flag which
contains the list of screen densities for which to optimize the APK. All
the resources that would be unused for a device having the given
densities are stripped from the APK leaving only the ones actually being
used.

Test: Manual.

Change-Id: I68368b00876a18ccdbbfc0a8dd265bd361117933
2017-02-01 18:49:19 +00:00
Pierre Lecesne
ff759e6a6e Moving the LoadedApk class to its own file.
Test: Unit tests pass.

Change-Id: Id706f9ad1f3406bb73a60a33139a04745d5d72c0
2017-02-01 00:31:55 +00:00
Fabien Sanglard
191602091b AAPT2: Convert Android.mk to Android.bp
Change-Id: I6c563993b57e3f04165ca57743f9a2878aba556c
2017-01-13 18:56:55 -05:00