From 7b43333a26c7588a8d7d2f7ea0f46d9b107ffdaa Mon Sep 17 00:00:00 2001 From: Michael Hoisie Date: Tue, 13 Feb 2024 21:42:21 +0000 Subject: Revert^2 "[res] Don't recalculate configuration twice on init" This reverts commit d38bd5180b2e39c48a5e3ffd1ea420a747a26d17. Reason for revert: Forward fix Bug: 282215580 Bug: 324939476 Change-Id: Ia919e3a7e7188900e4e98c82d3b3f295fb51ca39 --- libs/androidfw/AssetManager2.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'libs/androidfw/AssetManager2.cpp') diff --git a/libs/androidfw/AssetManager2.cpp b/libs/androidfw/AssetManager2.cpp index 8748dab581bb..46f636e2ae7f 100644 --- a/libs/androidfw/AssetManager2.cpp +++ b/libs/androidfw/AssetManager2.cpp @@ -117,6 +117,10 @@ bool AssetManager2::SetApkAssets(ApkAssetsList apk_assets, bool invalidate_cache return true; } +void AssetManager2::PresetApkAssets(ApkAssetsList apk_assets) { + BuildDynamicRefTable(apk_assets); +} + bool AssetManager2::SetApkAssets(std::initializer_list apk_assets, bool invalidate_caches) { return SetApkAssets(ApkAssetsList(apk_assets.begin(), apk_assets.size()), invalidate_caches); @@ -432,13 +436,18 @@ bool AssetManager2::ContainsAllocatedTable() const { return false; } -void AssetManager2::SetConfigurations(std::vector configurations) { +void AssetManager2::SetConfigurations(std::vector configurations, + bool force_refresh) { int diff = 0; - if (configurations_.size() != configurations.size()) { + if (force_refresh) { diff = -1; } else { - for (int i = 0; i < configurations_.size(); i++) { - diff |= configurations_[i].diff(configurations[i]); + if (configurations_.size() != configurations.size()) { + diff = -1; + } else { + for (int i = 0; i < configurations_.size(); i++) { + diff |= configurations_[i].diff(configurations[i]); + } } } configurations_ = std::move(configurations); @@ -775,8 +784,7 @@ base::expected AssetManager2::FindEntry( bool has_locale = false; if (result->config.locale == 0) { if (default_locale_ != 0) { - ResTable_config conf; - conf.locale = default_locale_; + ResTable_config conf = {.locale = default_locale_}; // Since we know conf has a locale and only a locale, match will tell us if that locale // matches has_locale = conf.match(config); -- cgit v1.2.3-59-g8ed1b