324 Commits

Author SHA1 Message Date
Adam Lesinski
54376bbd4b Merge "DO NOT MERGE: AAPT2: Allow undefined resources (placeholders)" into oc-dev
am: 2f84c4715d

Change-Id: I266b8648e9aa292befa02c4e7dc0ce54f0b26e21
2017-06-05 17:54:37 +00:00
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
3c860ed41d Merge "AAPT2: Allow any value type for <item> without format attr" into oc-dev
am: 1ac325e4d5

Change-Id: I1b1180f2b33a077b2c46a8466c58d83ed618576e
2017-06-02 02:35:07 +00:00
Adam Lesinski
e597d68d33 AAPT2: Allow any value type for <item> without format attr
TO bring AAPT2 behavior in-line with AAPT, <item> has a default
format of "any", and only becomes restricted with an explicit format
attribute.

Bug: 62260121
Test: make aapt2_tests
Change-Id: Ife416f520e6c2710bb30e3ba3f2d4463794bfa06
2017-06-01 17:16:44 -07:00
Adam Lesinski
ad227a8086 Merge "AAPT2: Update --no-version-vector list" into oc-dev
am: f296105e22

Change-Id: I0cde63dfd73b50debdc56f549f7adb1318f05309
2017-05-31 21:15:32 +00:00
Adam Lesinski
b5cdbdfcf8 Merge "AAPT2: Allow merging of Style attributes from overlays" into oc-dev
am: f42c86660d

Change-Id: I4a52a16fff3d544d8d7d63d8a482ba7e2111d01a
2017-05-31 21:12:58 +00:00
TreeHugger Robot
f296105e22 Merge "AAPT2: Update --no-version-vector list" into oc-dev 2017-05-31 20:49:02 +00:00
Adam Lesinski
f42c86660d Merge "AAPT2: Allow merging of Style attributes from overlays" into oc-dev 2017-05-31 20:48:06 +00:00
Adam Lesinski
41ea44f63d AAPT2: Update --no-version-vector list
Keep in sync with AAPT. Since gradle is moving to use AAPT2
by default, updates to AAPT will no longer be necessary and
this will be the authoritative list until a more programmatic
solution presents itself.

Bug: 62211148
Test: manual
Change-Id: Id9232c9fb730c50e4850887fa0f5da82574ca900
2017-05-31 10:23:58 -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
ce1e415d55 Merge "AAPT2: Fix <add-resource> tag for overlays" into oc-dev
am: 8255ced3f5

Change-Id: Icc420eea48a8379723c0bc84a5f30c03ac2a2492
2017-05-30 20:53:38 +00:00
Adam Lesinski
c69611fd86 Merge "AAPT2: Follow symlinks when compiling" into oc-dev
am: 6ea61f9c6d

Change-Id: I18dc95b8adf503e0bf72e5b48036945dc95312de
2017-05-27 01:51:55 +00:00
Adam Lesinski
4488f1c74a AAPT2: Fix <add-resource> tag for overlays
Bug: 38355988
Test: make aapt2_tests
Change-Id: Iea8887f55f8ceb2c15bd963405fd132916173c0c
2017-05-26 17:38:34 -07:00
Adam Lesinski
2354b56837 AAPT2: Follow symlinks when compiling
Bug: 62144459
Test: make AaptSymlinkTest
Change-Id: Idb3ab1ece17c52bb4fd174ec4c08a9e173289e55
2017-05-26 16:56:34 -07:00
Adam Lesinski
138d2a65b3 Merge "AAPT2: Implement attribute compat versioning" into oc-dev
am: e229113d46

Change-Id: I0200771f675cdfa69c458c374d3c16b0d91c5756
2017-05-26 18:49:11 +00: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
0196460f27 Merge "AAPT2: Ignore trailing data after IEND chunk in PNG" into oc-dev
am: 2d885e942d

Change-Id: Ic1c24dd55a4d6258533e57cea957a775e03013df
2017-05-18 17:42:44 +00:00
TreeHugger Robot
2d885e942d Merge "AAPT2: Ignore trailing data after IEND chunk in PNG" into oc-dev 2017-05-18 17:30:26 +00:00
Adam Lesinski
e768ad3708 Merge "AAPT2: Respect format attr in <array> resource" into oc-dev
am: dc6da8b4df

Change-Id: Ic7aa094d3d663d98fa4bc20eaf436f1f453da5d7
2017-05-17 23:11:04 +00:00
Adam Lesinski
dc6da8b4df Merge "AAPT2: Respect format attr in <array> resource" into oc-dev 2017-05-17 22:52:25 +00:00
Adam Lesinski
9d6a0d73e6 Merge "AAPT2: Update locale script filtering logic" into oc-dev
am: 3cd6e0bee5

Change-Id: Ie5377066de50d828f9f0a183c9dab4ee41f433eb
2017-05-17 19:28:43 +00:00
Adam Lesinski
13308bcdf6 AAPT2: Update locale script filtering logic
AAPT got an update to its locale script filtering logic that
dealt with enabling the removal of specific locales like
b+sr+Latn. Update AAPT2 to do the same.

Bug: 28055669
Bug: 29412034
Test: aapt2_tests
Change-Id: I3315c0814796cff05dfa1032d66d0306fe2b12bc
2017-05-16 15:28:36 -07:00
Adam Lesinski
d5fd76a2ff AAPT2: Respect format attr in <array> resource
Bug: 38152130
Test: make aapt2_tests
Change-Id: I84f352afb1a8fd2f329354f789aaa36c5ef88e47
2017-05-16 12:18:53 -07:00
Adam Lesinski
cc73e990e5 AAPT2: Ignore trailing data after IEND chunk in PNG
libpng seems to do the same, so our chunk filter should not care what
comes after.

Bug: 38169876
Test: manual
Change-Id: I020ddfe29ac3eb4d5ef9ace5611c6f6497de443d
2017-05-15 13:07:32 -07:00
Adam Lesinski
25b63c7bb8 Merge "AAPT2: Allow <uses-permission-sdk-23> in manifest" into oc-dev
am: 0d11c91d9e

Change-Id: I27d82f39f3063a9d03a5e4973c45c39e7f0054f6
2017-05-13 00:04:25 +00:00
Adam Lesinski
4b585db64f AAPT2: Allow <uses-permission-sdk-23> in manifest
Bug: 38269610
Test: build tools/aapt2/integration-tests/AppOne
Change-Id: I1d0b87aa36f6bf82aab146339acf8848166b218d
2017-05-12 15:25:50 -07:00
Adam Lesinski
71aab90db2 Merge "AAPT2: Add option to disable PNG crunching" into oc-dev
am: fb194bb81c

Change-Id: Ie471641c9b5fdb38c9623cc35cb3cc41c05c28a5
2017-05-11 19:06:18 +00:00
Adam Lesinski
fb194bb81c Merge "AAPT2: Add option to disable PNG crunching" into oc-dev 2017-05-11 18:39:05 +00:00
Adam Lesinski
28e6c0bac2 AAPT2: Add option to disable PNG crunching
When compiling, a developer may want to disable PNG crunching
for a specific set of PNGs.

Bug: 37729284
Test: manual
Change-Id: I134f208f8bb212df07a4eef65b467985a6443375
2017-05-10 15:00:10 -07:00
Adam Lesinski
84da7cdafe Merge "AAPT2: Ignore namespaced elements in AndroidManifest.xml" into oc-dev
am: dea0438385

Change-Id: I7868395090d2d49eeab80b61a73498f7535a57ab
2017-05-09 20:19:43 +00: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
Yi Kong
087e2d46ab Resolve merge conflicts of ccc5b9bbd02a to oc-dev-plus-aosp
Test: Build
Change-Id: I7d3d6bb4c436b2025a0293f9c6475855243f4dd9
2017-05-02 12:49:25 -07:00
Yi Kong
b1d8144ef0 SymbolComparator operator() is missing const
Clean up, no functionality change.

Test: build
Bug: 37752547
Change-Id: I7b6f368c0d0776f956a8b99353df7b23cbbc388d
2017-05-01 10:57:39 -07:00
TreeHugger Robot
7cf8ca95aa Merge "AAPT2: Fix typo in manifest validation expectation" into oc-dev 2017-04-30 14:31:17 +00:00
TreeHugger Robot
557a0c50a0 Merge "AAPT2: binary parser should be more lenient with files" into oc-dev 2017-04-29 21:39:29 +00:00
TreeHugger Robot
f6bc1402ed Merge "AAPT2: Fix string escaping" into oc-dev 2017-04-29 21:04:38 +00:00
TreeHugger Robot
53c9898e79 Merge changes I446fb6ab,Ife3bbd29 into oc-dev
* changes:
  Valid resource IDs may be negative
  AAPT2: Workaround for findViewById with package ID > 0x7f
2017-04-29 20:38:20 +00:00
Adam Lesinski
742888f0fd AAPT2: binary parser should be more lenient with files
Some APKs have file references that reference files that don't exist.

For now, just be lenient and ignore the files themselves.

Keep the actual reference until such a time as general resource
stripping is implemented.

Bug: 37749644
Test: manual
Change-Id: I773685acf41212405b71b064d64045fb4556dcfc
2017-04-28 15:34:52 -07:00
Andreas Gampe
3bf6389120 Aapt2: Fix png leak
do9Patch is leaking two rows of data.

Bug: 37782695
Test: ASAN_OPTIONS= SANITIZE_HOST=address m
Change-Id: Ibd2198919cd9c24f2de9f50b23c87753f2190708
2017-04-28 13:51:39 -07:00
Adam Lesinski
c10c0d0db2 AAPT2: Fix typo in manifest validation expectation
Change expected tag from grant-uri-permissions -> grant-uri-permission

Bug: 37714102
Test: manual
Change-Id: Ic0178b83fff8de961cb3fdfe38023eaf111237ee
2017-04-28 12:54:08 -07:00
Adam Lesinski
48448e8a31 AAPT2: Fix string escaping
We were processing escaped strings too early, before
parsing of values into types. Now the escaped strings get
processed when they are being flattened.

Bug: 37715376
Test: make aapt2_tests
Change-Id: Ic59aa2e3a20c40756c219752ff74b2a4f8a602ba
2017-04-28 12:51:23 -07:00
Adam Lesinski
1e4b0e54a3 AAPT2: Workaround for findViewById with package ID > 0x7f
The entire View code base checks IDs against View.NO_ID except
findViewById(), which checks to see if the ID is negative.

Any package ID > 0x7f is interpreted as a negative number in Java
(no unsigned ints), so this check prevents the use of IDs > 0x7f.

findViewById is final, so support library workarounds are not possible.

Instead, IDs (@id/foo) are just sentinels, their values don't matter.
If building for pre-O devices, rewrite any references to these IDs of
the for 0xPPTTEEEE, where PP > 7f, to 0x7fPPEEEE.

The symbol table will check for potential collisions against the base
APK, so this should be safe.

Bug: 37498913
Test: manual
Change-Id: Ife3bbd29db287757ef8a2ffd83053d97f1db2613
2017-04-28 12:47:48 -07:00
Chris Warrington
820d72adc0 AAPT2: Error reporting through JNI.
Rather than relying on stderr being wired correctly.

Test: Tests for JNI integration in studio-master-dev.
Change-Id: I1c7e7130bc4e56d61de259a9596bee3a6b3520fb
2017-04-28 10:06:38 +01:00
TreeHugger Robot
e7172ff9fb Merge "AAPT2: Add workaround for non-standard package IDs" into oc-dev 2017-04-27 23:45:44 +00:00
Adam Lesinski
4ca56978a9 AAPT2: Add workaround for non-standard package IDs
The dynamic ref table used to map build-time IDs to runtime IDs
is mainly used for shared resource libraries and has a few built-in
mappings (app 0x7f and framework 0x01).

Using a non-standard package ID like 0x80 causes a failure in package ID
lookup. The solution is to ship the dynamic_ref_table with an identity mapping
with any resource table that uses a non-standard package ID.

Adds some tests to ensure this works correctly.

Bug: 37498913
Test: make libandroidfw_tests
Test: make aapt2_tests
Change-Id: Ic3f67942384d34e7fdcbc94ded360e940e3ebc8a
2017-04-26 21:55:31 -07:00
TreeHugger Robot
b9dbee430d Merge "AAPT2: Add better error message when processing invalid files" into oc-dev 2017-04-25 15:26:24 +00:00
TreeHugger Robot
7beb895d75 Merge "AAPT2: Allow <path-permission> tag in <provider>" into oc-dev 2017-04-25 15:26:01 +00:00
Adam Lesinski
776aa959c7 AAPT2: Add better error message when processing invalid files
Instead of showing a failed mmap error, show a better error when a file
being compiled is a directory or other unsupported file type.

Bug: 37626838
Test: manual
Change-Id: Ib9acf5f48ab5da37e79411c6a9f37c51f00f925f
2017-04-24 22:19:53 +00:00
Adam Lesinski
25783cab0b AAPT2: Allow <path-permission> tag in <provider>
Fix a typo where the wrong tag name was expected under <provider>
in AndroidManifest.xml.

Bug: 37627250
Test: manual
Change-Id: I45afd09b4ff25feb320f7991e16c4172e20dd417
2017-04-24 22:18:48 +00:00
Adam Lesinski
b522f04bc2 AAPT2: Allow truncating of package names
ResTable_package header only allows 127 UTF-16 characters, so AAPT
would truncate the real package name to fit. AAPT2 would error-out
on any package name longer than 127 UTF-16 characters. This strictness
is not required except when building shared libraries, which use the
full package name as a way of identifying the runtime assigned
package ID to package name mapping.

Bug: 36940145
Test: make aapt2_tests
Change-Id: I7d2b7e50c7ab30c6a6c4f15d310e711f68e35091
2017-04-21 17:02:09 -07:00