summaryrefslogtreecommitdiff
path: root/libs/androidfw/AttributeResolution.cpp
AgeCommit message (Collapse)Author
2020-11-17Revert^2 "Cache resolved theme values"Ryan Mitchell
6ca48473e533a8b89abac6294a0bb8130b8c8c89 Change-Id: Icb295186b85e1edcdcebc1d746f7ff0d6ef66829
2020-11-17Set resource id correctly when resolve failsRyan Mitchell
If for some reason the resource id cannot be resolved to a value (there is no configuration that matches the AssetManager configuration or some error occurs), set the resource id of the SelectedValue to the resource id that could not be resolved. This was the behavior before the AssetManager IncFs hardening refactor. Bug: 173203252 Test: atest com.google.android.config.pts.PreinstalledAppsTestCase Test: Chrome icon appears on launcher Change-Id: Iad1760c0e246da1a4bf64d1c2ec60bb08da32d06
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-13Revert "Cache resolved theme values"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: Ibec051c79dfd28783a57b9ae82ebd8cdbed82fce
2020-11-12Cache resolved theme valuesRyan Mitchell
When calling Resources#obtainStyledAttributes, if a value for an attribute is supplied from the theme, and the value in the theme is a reference to a resource, the reference will be resolved using AssetManager2::ResolveReference each time the value from the theme is selected. This causes Resources#obtainStyledAttributes to do repeated work every time the same attribute is supplied from the theme in multiple invocations. Caching the result of ResolveReference reduces the cost of this repeated work and reduces the amount of time needed to inflate views. Before: com.android.resources.perf (3 Tests) [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 After: com.android.resources.perf (3 Tests) [1/3] com.android.resources.perf.PerfTest#youtube: PASSED (11.245s) youtube_ns_median: 92292347 youtube_ns_standardDeviation: 5899906 youtube_ns_mean: 93045239 [2/3] com.android.resources.perf.PerfTest#maps: PASSED (10.583s) maps_ns_standardDeviation: 7567929 maps_ns_mean: 81895979 maps_ns_median: 78647883 [3/3] com.android.resources.perf.PerfTest#gmail: PASSED (21.439s) gmail_ns_median: 229185043 gmail_ns_standardDeviation: 8770133 gmail_ns_mean: 232561234 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: 170232288 Test: atest ResourcesPerfWorkloads Change-Id: I1e9e9acaa40fa60475a0e55230e11243f5b69b39
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-03-07Clean up attribute apis based on api council feedback.Aurimas Liutikas
Bug: 127714248 Test: None Change-Id: I40596a88e7e446c6a25f2b9074bb88a0a417ed63
2019-01-31Update TypedArray and TypedValue to store source layouts.Aurimas Liutikas
In ag/5859897 we started tracking source styles for each TypedValue. It is also useful to keep track of source layouts if the attribute was resolved against a layout (attribute set in XML layout inside of <View> tag). Test: atest CtsContentTestCases:android.content.res.cts.TypedArrayTest Bug: 111439551 Change-Id: Ie6bc6ecd9a22b536a2f3288263b896f9cec67d38
2019-01-15Add source style for each TypedValue.Aurimas Liutikas
This API will be used by Android Studio layout inspector to query where a given resource attribute originated from to allow developers to have an easier way to find what needs to be changed to affect a given resource attribute. Test: CTS added in the topic Bug: 111439551 Change-Id: Ifbb52b39912ed0444030a86164290a1cd4155250
2019-01-14Merge "Fix/suppress androidfw google-explicit-constructor warnings" am: ↵Chih-Hung Hsieh
392f0052c2 am: 99a3d72b98 am: cd06f9ee04 Change-Id: I0340acdbd6530f9bd9f67333974bcc65ff97e0e5
2019-01-10Fix/suppress androidfw google-explicit-constructor warningsChih-Hung Hsieh
* Add explicit to conversion constructors/operators * Use NOLINT or NOLINTNEXTLINE to suppress warnings on intended converters Bug: 28341362 Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,google-explicit-constructor Change-Id: Id02c36c24f5708584e317c035cef3ef2762b537e
2018-11-16Add style value to ResolvedBag in AssetManager2.Aurimas Liutikas
Bug: 117176857 Test: updated AssetManager2Test.MergesStylesWithParentFromSingleApkAssets Change-Id: I2b79eea8e43431a932756b267b91eb4423c968a5
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-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-12Replace cutils/log.h and android/log.h with log/log.hMark Salyzyn
Test: compile Bug: 34250038 Change-Id: I42185a879beaa9bb244f53a968800392b854ac45
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-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
2016-10-12Move attribute resolution from core/jni to libandroidfwAdam Lesinski
Without the entire JNI environment, testing the attribute resolution code will be much easier and enable safer refactoring. Change-Id: I2815cc1e10a694a3b01bc37e191a0d5e9d0e6735 Test: Existing CTS tests pass