From 668ec5bd3bd9d5fe6ebf46985eacd3d8d81af937 Mon Sep 17 00:00:00 2001 From: MÃ¥rten Kongstad Date: Mon, 11 Jun 2018 14:11:33 +0200 Subject: AssetManager2: optionally keep non-matching configs AssetManager2 maintains a set of configurations [as specified in the resource blob] compatible with the currently set configuration [as specified via SetConfiguration]. This helps optimize future resource lookups by limiting the set of configurations to iterate over. However, when creating idmaps, all configurations must be considered, including those not compatible with the currently set configuration. Add an optional flag to SetApkAssets to disable the optimization described above. Test: manual (will be tested by upcoming idmap2 implementation) Change-Id: I7526a323ddf90e2f2f49c36e8c110a2cec25357e --- libs/androidfw/AssetManager2.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'libs/androidfw/AssetManager2.cpp') diff --git a/libs/androidfw/AssetManager2.cpp b/libs/androidfw/AssetManager2.cpp index 9c1629bc36f5..04cc5bb30ade 100644 --- a/libs/androidfw/AssetManager2.cpp +++ b/libs/androidfw/AssetManager2.cpp @@ -67,10 +67,10 @@ AssetManager2::AssetManager2() { } bool AssetManager2::SetApkAssets(const std::vector& apk_assets, - bool invalidate_caches) { + bool invalidate_caches, bool filter_incompatible_configs) { apk_assets_ = apk_assets; BuildDynamicRefTable(); - RebuildFilterList(); + RebuildFilterList(filter_incompatible_configs); if (invalidate_caches) { InvalidateCaches(static_cast(-1)); } @@ -825,7 +825,7 @@ uint32_t AssetManager2::GetResourceId(const std::string& resource_name, return 0u; } -void AssetManager2::RebuildFilterList() { +void AssetManager2::RebuildFilterList(bool filter_incompatible_configs) { for (PackageGroup& group : package_groups_) { for (ConfiguredPackage& impl : group.packages_) { // Destroy it. @@ -841,7 +841,7 @@ void AssetManager2::RebuildFilterList() { for (auto iter = spec->types; iter != iter_end; ++iter) { ResTable_config this_config; this_config.copyFromDtoH((*iter)->config); - if (this_config.match(configuration_)) { + if (!filter_incompatible_configs || this_config.match(configuration_)) { group.configurations.push_back(this_config); group.types.push_back(*iter); } -- cgit v1.2.3-59-g8ed1b