summaryrefslogtreecommitdiff
path: root/tools/aapt2/StringPool.cpp
AgeCommit message (Collapse)Author
2019-02-15Revert "Fix loaded apk string pool order"Ryan Mitchell
This reverts commit 4e9a922ede24f7f7bfe793321f7328623ee2a061. Reason for revert: <b/122518436> Change-Id: I3650b2c6c9bdfa69a3034f9ca49e95a9698c3cdd
2018-11-15Fix loaded apk string pool orderRyan Mitchell
Loading in an APk changed the ordering of strings in the string pool. When loading an apk, assign the strings to the same index as they are in the ResStringPool. Bug: 118831219 Test: "aapt2 dump strings left.apk" prints in the correct order, "aapt2 convert left.apk --output-format binary -o left_binary.apk" has entries in the correct order, and aapt2_tests Change-Id: I00014c02195f39c1152a110e90083d9b14e9216e
2018-07-02AAPT2: Encode 4-byte strings in Modified UTF-8Ryan Mitchell
Codepoints that are encoded to 4 bytes in UTF-8 are not allowed in Modified UTF-8. They instead should be encoded as surrogate pairs in the same way that CESU-8 allows for surrogate pairs. This will also cause 4 byte UTF-8 codes to be represented in 6 bytes. Bug: 37140916 Test: aapt2_tests Change-Id: I155dc24f166139d1d36a16bac088dcfcd59eb321
2018-04-18AAPT2: Modified StringPool uniqueness detection #2y
b/77862560 detected that when converting an apk to binary using aapt2, all resource ids of attributes that have been replaced with resource identifiers become set to the identifier of the first attribute. This is because the attribute names are all empty because the names are not necessary since the resource ids are present. The empty attribute names all map to the same string pool reference and cause all the ids to be the first empty string into the string pool. The ag/3897499 approach to fix the specified bug was extremely inefficient and caused hour long builds. This change takes advantage of the multimap data structure to do lookups efficiently. Bug: 77862560 Test: Converted apk in listed bug from proto to binary and observed correct resource ids and correct badging. Also built the Android tree to check for regressions in build time. Change-Id: I27a9ee4ffbed8b9ff6f238ad315cdf87b588947c
2018-04-16Revert "AAPT: Modified StringPool uniqueness detection"Ryan Mitchell
This reverts commit 35ecb89a8aa68f24d2e991df5bb9964ad15075dc. Reason for revert: <Long make duration (infinite loop)> Change-Id: I10d1cf53ca3054d40e23b06368ebaff6af69beab
2018-04-13AAPT: Modified StringPool uniqueness detectiony
b/77862560 detected that when converting an apk to binary using aapt2, all resource ids of attributes that have been replaced with resource identifiers become set to the identifier of the first attribute. This is because the attribute names are all empty because the names are not necessary since the resource ids are present. The empty attribute names all map to the same string pool reference and cause all the ids to be the first empty string into the string pool. Bug: 77862560 Test: Converted apk in listed bug from proto to binary and observed correct resource ids and correct badging. Change-Id: I635c13cd1ad7a395fe40a57198cfe5ec91602d01
2018-04-04Check the size of the strings in the StringPool before flattening.Ryan Mitchell
Test: Tested for normal functionality when string does not exceed maximum length and tests for detection of string that is too lonhg for UTF8i Bug: b/74176037 Change-Id: Ic71d3671a069e7012e8ca107e79e071499eebbf6 (cherry picked from commit a15c2a8957b9883cb293fdacaeabd7f2e037a0a5)
2017-10-18AAPT2: Ensure strings are sorted by configurationAdam Lesinski
Keep strings sorted by configuration so that strings likely to be selected (all match the same locale, for instance) are close together. Bug: 67958501 Test: make aapt2_tests Change-Id: Id17d93bf2e03ce408a6f619d3ea6dc313e393b76
2017-08-04AAPT2: Ensure style strings are always first in StringPoolAdam Lesinski
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-02-08AAPT2: Fix pseudolocalization to respect <xliff:g>Adam Lesinski
The XLIFF 'g' tag specifies content that should NOT be translated. AAPT2's pseudolocalization process should respect it. Bug:34064599 Test: make libandroidfw_tests Change-Id: Ice437d7f0ff246730ee04896fd035e2d846148fb
2017-01-17Move StringPiece to libandroidfwAdam Lesinski
libandroidfw needs to make use of StringPiece, so move it to libandroidfw and update all code referencing StringPiece in aapt2. Test: make libandroidfw_tests libaapt2_tests Change-Id: I68d7f0fc7c651b048d9d1f5e7971f10ef5349fa1
2016-10-26AAPT2: Rename to match new styleAdam Lesinski
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-19Use Google3 style guide with .clang-formatAdam Lesinski
Test: style change only, builds ok Change-Id: I885180e24cb2e7b58cfb4967c3bcb40058ce4078
2016-07-13AAPT2: Remove usage of u16stringAdam Lesinski
For legacy reasons, we kept around the use of UTF-16 internally in AAPT2. We don't need this and this CL removes all instances of std::u16string and StringPiece16. The only places still needed are when interacting with the ResTable APIs that only operate in UTF16. Change-Id: I492475b84bb9014fa13bf992cff447ee7a5fe588
2016-01-13AAPT2: Variety of small fixes to get the build workingAdam Lesinski
- Add option to rename package in AndroidManifest.xml - Support default versionName and versionCode - Accept True and False as valid booleans Change-Id: I400e350b9dcd0fd1c197d1929144299c7823617d
2015-10-16AAPT2: Separate out the various stepsAdam Lesinski
An early refactor. Some ideas became clearer as development continued. Now the various phases are much clearer and more easily reusable. Also added a ton of tests! Change-Id: Ic8f0a70c8222370352e63533b329c40457c0903e
2015-05-04Add namespace handling in attribute valuesAdam Lesinski
Previously, you could only reference namespace prefixes in attribute names: <View xmlns:appcompat="http://schemas.android.com/apk/res/android.support.v7.appcompat" appcompat:name="hey" ... Now you can also reference them in resource names within an attribute value: ... android:text="@appcompat:string/confirm" ... Which will be treated as "@android.support.v7.appcompat:string/confirm". Change-Id: Ib076e867a990c80cf877a704eb77cd1ef0b23b52
2015-04-15AAPT2: Add library supportAdam Lesinski
Change-Id: I307f56d9631784ab29ee4156d94886f9b2f25b30
2015-04-02AAPT2Adam Lesinski
First checking of AAPT2. The individual phases of AAPT2 work, but there are some missing pieces. For early testing we are missing: - Need to properly mark file references and include them in package - Need to package into zip Final AAPT for apps we are missing: - Need to crush PNGs - Need to parse 9-patches - Need to validate all of AndroidManifest.xml - Need to write align method to align resource tables for splits. Final AAPT for apps + system we are missing: - Need to handle overlays - Need to store comments for R file - Need to handle --shared-lib (dynamic references too). New AAPT features coming: - Need to import compiled libraries - Name mangling - R file generation for library code Change-Id: I95f8a63581b81a1f424ae6fb2c373c883b72c18d