summaryrefslogtreecommitdiff
path: root/libs/androidfw/tests/AttributeResolution_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
2020-03-19Refactor ApkAsset loading APIsRyan Mitchell
To add the partner requested ResourcesProvider#loadFromDir APIs, this change adds format type integer that allows us to reduce the number of ApkAssets loading overrides. This change also adds hidden offset and length based ResourcesProvider APIs that could not make R. Bug: 142716192 Test: atest FrameworksResourceLoaderTests Change-Id: I926fde257cae701901dcd4ca408024feae8c90a6 Merged-In: I926fde257cae701901dcd4ca408024feae8c90a6
2018-02-28Refactor AssetManagerAdam Lesinski
Bug: 64071469 Test: atest CtsContentTestCases Change-Id: Ia6856157e8813856268fba003e1e591d690cb26e
2018-02-09Revert "Replace AssetManager with AssetManager2 implementation"Adam Lesinski
This reverts commit 1187590da38457809dd368d4901c9c47ac5a6958. Bug: 73134570 Change-Id: I59b4d714e447478ea124f086356f127f42251fb7
2018-02-09Revert "libandroidfw: Make sure to set the 'app as lib' flag"Adam Lesinski
This reverts commit 9ad287c828a116f844e5c03346c618d83727e4ae. Bug: 73134570 Change-Id: If930d3a7c17fc2f7ffaebd31281ad5a5d120144f
2018-02-05libandroidfw: Make sure to set the 'app as lib' flagAdam Lesinski
When an app is loaded as a shared library (eg. monochrome), make sure to set the bit that it loaded as such, so that conversions from package ID 7f -> shared library ID are done. Bug: 72511998 Test: make libandroidfw_tests Test: out/host/<host_os>/nativetest64/libandroidfw_tests/libandroidfw_tests Change-Id: Icd11b7a5adff351165ca16d5853fb5a0002c34b1
2018-02-05Replace AssetManager with AssetManager2 implementationAdam Lesinski
Test: atest CtsContentTestCases:android.content.res.cts Test: make libandroidfw_tests Change-Id: I2bb6d7656d2516d371e83e541ed02f91405f6d94
2018-01-25Revert "Replace AssetManager with AssetManager2 implementation"Adam Lesinski
This reverts commit dcb3c6559b09ec89771858ec27a787027da9af50. Bug:72511998 Change-Id: I665966ca109f66f85d8665db388c71ea2303c3b8
2018-01-24Replace AssetManager with AssetManager2 implementationAdam Lesinski
Test: atest CtsContentTestCases:android.content.res.cts Test: make libandroidfw_tests Change-Id: I572eb13c6a4372c7f656f5912821cececd5bf3d4
2018-01-23Revert "Replace AssetManager with AssetManager2 implementation"Adam Lesinski
This reverts commit b20a0ce59f59cb5ec857748e056cc341dbd13b92.
2018-01-09Replace AssetManager with AssetManager2 implementationAdam Lesinski
Test: Existing CTS tests pass Test: make libandroidfw_tests Change-Id: I858f7e1d909c08273b096601136e3f28e15eb5d4
2017-05-11Fix support for @empty in style resolutionAdam Lesinski
If @empty is encountered in XML, do not fallback to searching through the theme. Bug: 36891052 Test: make aapt2_tests Test: bit CtsContentTestCases:android.content.res.cts.TypedArrayTest Change-Id: Ie3bf7b70af9c7913513a1092afd95d26bec5e635
2017-01-11New implementation of AssetManager/ResTableAdam Lesinski
The multiwindow model and Resources-per-activity model that came in N puts greater demands on AssetManagers. They are created whenever window dimensions change, which can be frequently. There is a need to be able to cheaply create a new AssetManager for each Activity, which shares a lot of underlying state. In order to make the creation of AssetManagers cheap, we need a new implementation of the native AssetManager and ResTable to support immutable representations of APKs. This new data structure/class is ApkAssets. ApkAssets have the same functionality of an AssetManager, except that they operate on a single APK, and they do not do any caching. Once loaded, they are immutable. ApkAssets will be exposed as a Java object, with its implementation in native code. The existing Java StringBlock will be owned by ApkAssets, which means that Strings can be shared across AssetManagers. ApkAssets can be cached by the ResourcesManager. Creating an AssetManager requires only a list of ApkAssets and a configuration. AssetManager2 (named with the suffix '2' for now while transitioning to the new implementation) caches bags that are accessed. Since ApkAssets are expected to be kept around longer, they do more validation of the resource table, which cause slower load times. Measured on an angler-userdebug, loading the framework assets takes 11ms with ApkAssets, and 2ms with the old AssetManager implementation. The tradeoff is that there does not need to be any security checks once an ApkAssets is loaded, and regular resource retrieval is faster. Measured on an angler-userdebug, accessing resource (android:string/ok) with many locales takes 18us with AssetManager2, and 19us with AssetManager (this is per resource, so these add up). Test: make libandroidfw_tests Change-Id: Id0e57ee828f17008891fe3741935a9be8830b01d
2017-01-06libandroidfw: Revert null check in ApplyStyleAdam Lesinski
The out parameter `out_indices` is expected to be non-null and so the extra null check adds a cost to performance and opens the door to misusing the API by not supplying `out_indices`. Test: make libandroidfw_tests Change-Id: Ie66fd837c5e24ec2838156e7b67f54c15cd27933
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-12-02Clean up ApplyStyle JNIJohn Reck
Bug: 32573798 Mark input uint32_t[] as const. Use Read-only JNI array access for input as it's faster than critical access. Use non-movable arrays for TypedArray so that the address can be resolved and stored, avoiding the need to do JNI array access for the output. Indicies is always non-null, so remove the optional checks. Eliminate unused return value. Benchmark results: twelveKeyInflate 4963us -> 4713us simpleViewInflate 73us -> 60us Test: Device boots, benchmarks show faster Change-Id: Ic3bde5aee31407d8903913f97f2218daf074499a
2016-11-29Add --testdata flag for easier testingAdam Lesinski
Instead of hardcoding or assuming a path for testdata, allow the testdata path to be specified via the command line. Test: make libandroidfw_tests Change-Id: Ideae880b21c157b70a11bb5a90a94556771aead6
2016-10-17Add tests for attribute resolutionAdam Lesinski
- Adds unit tests for attribute resolution. These include some test data resource tables and compiled XML files. - Convert touched files to Google style guide. Test: make libandroidfw_tests Change-Id: Ib3a36061dc874de5f6a266b4e82c0a12ef435f23