From 7960898f6f886aadda1dd3d7a89106dde9f44217 Mon Sep 17 00:00:00 2001 From: Roozbeh Pournader Date: Thu, 3 Mar 2016 15:06:46 -0800 Subject: Fix script-related parts of locale resource matching Previously, a bit was kept to find if the script of a locale was explicitly "provided" in a resource. This was not backward compatible, and failed in some edge cases when the package was created with older versions of AAPT that did not set the bit. The cases would happen when the old resource had an explicit script specified in its locale, but since the "provided" bit was not set in the package, we would assume that the script was computed by us. This CL replaces the "provided" bit with a "computed" bit, so the default value of the bit (set to "false" for old packages) would be correct. Bug: 27156990 Change-Id: I99e7f1ad8f70c90e25ab3640ed34cc1a6f8d1d64 --- tools/aapt2/Locale.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tools/aapt2/Locale.cpp') diff --git a/tools/aapt2/Locale.cpp b/tools/aapt2/Locale.cpp index 6acf3b09d301..12f56fc11226 100644 --- a/tools/aapt2/Locale.cpp +++ b/tools/aapt2/Locale.cpp @@ -253,7 +253,7 @@ std::string LocaleValue::toDirName() const { void LocaleValue::initFromResTable(const ResTable_config& config) { config.unpackLanguage(language); config.unpackRegion(region); - if (config.localeScriptWasProvided) { + if (config.localeScript[0] && !config.localeScriptWasComputed) { memcpy(script, config.localeScript, sizeof(config.localeScript)); } @@ -268,10 +268,10 @@ void LocaleValue::writeTo(ResTable_config* out) const { if (script[0]) { memcpy(out->localeScript, script, sizeof(out->localeScript)); - out->localeScriptWasProvided = true; + out->localeScriptWasComputed = false; } else { out->computeScript(); - out->localeScriptWasProvided = false; + out->localeScriptWasComputed = true; } if (variant[0]) { -- cgit v1.2.3-59-g8ed1b