summaryrefslogtreecommitdiffstats
path: root/libs/androidfw
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2014-07-02 15:41:13 -0700
committerNick Kralevich <nnk@google.com>2014-07-02 15:41:21 -0700
commita00144ca898ec23c02d3cc4be0ce1bdfee53faf3 (patch)
tree3bf63c7526eb13b93d51fbf251206f401d087a35 /libs/androidfw
parent6df71c76e05c6ca95c09940558911b9899ecccf9 (diff)
parenta8dbd7b433c2fff81881b5750529689d16f7f06b (diff)
downloadframeworks_base-a00144ca898ec23c02d3cc4be0ce1bdfee53faf3.zip
frameworks_base-a00144ca898ec23c02d3cc4be0ce1bdfee53faf3.tar.gz
frameworks_base-a00144ca898ec23c02d3cc4be0ce1bdfee53faf3.tar.bz2
resolved conflicts for merge of a8dbd7b4 to master
Change-Id: I90f42546c6d0a8f21af3041e59baf6a226247b1c
Diffstat (limited to 'libs/androidfw')
-rw-r--r--libs/androidfw/AssetManager.cpp57
1 files changed, 56 insertions, 1 deletions
diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp
index 0340928..19265f6 100644
--- a/libs/androidfw/AssetManager.cpp
+++ b/libs/androidfw/AssetManager.cpp
@@ -358,6 +358,15 @@ void AssetManager::setLocale(const char* locale)
setLocaleLocked(locale);
}
+
+static const char kFilPrefix[] = "fil";
+static const char kTlPrefix[] = "tl";
+
+// The sizes of the prefixes, excluding the 0 suffix.
+// char.
+static const int kFilPrefixLen = sizeof(kFilPrefix) - 1;
+static const int kTlPrefixLen = sizeof(kTlPrefix) - 1;
+
void AssetManager::setLocaleLocked(const char* locale)
{
if (mLocale != NULL) {
@@ -366,8 +375,44 @@ void AssetManager::setLocaleLocked(const char* locale)
//mZipSet.purgeLocale();
delete[] mLocale;
}
+
+
+ // If we're attempting to set a locale that starts with "fil",
+ // we should convert it to "tl" for backwards compatibility since
+ // we've been using "tl" instead of "fil" prior to L.
+ //
+ // If the resource table already has entries for "fil", we use that
+ // instead of attempting a fallback.
+ if (strncmp(locale, kFilPrefix, kFilPrefixLen) == 0) {
+ Vector<String8> locales;
+ getLocales(&locales);
+ const size_t localesSize = locales.size();
+ bool hasFil = false;
+ for (size_t i = 0; i < localesSize; ++i) {
+ if (locales[i].find(kFilPrefix) == 0) {
+ hasFil = true;
+ break;
+ }
+ }
+
+
+ if (!hasFil) {
+ const size_t newLocaleLen = strlen(locale);
+ // This isn't a bug. We really do want mLocale to be 1 byte
+ // shorter than locale, because we're replacing "fil-" with
+ // "tl-".
+ mLocale = new char[newLocaleLen];
+ // Copy over "tl".
+ memcpy(mLocale, kTlPrefix, kTlPrefixLen);
+ // Copy the rest of |locale|, including the terminating '\0'.
+ memcpy(mLocale + kTlPrefixLen, locale + kFilPrefixLen,
+ newLocaleLen - kFilPrefixLen + 1);
+ updateResourceParamsLocked();
+ return;
+ }
+ }
+
mLocale = strdupNew(locale);
-
updateResourceParamsLocked();
}
@@ -762,6 +807,16 @@ void AssetManager::getLocales(Vector<String8>* locales) const
if (res != NULL) {
res->getLocales(locales);
}
+
+ const size_t numLocales = locales->size();
+ for (size_t i = 0; i < numLocales; ++i) {
+ const String8& localeStr = locales->itemAt(i);
+ if (localeStr.find(kTlPrefix) == 0) {
+ String8 replaced("fil");
+ replaced += (localeStr.string() + kTlPrefixLen);
+ locales->editItemAt(i) = replaced;
+ }
+ }
}
/*