History log of /frameworks/base/libs/androidfw/AssetManager2.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
57cd195c4303ff248c6e016d51e3b7632cf69bae 12-Apr-2018 y <rtmitchell@google.com> AAPT2: GetBag infinite recursion fix

Style resources with circular parental dependencies caused infinite
recursion when calling AssetManager2::GetBag. This fix allows recursion
to cease when a circular dependency is found.

Bug: 77928512
Change-Id: Ib900c36ab1aef5da5b03234a9484c4dad3b63c02
Test: Manual test of b/77928512 and duplicates of 74493983
/frameworks/base/libs/androidfw/AssetManager2.cpp
6759955c95442571a0eb0cf88872b5010c60aad4 31-Mar-2018 Ryan Mitchell <rtmitchell@google.com> Fixed resource bag retrieval infinite recursion.

An app was crashing because in an attempt to retrieve layout
attribute/style data, the app infinitely recursed because its parent was
set to itself. This change checks if the resource bag parent and child
have the same ids, and if so, attempts to find the resource in this bag
alone rather than attempting to also look in parent bags.

Bug: 74493983
Test: Manual testing of Fitbit app
Change-Id: Iea37533a0676bd51b72c9bb235adec9bd04f2ccc
(cherry picked from commit ac04095ba91f262c9167985a8024607763d8cacc)
/frameworks/base/libs/androidfw/AssetManager2.cpp
bebfcc46a249a70af04bc18490a897888a142fb8 12-Feb-2018 Adam Lesinski <adamlesinski@google.com> Refactor AssetManager

Bug: 64071469
Test: atest CtsContentTestCases
Change-Id: Ia6856157e8813856268fba003e1e591d690cb26e
/frameworks/base/libs/androidfw/AssetManager2.cpp
bde1df21adf264d3398b9f3274f353faa6399008 09-Feb-2018 Adam Lesinski <adamlesinski@google.com> Revert "Replace AssetManager with AssetManager2 implementation"

This reverts commit 1187590da38457809dd368d4901c9c47ac5a6958.

Bug: 73134570
Change-Id: I59b4d714e447478ea124f086356f127f42251fb7
/frameworks/base/libs/androidfw/AssetManager2.cpp
2a447172a5b8c4fdb8527602144691802c492c2e 09-Feb-2018 Adam Lesinski <adamlesinski@google.com> Revert "libandroidfw: Make sure to set the 'app as lib' flag"

This reverts commit 9ad287c828a116f844e5c03346c618d83727e4ae.

Bug: 73134570
Change-Id: If930d3a7c17fc2f7ffaebd31281ad5a5d120144f
/frameworks/base/libs/androidfw/AssetManager2.cpp
b8b3a2619435eb226ce13b1792a6ccb1302b3cb2 09-Feb-2018 Adam Lesinski <adamlesinski@google.com> Revert "libandroidfw: Improve performance of AssetManager2"

This reverts commit 88c9959e5b417320bbc2484fab42ab4b12379533.

Bug: 73134570
Change-Id: I012643d2b4212cef5aef68feb4146add34f9ecfc
/frameworks/base/libs/androidfw/AssetManager2.cpp
88c9959e5b417320bbc2484fab42ab4b12379533 09-Jan-2018 Adam Lesinski <adamlesinski@google.com> libandroidfw: Improve performance of AssetManager2

AssetManager2 relied on creating a list of configurations
present in the resource table so as to avoid copying and
converting ResTable_config's from the APK on every
resource retrieval.

ResTable, however, had a better optimization that pruned
the configurations that didn't match the currently set
configuration. This vastly reduced the number of ResTable_configs
to test.

In this CL, AssetManager2 follows suite with this optimization
and only maintains the filtered ResTable_configs, falling back
to the slow path when the configuration is overridden.

Test: mma frameworks/base/libs/androidfw
Test: adb sync system data
Test: adb shell /data/benchmarktest64/libandroidfw_benchmarks/libandroidfw_benchmarks
Change-Id: Ib57b75fbb32e1d310eec146e5a12dfc6de4385f9
/frameworks/base/libs/androidfw/AssetManager2.cpp
9ad287c828a116f844e5c03346c618d83727e4ae 31-Jan-2018 Adam Lesinski <adamlesinski@google.com> libandroidfw: Make sure to set the 'app as lib' flag

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
/frameworks/base/libs/androidfw/AssetManager2.cpp
1187590da38457809dd368d4901c9c47ac5a6958 23-Jan-2017 Adam Lesinski <adamlesinski@google.com> Replace AssetManager with AssetManager2 implementation

Test: atest CtsContentTestCases:android.content.res.cts
Test: make libandroidfw_tests
Change-Id: I2bb6d7656d2516d371e83e541ed02f91405f6d94
/frameworks/base/libs/androidfw/AssetManager2.cpp
f7d01dd7e14e01420c39e7fb8eca3cfa0f5f31b6 26-Jan-2018 Adam Lesinski <adamlesinski@google.com> Revert "Replace AssetManager with AssetManager2 implementation"

This reverts commit dcb3c6559b09ec89771858ec27a787027da9af50.

Bug:72511998
Change-Id: I665966ca109f66f85d8665db388c71ea2303c3b8
/frameworks/base/libs/androidfw/AssetManager2.cpp
0dd369912a2b46c22d09ddc6ae117fe173e51cb8 26-Jan-2018 Adam Lesinski <adamlesinski@google.com> Revert "libandroidfw: Improve performance of AssetManager2"

This reverts commit 64ee69d0f1f412edee2eb7a0c846deebbfa37ef9.

Bug:72511998
Change-Id: Iab3ce449e60ec2451d391217543528d312089080
/frameworks/base/libs/androidfw/AssetManager2.cpp
64ee69d0f1f412edee2eb7a0c846deebbfa37ef9 09-Jan-2018 Adam Lesinski <adamlesinski@google.com> libandroidfw: Improve performance of AssetManager2

AssetManager2 relied on creating a list of configurations
present in the resource table so as to avoid copying and
converting ResTable_config's from the APK on every
resource retrieval.

ResTable, however, had a better optimization that pruned
the configurations that didn't match the currently set
configuration. This vastly reduced the number of ResTable_configs
to test.

In this CL, AssetManager2 follows suite with this optimization
and only maintains the filtered ResTable_configs, falling back
to the slow path when the configuration is overridden.

Test: mma frameworks/base/libs/androidfw
Test: adb sync system data
Test: adb shell /data/benchmarktest64/libandroidfw_benchmarks/libandroidfw_benchmarks
Change-Id: I5d46f8b005a37b72750d00bd75f090e7b5a36f60
/frameworks/base/libs/androidfw/AssetManager2.cpp
dcb3c6559b09ec89771858ec27a787027da9af50 23-Jan-2017 Adam Lesinski <adamlesinski@google.com> Replace AssetManager with AssetManager2 implementation

Test: atest CtsContentTestCases:android.content.res.cts
Test: make libandroidfw_tests
Change-Id: I572eb13c6a4372c7f656f5912821cececd5bf3d4
/frameworks/base/libs/androidfw/AssetManager2.cpp
7fb38311361390e24d7e43ce1eb220faccd251ff 23-Jan-2018 Adam Lesinski <adamlesinski@google.com> Revert "Replace AssetManager with AssetManager2 implementation"

This reverts commit b20a0ce59f59cb5ec857748e056cc341dbd13b92.
/frameworks/base/libs/androidfw/AssetManager2.cpp
50706b6ebc224920bceffa66baa30734de5e27ff 23-Jan-2018 Adam Lesinski <adamlesinski@google.com> Revert "libandroidfw: Improve performance of AssetManager2"

This reverts commit 392132748416719e3df427e6ac8dc11af194342c.
/frameworks/base/libs/androidfw/AssetManager2.cpp
392132748416719e3df427e6ac8dc11af194342c 09-Jan-2018 Adam Lesinski <adamlesinski@google.com> libandroidfw: Improve performance of AssetManager2

AssetManager2 relied on creating a list of configurations
present in the resource table so as to avoid copying and
converting ResTable_config's from the APK on every
resource retrieval.

ResTable, however, had a better optimization that pruned
the configurations that didn't match the currently set
configuration. This vastly reduced the number of ResTable_configs
to test.

In this CL, AssetManager2 follows suite with this optimization
and only maintains the filtered ResTable_configs, falling back
to the slow path when the configuration is overridden.

Test: mma frameworks/base/libs/androidfw
Test: adb sync system data
Test: adb shell /data/benchmarktest64/libandroidfw_benchmarks/libandroidfw_benchmarks
Change-Id: I42d53f703623cf7c3f7cbcf194f5026ff540faf4
/frameworks/base/libs/androidfw/AssetManager2.cpp
b20a0ce59f59cb5ec857748e056cc341dbd13b92 23-Jan-2017 Adam Lesinski <adamlesinski@google.com> Replace AssetManager with AssetManager2 implementation

Test: Existing CTS tests pass
Test: make libandroidfw_tests
Change-Id: I858f7e1d909c08273b096601136e3f28e15eb5d4
/frameworks/base/libs/androidfw/AssetManager2.cpp
498f6053dad29d715dd532f5272df12dabccf8c8 29-Nov-2017 Adam Lesinski <adamlesinski@google.com> libandroidfw: Remove pre-verification

This added more up-front cost to loading an APK and didn't provide
a significant benefit to resource retrieval.

Test: make libandroidfw_tests
Change-Id: Idbf993abc433fa8c8950d106c66469b310b66f7f
/frameworks/base/libs/androidfw/AssetManager2.cpp
1c855a0bc88281873b047391de93d0a2b4dbd454 29-Nov-2017 Adam Lesinski <adamlesinski@google.com> libandroidfw: Do not clear last resource id in ResolveReference

If the value passed to AssetManager::ResolveReference is not a
reference, the caller may be expecting for the last reference to
not be cleared, as a more appropriate value should most likely be
retained.

This was causing an issue when a caller was manually resolving
references and expecting the last resource ID resolved to be propagated
across calls to ResolveReference.

Test: make libandroidfw_tests
Change-Id: I5b7f586e2cd541059023eaa9ba23e324a21a9a1e
/frameworks/base/libs/androidfw/AssetManager2.cpp
1a1e9c272459f05c846a03fc15989ff7e492517e 14-Oct-2017 Adam Lesinski <adamlesinski@google.com> AssetManager2: Run ApkAssets that have failed verification

ApkAssets who have failed verification should still run for
compatibility. Not all resources are accessed, and therefore
errors in the APK are not necessarily fatal. However, this means
we must do bounds checks when retrieving resources, which is
slower.

Test: make libandroidfw_tests && $ANDROID_BUILD_TOP/out/host/<host>/nativetest64/libandroidfw_tests/libandroidfw_tests
Test: make libandroidfw_benchmarks && adb sync system && adb sync data && /data/benchmarktest64/libandroidfw_benchmarks/libandroidfw_benchmarks
Change-Id: I4cc926c064bca0491785d82cdac0419d74d7d9b0
/frameworks/base/libs/androidfw/AssetManager2.cpp
30080e2f282f40222bd9cc617e0c11d63c82f829 17-Oct-2017 Adam Lesinski <adamlesinski@google.com> AssetManager2: Improve Theme performance

This change brings Theme ApplyStyle down to 2x the original performance
and Theme attribute retrieval to less than the original performance.
Yay!

Benchmarks ran on marlin-eng
----------------------------------------------------------------------
Benchmark Time CPU Iterations
----------------------------------------------------------------------
BM_ThemeApplyStyleFramework 8540 ns 8500 ns 82105
BM_ThemeApplyStyleFrameworkOld 5280 ns 5258 ns 148849
BM_ThemeGetAttribute 8 ns 8 ns 88388549
BM_ThemeGetAttributeOld 11 ns 11 ns 63394463

ApplyStyle still takes some time, and the weird thing is that if I
switch the data structure of ThemeType to use an
std::vector<ThemeEntry>, the performance becomes better than the
original implementation! The issue is that std::vector<T> takes up 24
bytes, which would make Themes take up 8 more bytes per ThemeType, which
is unacceptable. Still trying to isolate where the performance gain is
coming from.

Test: make libandroidfw_tests && $ANDROID_BUILD_TOP/out/host/<host>/nativetest64/libandroidfw_tests/libandroidfw_tests
Test: make libandroidfw_benchmarks && adb sync system && adb sync data && adb shell /data/benchmarktest64/libandroidfw_benchmarks/libandroidfw_benchmarks
Change-Id: I0e7a756afd44b6aac1521e69c2b907258c262d3e
/frameworks/base/libs/androidfw/AssetManager2.cpp
970bd8d2835b05237c4561bd6c12329e26f136b3 25-Sep-2017 Adam Lesinski <adamlesinski@google.com> AssetManager2: Implement IDMAP support

This enables RRO (runtime resource overlays) with AssetManager2

Test: make libandroidfw_tests
Test: out/host/<platform>/nativetest64/libandroidfw_tests/libandroidfw_tests --testdata=frameworks/base/libs/androidfw/tests/data
Change-Id: Id8079104faefbfaa3f4017d8f7ee1a8968f151a2
/frameworks/base/libs/androidfw/AssetManager2.cpp
03ebac8c68f9925592a172fcfd11d56f48cadaeb 25-Sep-2017 Adam Lesinski <adamlesinski@google.com> A few fixes to AssetManager2 for compat

Theme copying should behave the way it did with the old AssetManager
(copy only the framework attributes when copying from a Theme object
from a different AssetManager).

Cleanup the dependencies on libziparchive in ApkAssets.

Test: make libandroidfw_tests
Test: out/host/<platform>/nativetests64/libandroidfw_tests/libandroidfw_tests --testdata=frameworks/base/libs/androidfw/tests/data
Change-Id: I973f7e6eb14ce311306e2ec66a623a4790c8d233
/frameworks/base/libs/androidfw/AssetManager2.cpp
09b119fb7d0494e9afd2bf2ec774532fcafe754e 26-Jul-2017 George Burgess IV <gbiv@google.com> AssetManager2: Fix a memory leak

Caught by the static analyzer:

frameworks/base/libs/androidfw/AssetManager2.cpp:580:9: warning:
Potential leak of memory pointed to by 'new_bag'
[clang-analyzer-unix.Malloc]

Bug: 27101951
Test: mma. Memory leak warning is gone.
Change-Id: I532585d4dd376cec1abf4358f26d23f5ae3231cf
/frameworks/base/libs/androidfw/AssetManager2.cpp
d1ecd7af687bcad0f87c37fe33515ff6c5ea0f1d 23-Jan-2017 Adam Lesinski <adamlesinski@google.com> AssetManager2: Various fixes

- Use FileMaps to open Assets (prevents closing of ApkAssets underlying
zip)
- Implement OpenDir and List methods
- Fix issue where DynamicRefTable wasn't properly constructed

Test: make libandroidfw_tests
Change-Id: Ib21a84e1114d028120744aa3bc1c6eb9d9399fa8
/frameworks/base/libs/androidfw/AssetManager2.cpp
929d6517dfd338f0d481dbe6587643d5aef27ec6 17-Jan-2017 Adam Lesinski <adamlesinski@google.com> AssetManager2: Add GetResourceId

Add ability to lookup a resource by name.

Test: make libandroidfw_tests
Change-Id: I262ba5ce4c9892458226fbdb44cf21f9877fb92d
/frameworks/base/libs/androidfw/AssetManager2.cpp
0c40524953f3d36a880f91183302a2ea5c722930 14-Jan-2017 Adam Lesinski <adamlesinski@google.com> AssetManager2: Add other support methods

- Add GetResourceConfigurations()
- Add GetResourceLocales()
- Add ResolveReference()
- Add stub for GetResourceId()
- Change LoadedArsc and ApkAssets factory method to return const

Test: make libandroidfw_tests
Change-Id: Ia797dc9381a523b1a3e7029048a413e544730379
/frameworks/base/libs/androidfw/AssetManager2.cpp
da431a22da38f9c4085b5d71ed9a9c6122c6a5a6 29-Dec-2016 Adam Lesinski <adamlesinski@google.com> libandroidfw: Add new support for shared libraries

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
/frameworks/base/libs/androidfw/AssetManager2.cpp
7ad1110ecd6a840fcd2895c62668828a1ca029c6 29-Oct-2016 Adam Lesinski <adamlesinski@google.com> New implementation of AssetManager/ResTable

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
/frameworks/base/libs/androidfw/AssetManager2.cpp