diff options
| author | 2023-08-25 12:59:08 -0700 | |
|---|---|---|
| committer | 2023-08-25 12:59:08 -0700 | |
| commit | 7d3ffbae618e9e728644a96647ed709bf39ae759 (patch) | |
| tree | ab369a30c6a0e17a69c8f80c6353be4de3692e10 /libs/androidfw/ConfigDescription.cpp | |
| parent | a8a87bbca9162af7add830139198c4ee899fa123 (diff) | |
| parent | 8a809c6e46007521f75ac035ad4b1dcc1d00d9cf (diff) | |
Merge Android U (ab/10368041)
Bug: 291102124
Merged-In: I3c9e9d15786fbead1b874636b46844f6c24bccc2
Change-Id: Id6cf6cc13baef4e67486c6271a1510146204affa
Diffstat (limited to 'libs/androidfw/ConfigDescription.cpp')
| -rw-r--r-- | libs/androidfw/ConfigDescription.cpp | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/libs/androidfw/ConfigDescription.cpp b/libs/androidfw/ConfigDescription.cpp index 952101b1952c..e08030c4cca5 100644 --- a/libs/androidfw/ConfigDescription.cpp +++ b/libs/androidfw/ConfigDescription.cpp @@ -21,6 +21,7 @@ #include "androidfw/Util.h" #include <string> +#include <string_view> #include <vector> namespace android { @@ -38,11 +39,11 @@ static bool parseMcc(const char* name, ResTable_config* out) { return true; } const char* c = name; - if (tolower(*c) != 'm') return false; + if (*c != 'm') return false; c++; - if (tolower(*c) != 'c') return false; + if (*c != 'c') return false; c++; - if (tolower(*c) != 'c') return false; + if (*c != 'c') return false; c++; const char* val = c; @@ -68,11 +69,11 @@ static bool parseMnc(const char* name, ResTable_config* out) { return true; } const char* c = name; - if (tolower(*c) != 'm') return false; + if (*c != 'm') return false; c++; - if (tolower(*c) != 'n') return false; + if (*c != 'n') return false; c++; - if (tolower(*c) != 'c') return false; + if (*c != 'c') return false; c++; const char* val = c; @@ -93,6 +94,23 @@ static bool parseMnc(const char* name, ResTable_config* out) { return true; } +static bool parseGrammaticalInflection(const std::string& name, ResTable_config* out) { + using namespace std::literals; + if (name == "feminine"sv) { + if (out) out->grammaticalInflection = ResTable_config::GRAMMATICAL_GENDER_FEMININE; + return true; + } + if (name == "masculine"sv) { + if (out) out->grammaticalInflection = ResTable_config::GRAMMATICAL_GENDER_MASCULINE; + return true; + } + if (name == "neuter"sv) { + if (out) out->grammaticalInflection = ResTable_config::GRAMMATICAL_GENDER_NEUTER; + return true; + } + return false; +} + static bool parseLayoutDirection(const char* name, ResTable_config* out) { if (strcmp(name, kWildcardName) == 0) { if (out) @@ -637,7 +655,7 @@ static bool parseVersion(const char* name, ResTable_config* out) { return true; } -bool ConfigDescription::Parse(const StringPiece& str, ConfigDescription* out) { +bool ConfigDescription::Parse(StringPiece str, ConfigDescription* out) { std::vector<std::string> parts = util::SplitAndLowercase(str, '-'); ConfigDescription config; @@ -678,6 +696,13 @@ bool ConfigDescription::Parse(const StringPiece& str, ConfigDescription* out) { } } + if (parseGrammaticalInflection(*part_iter, &config)) { + ++part_iter; + if (part_iter == parts_end) { + goto success; + } + } + if (parseLayoutDirection(part_iter->c_str(), &config)) { ++part_iter; if (part_iter == parts_end) { @@ -832,11 +857,13 @@ success: void ConfigDescription::ApplyVersionForCompatibility( ConfigDescription* config) { uint16_t min_sdk = 0; - if ((config->uiMode & ResTable_config::MASK_UI_MODE_TYPE) + if (config->grammaticalInflection != 0) { + min_sdk = SDK_U; + } else if ((config->uiMode & ResTable_config::MASK_UI_MODE_TYPE) == ResTable_config::UI_MODE_TYPE_VR_HEADSET || config->colorMode & ResTable_config::MASK_WIDE_COLOR_GAMUT || config->colorMode & ResTable_config::MASK_HDR) { - min_sdk = SDK_O; + min_sdk = SDK_O; } else if (config->screenLayout2 & ResTable_config::MASK_SCREENROUND) { min_sdk = SDK_MARSHMALLOW; } else if (config->density == ResTable_config::DENSITY_ANY) { @@ -913,6 +940,7 @@ bool ConfigDescription::HasHigherPrecedenceThan( if (country[0] || o.country[0]) return (!o.country[0]); // Script and variant require either a language or country, both of which // have higher precedence. + if (grammaticalInflection || o.grammaticalInflection) return !o.grammaticalInflection; if ((screenLayout | o.screenLayout) & MASK_LAYOUTDIR) { return !(o.screenLayout & MASK_LAYOUTDIR); } @@ -971,6 +999,7 @@ bool ConfigDescription::ConflictsWith(const ConfigDescription& o) const { // The values here can be found in ResTable_config#match. Density and range // values can't lead to conflicts, and are ignored. return !pred(mcc, o.mcc) || !pred(mnc, o.mnc) || !pred(locale, o.locale) || + !pred(grammaticalInflection, o.grammaticalInflection) || !pred(screenLayout & MASK_LAYOUTDIR, o.screenLayout & MASK_LAYOUTDIR) || !pred(screenLayout & MASK_SCREENLONG, |