summaryrefslogtreecommitdiff
path: root/tools/aapt2/StringPool_test.cpp
AgeCommit message (Collapse)Author
2020-11-17Revert^2 "libandroidfw hardening for IncFs"Ryan Mitchell
55ef6167a2c235bd88c7216238b2001b46795b79 Change-Id: I02d4890d181655dfd0a14c188468db512559d27b
2020-11-13Revert "libandroidfw hardening for IncFs"Ryan Mitchell
Revert "Move map_ptr to incfs namspace" Revert submission 12787270 Reason for revert: b/173250495 Reverted Changes: I5cd1bc8a2:libandroidfw hardening for IncFs Ice5dbcfb2:Move map_ptr to incfs namspace I29ccdc8ed:Do not cache bag parent stack until requested I1e9e9acaa:Cache resolved theme values Change-Id: Ib90ef68339710086df41e9abe0833a542d03a74f
2020-11-12libandroidfw hardening for IncFsRyan Mitchell
Migrate libandroifw to using incfs::util::map_ptr to prevent processes from crashing when parsing the resources.arsc, parsing compiled xml, files, and retrieving resource values. This change propagates incremental failures to the JNI level where they are raised as ResourcesNotFoundException. Performance of ResourcesPerfWorkloads without change (time in nanoseconds): [1/3] com.android.resources.perf.PerfTest#youtube: PASSED (11.883s) youtube_ns_median: 93812805 youtube_ns_standardDeviation: 4387062 youtube_ns_mean: 94455597 [2/3] com.android.resources.perf.PerfTest#maps: PASSED (11.265s) maps_ns_standardDeviation: 2997543 maps_ns_mean: 83480371 maps_ns_median: 82210941 [3/3] com.android.resources.perf.PerfTest#gmail: PASSED (24.963s) gmail_ns_median: 266141091 gmail_ns_standardDeviation: 3492043 gmail_ns_mean: 267472765 With change and verification forcibly enabled for all apks (including the framework-res.apk): [1/3] com.android.resources.perf.PerfTest#youtube: PASSED (11.646s) youtube_ns_median: 101999396 youtube_ns_standardDeviation: 4625782 youtube_ns_mean: 102631770 [2/3] com.android.resources.perf.PerfTest#maps: PASSED (11.286s) maps_ns_standardDeviation: 2692088 maps_ns_mean: 91326538 maps_ns_median: 90519884 [3/3] com.android.resources.perf.PerfTest#gmail: PASSED (24.694s) gmail_ns_median: 290284442 gmail_ns_standardDeviation: 5764632 gmail_ns_mean: 291660464 With change and verification disabled: [1/3] com.android.resources.perf.PerfTest#youtube: PASSED (11.748s) youtube_ns_median: 95490747 youtube_ns_standardDeviation: 7282249 youtube_ns_mean: 98442515 [2/3] com.android.resources.perf.PerfTest#maps: PASSED (10.862s) maps_ns_standardDeviation: 4484213 maps_ns_mean: 87912988 maps_ns_median: 86325549 [3/3] com.android.resources.perf.PerfTest#gmail: PASSED (24.034s) gmail_ns_median: 282175838 gmail_ns_standardDeviation: 6560876 gmail_ns_mean: 282869146 These tests were done on a Pixel 3 and with cpu settings configured by libs/hwui/tests/scripts/prep_generic.sh: Locked CPUs 4,5,6,7 to 1459200 / 2803200 KHz Disabled CPUs 0,1,2,3 Bug: 160635104 Bug: 169423204 Test: boot device && atest ResourcesPerfWorkloads Change-Id: I5cd1bc8a2257bffaba6ca4a1c96f4e6640106866
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-09-14AAPT2: Convert from Modified UTF-8 ResStringPoolRyan Mitchell
Since ResStringPools are encoded using Modified UTF-8, retrieving strings from the string pool convert the strings to UTF-8 before returning. Bug: 114734350 Test: m aapt2_tests Change-Id: Ib459018186f4c5b40f3f3786425a335ecfb9ed02
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-07-31AAPT2: 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-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-07-01AAPT2: Encode empty attribute string valuesAdam Lesinski
Due to another bug, empty strings in XML files were encoded as NULLs. This was only needed for encoding missing namespace URIs. Attribute values should remain empty strings. Bug:29939875 Bug:29462255 Change-Id: I3897661d85865c88bb2b7cf1495da16c30f7272e
2016-04-06AAPT2: Enable windows build and make sure it buildsAdam Lesinski
Mingw32 4.8 is kind of picky with macros and some complicated template stuff. Luckily there was another way to represent the SFINAE code that works on all platforms. Yay! Change-Id: Idc2e38f47bfdc57b394550bfa0f53cc0b825df25
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-04-15AAPT2: Add library supportAdam Lesinski
Change-Id: I307f56d9631784ab29ee4156d94886f9b2f25b30
2015-04-03Fix windows build of AAPT2Adam Lesinski
Change-Id: Ib8e1a4322510b582e9600a08d3118842c9abc73c
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