Commit Graph

407 Commits

Author SHA1 Message Date
Shane Farmer
0a5b201156 AAPT2: Add a APK filtering.
Allow resource files to be removed from the final artifact based on the
density and locale configuration in the config file. The APK is split
along the density, locale and ABI axis. Each split is generated from the
original APK without modifying the original. The new resource table is
written back to the file system with unneeded assets etc removed.

Test: Unit tests
Test: Manually run optimize command against an APK and inspect results
Test: Installed split searchlite APK (after resigning) and ran on N6

Change-Id: If73597dcfd88c02d2616518585d0e25a5c6a84d1
2017-08-16 19:19:54 +00:00
Adam Lesinski
38ef937bad Merge "AAPT2: Make sure to fail when XML linking fails" 2017-08-15 18:33:47 +00:00
Steven Moreland
f1cd35cbe1 Merge "Merge "Revert "aapt2_jni: use proper nativehelper headers"" into stage-aosp-master am: e59c1b1b50 am: bc6d35e698 am: 8e22616fb8" into oc-mr1-dev-plus-aosp
am: aa2fa959ee

Change-Id: I1e139e90fafc3c0fd43d3bd08d69c6e493975372
2017-08-12 04:07:25 +00:00
Steven Moreland
d4cb8788f2 Merge "Merge "aapt2_jni: use proper nativehelper headers" into stage-aosp-master am: e17aa09136 am: 1c7ae6507e am: 5c65590564" into oc-mr1-dev-plus-aosp
am: a750dce30b

Change-Id: I2ab40e21bdd678c33ae4287bfc693cdd8bb33ed8
2017-08-12 03:48:38 +00:00
Steven Moreland
4126f4651f Merge "Revert "aapt2_jni: use proper nativehelper headers"" into stage-aosp-master am: e59c1b1b50 am: bc6d35e698
am: 8e22616fb8

Change-Id: Ie23fe137a0cc6df2be34c1c57bb550631654d61b
2017-08-12 03:44:52 +00:00
Steven Moreland
39c5f424b4 Merge "aapt2_jni: use proper nativehelper headers" into stage-aosp-master am: e17aa09136 am: 1c7ae6507e
am: 5c65590564

Change-Id: Ie3c13f03658a2a5ac8fae7edadb4833b86716386
2017-08-12 03:32:29 +00:00
Steven Moreland
8e22616fb8 Merge "Revert "aapt2_jni: use proper nativehelper headers"" into stage-aosp-master am: e59c1b1b50
am: bc6d35e698

Change-Id: Ida9cc1c9c2a64920ce094f2305e2e7bc1abaec1b
2017-08-11 22:17:51 +00:00
Steven Moreland
5c65590564 Merge "aapt2_jni: use proper nativehelper headers" into stage-aosp-master am: e17aa09136
am: 1c7ae6507e

Change-Id: I31224c1a0bef8074c4d569137b3134d28039ee58
2017-08-11 22:06:57 +00:00
Steven Moreland
fe028b0d0f Revert "aapt2_jni: use proper nativehelper headers"
This reverts commit 8eebd694e5.

Reason for revert: TH skipped PS run

Change-Id: Iab0e71d985819880146476ba3648e8b94201a839
2017-08-11 21:38:39 +00:00
Steven Moreland
8eebd694e5 aapt2_jni: use proper nativehelper headers
libnativehelper exports headers under nativehelper. These were
available before incorrectly as global headers in order to give
access to jni.h.

Test: modules using aapt2_jni find headers
Bug: 63762847
Change-Id: Id51354d533bfef66ecd71f5d89599b8adc688c1f
2017-08-11 11:01:23 -07:00
TreeHugger Robot
a27ca01955 Merge "AAPT2: Forward @TestApi in resource comments to JavaDoc" 2017-08-09 18:32:13 +00:00
Adam Lesinski
49f0aa41f1 Merge "AAPT2: Fix windows unicode path issues" 2017-08-08 22:18:55 +00:00
Adam Lesinski
09f4d706d9 AAPT2: Forward @TestApi in resource comments to JavaDoc
Bug: 37894597
Test: make aapt2_tests
Change-Id: I357fb84941bfbb3892a8c46feb47f55b865b6649
2017-08-08 10:51:23 -07:00
Adam Lesinski
e2ba325d27 Merge "AAPT2: Fix typo in Config parsing" 2017-08-08 17:41:00 +00:00
TreeHugger Robot
1c9f0fb7ec Merge "AAPT2: Change proto format to reduce usage of StringPool" 2017-08-08 00:26:31 +00:00
Adam Lesinski
c0a5e1e600 AAPT2: Make sure to fail when XML linking fails
Bug: 64367402
Test: manual
Change-Id: I3082887f5e449d8d0dac2aad93a834eb346008ba
2017-08-07 11:56:32 -07:00
Adam Lesinski
0853500201 AAPT2: Change proto format to reduce usage of StringPool
The StringPool class is a binary blob and makes it difficult to
modify the proto files from external tools (like bundle-tool).

Size increase of full build is negligible.

Test: make aapt2_tests
Change-Id: I984755170c315730ab751b51133f8fb2f614f6af
2017-08-07 11:45:46 -07:00
Adam Lesinski
13c0c74888 AAPT2: Fix typo in Config parsing
The 'any' syntax of a configuration is rarely used so this has not been
an issue in the field.

Test: none
Change-Id: Icb9cb2d5ad061e3ea1c43dc1cd7ca2f222965cdc
2017-08-07 10:53:55 -07:00
Adam Lesinski
55f2761fc8 AAPT2: Add targetConfig to AndroidManifest.xml
Splits may include more/different configurations than they
were originally specified to include. This happens, for instance,
when a particular requested density doesn't exist. A fallback density
resource is chosen for the split.

This makes programmatic configuration targetting difficult, as the APK
may report that it has resources for multiple densities, while it was
meant to target only a specific density.

This change encodes a comma separated list of the intended configurations
for the split in an attribute called 'targetConfig' on the <manifest> tag of
AndroidManifest.xml.

Test: manual
Change-Id: I3167e9341a434abc34ed2ddb8f740762b40b1ab7
2017-08-04 17:32:32 -07:00
Adam Lesinski
5b6ee11548 AAPT2: Ensure style strings are always first in StringPool
Move the styled strings to a separate section of the StringPool so
that sorting can never mess up the order of Styles.

Bug: 63570514
Test: make aapt2_tests
Change-Id: Id2ce1355b92be1bb31ce0daa7e54ae9b5b6c2ffe
2017-08-04 17:29:13 -07:00
Adam Lesinski
907399187e AAPT2: Disable locale domination for deduping
Locale deduping isn't straightforward, as parenting rules
change between platform versions and the selection
preference of a specific locale variant over the default
configuration lead to incorrect results at runtime.

Bug: 62409213
Test: make aapt2_tests
Change-Id: Iec8f1cfba7ae43c847d163529891fdc15f3db826
2017-08-04 17:23:14 -07:00
TreeHugger Robot
61cf5b68b5 Merge "Fix clang-tidy performance warnings in aapt2." 2017-08-04 17:17:45 +00:00
Adam Lesinski
efeb7af13b AAPT2: Fix windows unicode path issues
Mingw64 was being difficult, so instead of defining a wmain entrypoint,
the command line parameters are parsed manually using built-in Windows
methods that support Unicode. The results are converted to UTF8 and
handled just like the rest of the linux/mac version of the code.

This also removes dependencies on std::istream in favour of a
FileInputStream which calls the appropriate unicode version of
open to read a file.

No speed regressions found on Linux or MacOS.

Bug: 62336414
Bug: 63830502
Test: manual
Change-Id: I597da51e33729ed1b98bf246e7e773337fd3fee8
2017-08-03 17:33:52 -07:00
Chih-Hung Hsieh
4dc5812dc0 Fix clang-tidy performance warnings in aapt2.
* Use const reference parameter type to avoid unnecessary copy.
* Use more efficient overloaded string methods.

Bug: 30407689
Bug: 30411878
Test: build with WITH_TIDY=1
Change-Id: Iaa0a6f18f64cf573bee49dd1466281ea4d37b410
2017-08-03 16:28:10 -07:00
Adam Lesinski
292cece3b2 Merge "AAPT2: Ensure style strings are always first in StringPool" 2017-08-01 19:56:09 +00:00
Adam Lesinski
060b53d028 AAPT2: Ensure style strings are always first in StringPool
Move the styled strings to a separate section of the StringPool so
that sorting can never mess up the order of Styles.

Bug: 63570514
Test: make aapt2_tests
Change-Id: Id2ce1355b92be1bb31ce0daa7e54ae9b5b6c2ffe
2017-07-31 17:46:28 -07:00
Adam Lesinski
18dc03a9fd Cherry-pick from master: AAPT2: Fix JavaDoc first sentence extraction.
The old algorithm for detecting the first sentence of a JavaDoc comment
looked for the first occurence of '.'. This does not work when code or a
{@link android.R.styleable} link is encountered in the first sentence.

Switch to checking for whitespace characters after the '.' character.

Bug: 62900335
Test: make aapt2_tests , make ds-docs
Original change-Id: I8238f6a6304c9c2f92e2e576ca8962a59c2b20ea

Change-Id: Ie272d0d793d157f2a30f3ead20b2b53976661d33
2017-07-27 17:22:09 -07:00
Adam Lesinski
7e638bceb9 Merge "AAPT2: Fix JavaDoc first sentence extraction." 2017-07-27 18:15:18 +00:00
Adam Lesinski
c895688488 AAPT2: Fix processing of quotes in XML
When processing attributes in XML, quotes can't be used to mark a
section as whitespace preserving, so the assumption should be that the
entire string is whitespace preserving, which makes quote characters
literals.

Bug: 62840718
Bug: 62840406
Test: make aapt2_tests
Change-Id: I4afff02148b5b8e78833abf1f323c2f5325d6155
2017-07-26 20:41:34 +00:00
TreeHugger Robot
7ad5d91eb0 Merge "AAPT2: Add navigation type" 2017-07-26 02:13:09 +00:00
Adam Lesinski
3b84124edc AAPT2: Add navigation type
Test: build succeeds
Change-Id: I7d49366c7cc4a93c29bad4cb9f13eec23ad05bd2
2017-07-25 17:16:53 -07:00
Adam Lesinski
e967d3f6ac AAPT2: Fix JavaDoc first sentence extraction.
The old algorithm for detecting the first sentence of a JavaDoc comment
looked for the first occurence of '.'. This does not work when code or a
{@link android.R.styleable} link is encountered in the first sentence.

Switch to checking for whitespace characters after the '.' character.

Bug: 62900335
Test: make aapt2_tests
Change-Id: I8238f6a6304c9c2f92e2e576ca8962a59c2b20ea
2017-07-25 15:53:15 -07:00
TreeHugger Robot
6d72a4ea80 Merge "AAPT2: Add targetConfig to AndroidManifest.xml" 2017-07-25 03:18:27 +00:00
Adam Lesinski
3d6323961c AAPT2: Add targetConfig to AndroidManifest.xml
Splits may include more/different configurations than they
were originally specified to include. This happens, for instance,
when a particular requested density doesn't exist. A fallback density
resource is chosen for the split.

This makes programmatic configuration targetting difficult, as the APK
may report that it has resources for multiple densities, while it was
meant to target only a specific density.

This change encodes a comma separated list of the intended configurations
for the split in an attribute called 'targetConfig' on the <manifest> tag of
AndroidManifest.xml.

Test: manual
Change-Id: I3167e9341a434abc34ed2ddb8f740762b40b1ab7
2017-07-24 17:08:32 -07:00
Shane Farmer
1a21b8c041 AAPT2: Update ReplacePlaceholder for artifact name parser
Update the artifact name parser to ensure that duplicate placeholders
are treated as an error.

Also applied suggested changes from ag/2447777.

Test: ran unit tests
Change-Id: Iab8fd9d9b81aa3008177141256ecd16ef04b0c34
2017-07-25 00:01:18 +00:00
TreeHugger Robot
ac6efa3ae2 Merge "AAPT2: Document Format.proto" 2017-07-24 19:29:38 +00:00
Jeff Sharkey
6d626c24e3 Merge "Let's get a constant for O_MR1." 2017-07-20 03:20:22 +00:00
Jeff Sharkey
7beabc264b Let's get a constant for O_MR1.
Test: none
Exempt-From-Owner-Approval: HULK SMASH!
Change-Id: I440ebae4d0891d9044bbbfb5beaaaa98639aea98
2017-07-20 03:19:33 +00:00
Shane Farmer
9f0e7f1dba AAPT2: Parse artifact names from template.
Add a helper method to convert a templated artifact name to file name
based on the values present in an Artifact struct. The Artifact
validates that all required template paramters are present.

Test: Unit tests
Change-Id: Id97ff606bb41c72a31c2d769104966be9cbca1a0
2017-07-18 20:32:54 +00:00
Adam Lesinski
0c80895c20 AAPT2: Document Format.proto
Test: none
Change-Id: I6b05bcdece5a310201d3ab0790a4ea1d23698e96
2017-07-13 09:40:03 -07:00
Adam Lesinski
bb94f32a00 Revert "AAPT2: Auto-version adaptive-icon XML"
This reverts commit 5b7337f77c.

Bug: 63579299
Test: none
Change-Id: Ib617c4edfc16eeae3507b59b2debeae4f8bbf9a5
2017-07-12 07:42:01 -07:00
Adam Lesinski
f903d5f15a AAPT2: Bump version number to v2.18
Test: none
Change-Id: I6e3b4c95a7d7ba416ba368e5b19782dbffa04fd8
2017-07-10 04:19:28 -07:00
Adam Lesinski
fba0cf2950 AAPT2: Fix processing of quotes in XML
When processing attributes in XML, quotes can't be used to mark a
section as whitespace preserving, so the assumption should be that the
entire string is whitespace preserving, which makes quote characters
literals.

Bug: 62840718
Bug: 62840406
Test: make aapt2_tests
Change-Id: I4afff02148b5b8e78833abf1f323c2f5325d6155
2017-07-07 13:23:55 -07:00
Adam Lesinski
66ea840038 AAPT2: Accept Java unicode identifiers
Test: make aapt2_tests
Change-Id: I75a0e52d43b1785001bfe120eea7484f7bb4682b
2017-07-07 13:23:55 -07:00
Igor Viarheichyk
10da015d05 Merge "Improved word break for BiDi pseudolocalizer." 2017-07-07 16:42:39 +00:00
Igor Viarheichyk
4fb6516a55 Improved word break for BiDi pseudolocalizer.
Characted sequences \n and \t are now treated as word separators
by BiDi pseudolocalizer. This solves issues when text rendering
engine breaks a line in the middle of a text chunk marked with
RLM+RLO and PDF+RLM sequences.

Bug:34064580
Change-Id: I52e6018785fae25479fa167440f24c534b0e3253
Fixes:34064580
Test: make aapt2_tests
Test: Run aapt2_tests binary
2017-07-06 15:41:47 -07:00
Adam Lesinski
afcd59b443 Merge "AAPT2: Iterate over UTF-8 string by codepoints" 2017-07-06 22:37:45 +00:00
Adam Lesinski
dfbcd36afd Add adamlesinski@google.com as owner of AAPT2
Test: none
Change-Id: Ief971f7e85050164628d2e25bee888f035a93725
2017-07-06 11:47:17 -07:00
Adam Lesinski
549e437e14 AAPT2: Iterate over UTF-8 string by codepoints
Iterating over a UTF-8 string by codepoints ensures that
unicode characters do not get sliced. Otherwise the resulting
string could contain malformed characters.

Bug: 62839202
Test: make aapt2_tests
Change-Id: Ia0c44fbceb7dcfa11e77a1a77011da0f5466e342
2017-06-29 18:17:35 -07:00
Adam Lesinski
5b7337f77c AAPT2: Auto-version adaptive-icon XML
Auto version adaptive-icon XML to v26.

This change makes the logic for generating versioned resources
simpler by changing the comparison function of ResTable_config
to evaluate the sdkVersion property last, making configurations
that differ only in sdkVersion next to each other in a sorted vector.

Bug: 62316340
Test: manual (verified output of tools/aapt2/integration-tests/AppOne)
Change-Id: I977d45821722a65d2135efb4693304eacc565c9a
2017-06-28 11:20:17 -07:00