218 Commits

Author SHA1 Message Date
Zak Cohen
1a6acdbb86 Introduce new UI_MODE_TYPE_VR_HEADSET and qualifier.
Bug: 30989383
Test: Unit test for aapt2
Change-Id: I66dc65af6327b94fed74538bee08cada0b8be4fa
2017-01-11 11:44:47 -08:00
Adam Lesinski
38665547bb AAPT2: Treat non-AAPT attributes as Attributes with no format specified.
Attributes in XML like "class" should be treated as attributes with no
format specified. That means that something like 'version="1"' will
be interpreted as an Integer value instead of as a string.

This is more in line with the old AAPT behaviour.
Bug: 30763349
Test: make libaapt2_tests

Change-Id: I02fe41617e3c62c354714056198ef480d62afee7
2016-12-28 12:40:35 -05: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
Tamas Berghammer
67387af732 Merge "Update package names to work with the proto3 compiler" 2016-11-09 13:38:58 +00:00
Adam Lesinski
f96789d37c Merge "Add font type to AAPT2" 2016-11-08 23:03:58 +00:00
Tamas Berghammer
383db5ebcc Update package names to work with the proto3 compiler
Bug: b/28974522
Change-Id: I5f3adf4946ee4ba1e09e4f40afe83c151405972a
2016-11-08 14:06:09 +00:00
Paulo Casanova
a256408b24 Renamed Aapt2.java to Aapt2Jni.java.
See http://ag/1590668 for a discussion.

Test: Done in tools
Change-Id: I3bfced0da98ab24531c1c1a79970841b32bfa1fa
2016-11-04 11:28:44 +00:00
Paulo Casanova
573cccfea7 Merge "Updated JNI interface." 2016-11-03 18:39:04 +00:00
Paulo Casanova
b555b59f2e Updated JNI interface.
Added new "ping" method used to detect if the shared
library has already been loaded.

Fixed a few bugs in the implementation (and now it works
from the Java side).

See http://ag/1590668 for the implementation on devtools.

Test: Done on the tools side
Change-Id: Ifa41073dc3b6ac69cdb9f77e655bf261c3b4c3d1
2016-11-03 10:14:42 +00:00
Paulo Casanova
3497b26507 Added Windows support for aapt/JNI.
This includes copying and slightly modifying
libnativehelper's ScopedUtfChars' implementation.

Test: Done in studio-master-dev
Change-Id: I2aacc67b444668478aaa5bb0db991a201c571d1f
2016-11-03 09:39:43 +00:00
Adam Lesinski
c0c366394c Add font type to AAPT2
Test: make libaapt2_tests AaptTestAppOne
Change-Id: I8fbf01675a218cc3c0b59598b6b1ec173851e946
2016-10-27 18:09:00 -07: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
Paulo Casanova
418063c63f Merge "Added JNI interface for aapt2." 2016-10-22 08:19:19 +00:00
TreeHugger Robot
b366402a68 Merge "AAPT2: Ensure string pool ordering is compact" 2016-10-22 00:37:20 +00:00
Adam Lesinski
b54ef10f55 AAPT2: Ensure string pool ordering is compact
Keep styledstrings at the beginning of the StringPool
to reduce the padding in the StyledString array.

Bug:32336940
Test: manual
Change-Id: Iec820c21a54daac40ecc3b2f87517a0f1efc9d3d
2016-10-21 13:51:59 -07:00
TreeHugger Robot
577e66cc43 Merge "AAPT2: Fail compile on bad output file/dir" 2016-10-21 03:04:12 +00:00
Adam Lesinski
dfaecafbe9 AAPT2: Fail compile on bad output file/dir
Test: manual
Change-Id: I2578e32c52430a62df942822ddf6bd3f06357bce
2016-10-20 17:08:51 -07:00
TreeHugger Robot
12bfe65410 Merge "AAPT2: Error on uncompiled XML or PNG files in link phase" 2016-10-20 23:58:15 +00:00
Adam Lesinski
6a396c1abb AAPT2: Error on uncompiled XML or PNG files in link phase
Incorrectly passing text XML and unprocessed PNG files to
the AAPT2 link phase should raise an error.

Test: manual incorrect invocation of aapt2
Change-Id: Iab47f99bc378b5d1c4f4d87098f08243b9a4dc6a
2016-10-20 14:40:49 -07:00
George Burgess IV
092db3c88a Merge "Fix a static-analyzer warning." am: 63b4f6f5db am: ea4423b181
am: 281e9f30c0

Change-Id: If34a4265ceb5bc6f4bf31c35e82270f90e970457
2016-10-20 19:35:45 +00:00
George Burgess IV
ea4423b181 Merge "Fix a static-analyzer warning."
am: 63b4f6f5db

Change-Id: I85fd6d25733d59da76eb0bab381fdbd3b5a0430d
2016-10-20 19:19:15 +00:00
Paulo Casanova
255960857d Added JNI interface for aapt2.
Test: None (tests will be made on the Android Studio Tools project)
2016-10-20 12:03:34 +01: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
George Burgess IV
56f5f7b79b Fix a static-analyzer warning.
frameworks/base/tools/aapt2/util/Files.cpp:81:21: warning: Null pointer
passed as an argument to a 'nonnull' parameter
     while ((entry = readdir(dir))) {

Bug: None.
Test: Warning no longer appears.
Change-Id: If242598405e995928378ce317a2e909654e1e985
2016-10-13 15:52:34 -07:00
Elliott Hughes
56f823be9a Merge "Rely on the platform -std default." am: 66f15cc01b am: 5a989a504a am: 39ad1b92fa
am: 437b8c95a8

Change-Id: Idacd1cad6e0e241404c99b680974aae2b8f81926
2016-10-10 17:42:08 +00:00
Elliott Hughes
437b8c95a8 Merge "Rely on the platform -std default." am: 66f15cc01b am: 5a989a504a
am: 39ad1b92fa

Change-Id: Iec4bca8e96c776d61c5da5540a74acc6773c2bce
2016-10-08 22:03:56 +00:00
Elliott Hughes
c08e32e0be Rely on the platform -std default.
Bug: http://b/32019064
Test: builds
Change-Id: I7180f1eb539ff8cbe33832d010775f053a922946
2016-10-07 15:57:17 -07:00
Adam Lesinski
edba941064 AAPT2: Ensure PNG endianness in 9-patch serialization
9-patch serialization requires PNG endianness

Bug:31942900
Test: manual + added serialization test to libaapt2_tests
Change-Id: Iea521718f88e80d3fa7a8723a47584973738748a
2016-10-04 17:50:19 -07:00
Adam Lesinski
ffa9656223 Merge "AAPT2: Refactor PngCrunching" 2016-10-03 21:22:28 +00:00
Alexandria Cornwall
77788eb4cf AAPT2: Add dominator tree analysis and resource removal
Added dominator tree analysis of resource configurations for each
resource entry to allow deduping of resource entries if:

1. The configuration for the resource entry's value is dominated by
a configuration with an equivalent entry value.

2. All compatible configurations for the entry (those not in conflict
and unrelated by domination with the configuration for the entry's
value) have an equivalent entry value.

Bug: 30051199
Test: make libaapt2_tests && libaapt2_tests
Change-Id: I66468d3014a2d6097a94b039ac1028f9f461c7d3
2016-09-30 18:27:13 -07:00
Adam Lesinski
21efb6827c AAPT2: Refactor PngCrunching
PngCrunching now has a slightly better heuristic of choosing to encode
an image as a palette or RGB. For small images, RGB compresses much better
than a palette.

The original PNG is used as-is (minus some optional chunks being stripped)
if the resulting crunched PNG is larger than the original.

9-patch handling is abstracted away from PNGs, paving the way
for other 9-patches, like WebP.

TODO: handle PNGs with 9-patch chunks already present, which
should just be passed through. This will allow for 3rd party
tools to generate 9-patches.

TODO: implement cheap transparency: when one color is used to represent
transparent, and all other colors are opaque.

Bug:30053276
Change-Id: I5167f53b91d1efa462d9f03d6b9108d9b541c0c1
2016-09-29 15:28:52 -07:00
Paulo Casanova
b896ae7267 Merge "Added building libaapt2_jni.so." 2016-09-27 21:33:56 +00:00
Paulo Casanova
c7ca55e27b Added building libaapt2_jni.so.
Change-Id: Ica2769c08b4bb5c6cceebb8052c0dd7817ef4586
2016-09-27 18:34:54 +01:00
Adam Lesinski
a0b929d27f AAPT2: Allow <compatible-screens><screen> in AndroidManifest.xml
Change-Id: I1e7c7211be1d9caea4174f7cac067c2565879d04
2016-09-19 09:50:45 -07:00
Adam Lesinski
8c3f31f022 AAPT2: Fix issue with styled string indices
Styled strings use spans to denote which part
is styled (<b>, <i>, etc). Spans are simply a range
of indices into the original string.

In Java, we use String and its internal representation, meaning
we must encode the indices using UTF16 lengths.

When the internal AAPT2 representation of strings switched to UTF8,
the indices also began to index into the UTF8 string.

This change reverts the indices to use UTF16 lengths.

Bug:31170115
Change-Id: I07b8b5b67d2542c7e0a855b601cdbd3ac4ebffb0
2016-09-07 13:45:13 -07:00
Adam Lesinski
5cb0530ca4 AAPT2: Update version and readme
Update version to 2.2 and update readme to reflect added
support for inline complex XML resources.

Change-Id: If825c96541952e95860d34390c6c36704a24129b
2016-09-06 17:34:06 -07:00
Adam Lesinski
871f2f5fc2 Merge "AAPT2: Add Inline Complex XML support" 2016-09-02 18:49:46 +00:00
Adam Lesinski
5eeaaddffd AAPT2: Add Inline Complex XML support
See: https://developer.android.com/guide/topics/resources/complex-xml-resources.html

Change-Id: I8274c85e25cabf90423141c228697e873167d136
2016-08-31 18:32:34 -07:00
Adam Lesinski
96692047e6 Merge "AAPT2: Revert warning when merging packages" 2016-08-31 20:18:19 +00:00
Adam Lesinski
a6ad7d5cc3 Merge "AAPT2 tools: Fix logging in resource file fixer" 2016-08-31 00:55:53 +00:00
Colin Cross
7fd4eb7ff7 Merge "Replace libziparchive-host with libziparchive" am: 611e205bbe am: 8c8bb25089 am: 63dc310e6a
am: e3cd4b394c

Change-Id: Icc088a0cdd6a2ebc2b7bedb719ad7220d947273d
2016-08-31 00:29:35 +00:00
Adam Lesinski
198cb0f048 AAPT2 tools: Fix logging in resource file fixer
Change-Id: I5113012229005c94e466f43a30932ebdc74d76fc
2016-08-30 15:07:50 -07:00
Adam Lesinski
085f495747 AAPT2: Revert warning when merging packages
A compiled ResourceTable may contain multiple packages.
When referencing a framework attribute, for instance,
the compile phase has no idea if that attribute is a USE
or a DECLARATION, like so:

  <declare-styleable name="Foo">
    <item name="android:id" />
  </declare-styleable>

If this file is compiled with the package 'android', then this
is a declaration. If it is compiled with the package 'com.foo',
this is a reference that must resolve at link time.

Since this is common, warning that the package 'android' is being
ignored during the merge phase is incorrect behaviour.

The warning was antroduced in ag/1363992

Change-Id: I09254d79ac379439face177eb724df882d1d0ce1
2016-08-30 14:25:51 -07:00
Adam Lesinski
5c3464c75f AAPT2: Fix merging of styleables the right way
Styleables should only be merged when processing overlays.
This moves the styleable merging code out of ResourceTable
and into TableMerger.

Change-Id: I3aae05cf4dd875cd25ac2ac744b61194409b2fee
2016-08-26 19:40:50 -07:00
Colin Cross
e3cd4b394c Merge "Replace libziparchive-host with libziparchive" am: 611e205bbe am: 8c8bb25089
am: 63dc310e6a

Change-Id: I645d077dd656f84446f77fd91c169fd7b977e661
2016-08-26 20:40:27 +00:00
Colin Cross
9a1a3bcb16 Replace libziparchive-host with libziparchive
libziparchive-host is no longer necessary, and mixing libziparchive-host
and libziparchive can cause ODR violations.

Change-Id: I623c0c5579e28f26a6e1db7bd953f33ed1ca68cd
2016-08-26 11:15:17 -07:00
Martijn Coenen
2cc64692ce Merge changes from topic 'utf' am: 0a357a1a73 am: de8a6a66f6
am: 1657493c22

Change-Id: Ie675738a4f9042929d1ffb5e1ffcc7bbb5c7b217
2016-08-25 20:31:31 +00:00
Sergio Giro
d90d8d615a Add bound checks to utf16_to_utf8
Test: ran libaapt2_tests64
Bug: 29250543
Change-Id: I1ebc017af623b6514cf0c493e8cd8e1d59ea26c3
(cherry picked from commit 4781057e78f63e0e99af109cebf3b6a78f4bfbb6)
2016-08-25 12:19:12 +02:00
Sergio Giro
8f7b8a1f6c Unicode: specify destination length in utf8_to_utf16 methods
Change-Id: I5223caa7d42f4582a982609a898a02043265c6d3
2016-08-25 12:04:40 +02:00