diff options
author | Adam Lesinski <adamlesinski@google.com> | 2015-03-20 20:46:39 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-03-20 20:46:40 +0000 |
commit | 47fe60a643d5d138ee3b0d836a1c4ab8b6e5b730 (patch) | |
tree | b50fada585a400bb915cb2cbc44e4c31eda85588 /libs | |
parent | 0964cfc384398cdacd82030649b9c43b95ffa970 (diff) | |
parent | 8a9355a98ece3d7fc9d022e759d05378060c86e2 (diff) | |
download | frameworks_base-47fe60a643d5d138ee3b0d836a1c4ab8b6e5b730.zip frameworks_base-47fe60a643d5d138ee3b0d836a1c4ab8b6e5b730.tar.gz frameworks_base-47fe60a643d5d138ee3b0d836a1c4ab8b6e5b730.tar.bz2 |
Merge "Output modified bcp47 tag in ResTable_config::toString()"
Diffstat (limited to 'libs')
-rw-r--r-- | libs/androidfw/ResourceTypes.cpp | 59 |
1 files changed, 53 insertions, 6 deletions
diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp index d5d583c..e247150 100644 --- a/libs/androidfw/ResourceTypes.cpp +++ b/libs/androidfw/ResourceTypes.cpp @@ -2550,6 +2550,58 @@ bool ResTable_config::match(const ResTable_config& settings) const { return true; } +void ResTable_config::appendDirLocale(String8& out) const { + if (!language[0]) { + return; + } + + if (!localeScript[0] && !localeVariant[0]) { + // Legacy format. + if (out.size() > 0) { + out.append("-"); + } + + char buf[4]; + size_t len = unpackLanguage(buf); + out.append(buf, len); + + if (country[0]) { + out.append("-r"); + len = unpackRegion(buf); + out.append(buf, len); + } + return; + } + + // We are writing the modified bcp47 tag. + // It starts with 'b+' and uses '+' as a separator. + + if (out.size() > 0) { + out.append("-"); + } + out.append("b+"); + + char buf[4]; + size_t len = unpackLanguage(buf); + out.append(buf, len); + + if (localeScript[0]) { + out.append("+"); + out.append(localeScript, sizeof(localeScript)); + } + + if (country[0]) { + out.append("+"); + len = unpackRegion(buf); + out.append(buf, len); + } + + if (localeVariant[0]) { + out.append("+"); + out.append(localeVariant, sizeof(localeVariant)); + } +} + void ResTable_config::getBcp47Locale(char str[RESTABLE_MAX_LOCALE_LEN]) const { memset(str, 0, RESTABLE_MAX_LOCALE_LEN); @@ -2650,12 +2702,7 @@ String8 ResTable_config::toString() const { res.appendFormat("mnc%d", dtohs(mnc)); } - char localeStr[RESTABLE_MAX_LOCALE_LEN]; - getBcp47Locale(localeStr); - if (strlen(localeStr) > 0) { - if (res.size() > 0) res.append("-"); - res.append(localeStr); - } + appendDirLocale(res); if ((screenLayout&MASK_LAYOUTDIR) != 0) { if (res.size() > 0) res.append("-"); |