summaryrefslogtreecommitdiff
path: root/libs/androidfw/AssetManager2.cpp
diff options
context:
space:
mode:
author Ryan Mitchell <rtmitchell@google.com> 2018-11-30 15:22:31 -0800
committer Ryan Mitchell <rtmitchell@google.com> 2018-12-04 00:58:14 +0000
commit449a54fb6bdbe8401d4f7291df46d4d980622ba7 (patch)
treebd530d1e613b8ae961a8a5b9dee139924e844d83 /libs/androidfw/AssetManager2.cpp
parente59ac13c375ce1c04d05429826a3d993fea4d9a2 (diff)
Do not include system overlay data when excluded
Do not include configurations or locales from overlays overriding system resources when exclude_system is specified in GetResourceConfigurations or GetResourceLocales. Bug: 120083032 Test: run cts -m CtsContentTestCases -t android.content.res.cts.AssetManagerTest#testGetNonSystemLocales Change-Id: I4ba3b07d3bb9ac72b196ff7ed4d1e853b51f7eea
Diffstat (limited to 'libs/androidfw/AssetManager2.cpp')
-rw-r--r--libs/androidfw/AssetManager2.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/libs/androidfw/AssetManager2.cpp b/libs/androidfw/AssetManager2.cpp
index 7ab12b1b3167..ad9ec02648b1 100644
--- a/libs/androidfw/AssetManager2.cpp
+++ b/libs/androidfw/AssetManager2.cpp
@@ -217,10 +217,19 @@ std::set<ResTable_config> AssetManager2::GetResourceConfigurations(bool exclude_
ATRACE_NAME("AssetManager::GetResourceConfigurations");
std::set<ResTable_config> configurations;
for (const PackageGroup& package_group : package_groups_) {
+ bool found_system_package = false;
for (const ConfiguredPackage& package : package_group.packages_) {
if (exclude_system && package.loaded_package_->IsSystem()) {
+ found_system_package = true;
continue;
}
+
+ if (exclude_system && package.loaded_package_->IsOverlay() && found_system_package) {
+ // Overlays must appear after the target package to take effect. Any overlay found in the
+ // same package as a system package is able to overlay system resources.
+ continue;
+ }
+
package.loaded_package_->CollectConfigurations(exclude_mipmap, &configurations);
}
}
@@ -232,10 +241,19 @@ std::set<std::string> AssetManager2::GetResourceLocales(bool exclude_system,
ATRACE_NAME("AssetManager::GetResourceLocales");
std::set<std::string> locales;
for (const PackageGroup& package_group : package_groups_) {
+ bool found_system_package = false;
for (const ConfiguredPackage& package : package_group.packages_) {
if (exclude_system && package.loaded_package_->IsSystem()) {
+ found_system_package = true;
continue;
}
+
+ if (exclude_system && package.loaded_package_->IsOverlay() && found_system_package) {
+ // Overlays must appear after the target package to take effect. Any overlay found in the
+ // same package as a system package is able to overlay system resources.
+ continue;
+ }
+
package.loaded_package_->CollectLocales(merge_equivalent_languages, &locales);
}
}