summaryrefslogtreecommitdiffstats
path: root/libs/androidfw
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2015-03-10 16:55:43 -0700
committerAdam Lesinski <adamlesinski@google.com>2015-03-16 22:25:26 +0000
commit8a9355a98ece3d7fc9d022e759d05378060c86e2 (patch)
treed6d76f94f2688f9bcee4c961dafc4cc3ec97a6bd /libs/androidfw
parent9c329b8b6440823ef94bffebc0b1098e8b2ad622 (diff)
downloadframeworks_base-8a9355a98ece3d7fc9d022e759d05378060c86e2.zip
frameworks_base-8a9355a98ece3d7fc9d022e759d05378060c86e2.tar.gz
frameworks_base-8a9355a98ece3d7fc9d022e759d05378060c86e2.tar.bz2
Output modified bcp47 tag in ResTable_config::toString()
We expect to be able to parse the output of ResTable_config::toString(), so it should use modified bcp47 (b+en+Latn+US). Change-Id: I597a1779a1fa5cff171c473e6a0368d93b9c7722
Diffstat (limited to 'libs/androidfw')
-rw-r--r--libs/androidfw/ResourceTypes.cpp59
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("-");