summaryrefslogtreecommitdiff
path: root/tools/aapt2/util/Util.cpp
AgeCommit message (Collapse)Author
2020-12-22Merge "Add explicit Result::ok() checks where needed" am: c08d3ef8a8 am: ↵Bernie Innocenti
ae613dd6c4 am: f454301ae6 Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1532909 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I22f3e4f97d523bd09b898ebdf4de18114cb4c34f
2020-12-21Add explicit Result::ok() checks where neededBernie Innocenti
Test: m checkbuild continuous_instrumentation_tests continuous_instrumentation_tests_api_coverage continuous_native_tests device-tests platform_tests Exempt-From-Owner-Approval: mechanical mass refactoring Change-Id: I3117833c51cdb333cccdfd159d1582f2adef77db
2020-12-08Revert^2 "libandroidfw hardening for IncFs"Ryan Mitchell
55ef6167a2c235bd88c7216238b2001b46795b79 Change-Id: I02d4890d181655dfd0a14c188468db512559d27b Merged-In: I02d4890d181655dfd0a14c188468db512559d27b
2020-11-20Merge "aapt2: Limit length of package name and shared user id"Rhed Jao
2020-11-19aapt2: Limit length of package name and shared user idRhed Jao
Package name and shared user id could be used as part of filename as prefix by other modules. Limits the length to 223 and reserves 32 for the OS. Bug: 118768971 Test: atest aapt2_tests Test: aapt2 link -I android.jar --manifest ManifestLongPackageName.xml Test: aapt2 link -I android.jar --manifest ManifestLongSharedUserId.xml Change-Id: Ic4b5b4647b9e253b79b663f4d7a9050f43bb8cf0
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-04-17Add build number to aapt2 versionRyan Mitchell
This changes adds the build id to the version printed by "aapt2 version". This change also adds a field to the ResourceTable proto that specifies the fingerprints of tools used to build the table. Bug: 123663089 Test: manual Change-Id: Ifaf33c1e506b68e9f1d921fdbeddf36485e65790
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-02-27AAPT2: Fix styled string whitespace processingAdam Lesinski
Change styled string whitespace processing to be like AAPT's was. Main changes: - whitespace around tags is preserved. - tags start exactly where they are supposed to, not off by one. Bug: 72406283 Test: make aapt2_tests Change-Id: I4d12728c493efd8c978e2e3d2718b56534ff52ef
2017-11-07AAPT2: Differentiate between Android and Java package namesAdam Lesinski
Android package names are more strict (ASCII only) than Java package names. Also fixed an issue where trailing underscores were disallowed in Android package names. Bug: 68468089 Test: make aapt2_tests Change-Id: I1052e9e82b6617db6065ce448d9bf7972bb68d59
2017-08-03Fix clang-tidy performance warnings in aapt2.Chih-Hung Hsieh
* 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-07-07AAPT2: Fix processing of quotes in XMLAdam Lesinski
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-07AAPT2: Accept Java unicode identifiersAdam Lesinski
Test: make aapt2_tests Change-Id: I75a0e52d43b1785001bfe120eea7484f7bb4682b
2017-06-29AAPT2: Iterate over UTF-8 string by codepointsAdam Lesinski
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-06AAPT2: Do not interpret %n as a format specifier in string resourcesAdam Lesinski
%n is a special value marking a platform independent newline and is not to be considered a format argument. Bug: 37132275 Test: make aapt2_tests Change-Id: I806521e44afe20004344dee9f18ecee6cc7086ea
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-09-07AAPT2: Fix issue with styled string indicesAdam Lesinski
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-07-29Unicode: specify destination length in utf8_to_utf16 methodsSergio Giro
Change-Id: I5223caa7d42f4582a982609a898a02043265c6d3
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-12Merge \\"Add bound checks to utf16_to_utf8\\" into nyc-mr1-dev am: 49c410bc48Sergio Giro
am: daad138428 Change-Id: I5a660dccb76e823736a59e50904a7279a97ef849
2016-07-07AAPT2: Fix fully qualified java class verificationAdam Lesinski
Proguard rules would be ignored for components defined in AndroidManifest.xml for android:name attributes if they didn't start with '.'. Change-Id: I029b5a2f224f4daf155b73a2a4dcd940dd43372e
2016-07-02Add bound checks to utf16_to_utf8Sergio Giro
Test: ran libaapt2_tests64 Bug: 29250543 Change-Id: I1ebc017af623b6514cf0c493e8cd8e1d59ea26c3
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-11-19AAPT2: Fail compiling when private symbols are referencedAdam Lesinski
Also moved some XML specific stuff into its own directory, and refactored ReferenceLinker a bit. Change-Id: I912247a82023c1bbf72dc191fbdaf62858cbec0c
2015-11-03AAPT2: Verify positional Java String format arguments in stringsAdam Lesinski
Change-Id: Id415969035a0d5712857c0e11e140155566a960c
2015-11-02AAPT2: Add support for comments in R.javaAdam Lesinski
Change-Id: Iaa5f3b75bf7de9dbf458fa5c452f7312989f4c4f
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