From 527ebbaa55f42e90a05f12f0154294d2e9d16903 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Fri, 30 Oct 2020 12:32:47 -0700 Subject: Fix DominatorTree for locale and mcc/mnc config De-duping of configurations with locales was disabled previously since there is not a good way to dedupe locales in a forwards compatible way (change SHA: e38567480be67ac83a8f8f090704bb0d49e2eed2). In b/171892595, since every locale is a root in the dominator tree, configs that do not specify locale qualifiers are dominated by the default config and their values are checked for compatiblity with the locale config values. b/171892595 took a while to detect because, this is only an issue at runtime when a resource has one config containing mnc/mcc without a locale, one config containing a locale, and the values for the configs differ. This is because mcc/mnc is the only qualifier with a greater precedence than locale. Make configurations with mcc/mnc and mcc unable to be dominated until locale deduping is fixed. Bug: 171892595 Bug: 62409213 Test: aapt2-tests Change-Id: Ia0a5e5d7a1650d070f5f2fcaf9a8469a8c7dabe6 --- libs/androidfw/ConfigDescription.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libs/androidfw/ConfigDescription.cpp') diff --git a/libs/androidfw/ConfigDescription.cpp b/libs/androidfw/ConfigDescription.cpp index 1f3a89edb8af..19ead9583eb2 100644 --- a/libs/androidfw/ConfigDescription.cpp +++ b/libs/androidfw/ConfigDescription.cpp @@ -887,13 +887,16 @@ bool ConfigDescription::Dominates(const ConfigDescription& o) const { } // Locale de-duping is not-trivial, disable for now (b/62409213). - if (diff(o) & CONFIG_LOCALE) { + // We must also disable de-duping for all configuration qualifiers with precedence higher than + // locale (b/171892595) + if (diff(o) & (CONFIG_LOCALE | CONFIG_MCC | CONFIG_MNC)) { return false; } if (*this == DefaultConfig()) { return true; } + return MatchWithDensity(o) && !o.MatchWithDensity(*this) && !isMoreSpecificThan(o) && !o.HasHigherPrecedenceThan(*this); } -- cgit v1.2.3