summaryrefslogtreecommitdiff
path: root/libs/androidfw/tests/ResTable_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
2018-04-02Added decoding of truncated AAPT string lengths.Ryan Mitchell
AAPT incorrectly writes a truncated string length when the string size exceeded the maximum possible encode length value (0x7FFF). To decode a truncated length, this change iterates through length values that end in the encode length bits. Strings that exceed the maximum encode length are not placed into StringPools in AAPT2. Test: Successfully ran broken apps from the duplicates of the bugs provided and created tests Bug: 69320870 Change-Id: I99dd9b63e91ac250f81d5dfc26b7c0e6276ae162
2017-02-15Add ResTable_sparseTypeEntry supportAdam Lesinski
Benchmarks on bullhead-userdebug show that there is a negligent performance impact when using sparse entries on a 30% loaded sparse type of 1000 resources. Benchmark Time CPU Iterations ----------------------------------------------------------------------------------- BM_SparseEntryGetResourceSparseLarge 255 ns 254 ns 2751408 BM_SparseEntryGetResourceNotSparseLarge 254 ns 254 ns 2756534 Bug: 27381711 Test: make libandroidfw_tests aapt2_tests Change-Id: I051ea22f2f6b2bc3696e446adc9e2a34be18009f
2017-01-11libandroidfw: Add new support for shared librariesAdam Lesinski
This adds support for shared resource libraries in the new ResTable/AssetManager implementation. The dynamic package map encoded in resources.arsc is parsed and stored with LoadedArsc, and combined to form a resolved table in AssetManager2. Benchmarks show that this implementation is an order of magnitude faster on angler-userdebug (make libandroidfw_benchmarks). Test: libandroidfw_tests Change-Id: I57c80248728b63b162bf8269ac9495b53c3e7fa0
2016-12-05Make tests use APKs instead of exploded APKsAdam Lesinski
Tests would expect parts of the APK to be unzipped and maintained. Instead, we now decompress the required files from the test APKs on test setup. This simplifies test maintenance substantially. Test: make libandroidfw_tests && libandroidfw_tests --testdata=frameworks/base/libs/androidfw/tests/data Change-Id: I3d2100af22df913e02401dedcf9842cdb32b2a3b
2016-05-10Resource shared libraries: fix theme referencesAdam Lesinski
Theme values that would reference other theme values would not work if they were declared in a shared library. We now introduce a parallel resource type to TYPE_DYNAMIC_REFERENCE, TYPE_DYNAMIC_ATTRIBUTE, which allows us to lookup and resolve theme value references from shared libraries. Bug:28687378 Change-Id: I4f2364e3e8b567679f90784fcaaea12b6b05e926
2016-04-18Optimize ResTable::getLocales() to improve bindApplication performanceAdam Lesinski
Change from linear searching for uniqueness to binary search. Bug:27198799 Change-Id: I1ccb6e93cc213810848f07d631d9d8de7c719803
2016-04-14Revert "Optimize ResTable::getLocales() to improve bindApplication performance"Tim Murray
This reverts commit 5520581b5f043fb858b5b2044ff33ad8545a6d38. bug 28189634 Change-Id: I2d2b859f6d9bd44434fa901cce990583f514980c
2016-04-13Optimize ResTable::getLocales() to improve bindApplication performanceAdam Lesinski
Change from linear searching for uniqueness to binary search. Bug:27198799 Change-Id: Ifa4672929df286c4693ab1f77716f08945941b0c
2016-03-09AssetManager: Cache a pre-filtered list of configurationsAdam Lesinski
When we set the parameters for a ResTable, we can pre-filter which resources match and only look at that smaller list when getting entries. This helps A LOT with types that have many configurations, like strings and all their various locales. We must store the cached entries in a parallel data structure because parts of the main Type object are shared with other ResTables, causing data races. Bug:25499111 Change-Id: I63e37dcbd683fc9f1e7d0f3a6ed4c1c01e0fc575
2015-04-08Fix UB in ResourceTable::stringToInt.Dan Albert
Was here because UBsan found integer overflow in the parsing for hex numbers, since hex numbers here are actually unsigned but assigned to a signed integer. Also fixes a number of missing error conditions. Change-Id: Iaea576daedfc6c75521cde02de3fe9dd0198a3b7
2014-10-23Added some more Split density testsAdam Lesinski
Change-Id: I3b83515f1240e713bbcff5385cf054bba693f297
2014-08-15Fix assumption about DynamicRefTable in aaptAdam Lesinski
Packages without any resources should not expect to have a DynamicRefTable. Bug:16895517 Bug:17056720 Change-Id: Id006f6bdbf08f30505f6ba5982bc9d1b09db0f0a
2014-08-15Revert "Fix aapt dump for APKs with no resources"Adam Lesinski
This reverts commit 0e475302cd196f45a01a525c49089018b238d4ba. I'll re-upload this CL with the correct fix in LoadedApk. Change-Id: I17c6381f8e5907dab9f996f89c5d435b9c08a13a
2014-08-14Fix aapt dump for APKs with no resourcesAdam Lesinski
All APKs are expected to have at least one resource table (even if it is empty). We were missing the creation of an empty DynamicRefTable. Bug:16895517 Change-Id: I6a6e887f91b3b4bbcc52b3fd2741ef3d05fab1fd
2014-08-11Fix shared library bug in bag attributesAdam Lesinski
A ResTable_map entry has a name attribute, which could be a dynamic reference if it comes from a shared library. It was not being patched with the correct package id. Bug:16795890 Change-Id: Ia8df6a943269b2fefb2132c3ed74eb1997d7701b
2014-08-04AAPT support for feature splitsAdam Lesinski
This change allows the developer to add a base package for which to build a feature split. The generated resource types will begin after the base APK's defined types so as not to collide or override resources. Multiple features can be generated by first choosing an arbitrary order for the features. Then for each feature, the base APK and any preceding features are specified with the --feature-of flags. So with a base APK 'A' and features, 'B', and 'C', 'B' would be built with aapt package [...] --feature-of A [...] and 'C' would be built with aapt package [...] --feature-of A --feature-of B [...] Change-Id: I1be66e3f8df9a737b21c71f8a93685376c7e6780
2014-06-18Support multiple resource tables with same packageAdam Lesinski
In order to support APK split features, the resource table needs to support loading multiple resource tables with the same package but potentially new set of type IDs. This adds some complexity as the type ID space changes from dense and ordered to potentially sparse. A ByteBucketArray is used to store the type IDs in a memory efficient way that allows for fast retrieval. In addition, the IDMAP format has changed. We no longer need random access to the type data, since we store the types differently. However, random access to entries of a given type is still required. Change-Id: If6f5be680b405b368941d9c1f2b5d2ddca964160