summaryrefslogtreecommitdiffstats
path: root/telephony
diff options
context:
space:
mode:
authorRobert Greenwalt <robdroid@android.com>2009-05-06 11:53:25 -0700
committerRobert Greenwalt <robdroid@android.com>2009-05-06 12:00:01 -0700
commit027405155ff25ebe760dff03128519fb13cb8311 (patch)
treea1019a13199397fb778a84e66b46d0e17b6d4c08 /telephony
parentfd445d3510cddc7a67cf7720935626684a2f3011 (diff)
downloadframeworks_base-027405155ff25ebe760dff03128519fb13cb8311.zip
frameworks_base-027405155ff25ebe760dff03128519fb13cb8311.tar.gz
frameworks_base-027405155ff25ebe760dff03128519fb13cb8311.tar.bz2
Fix Phone-based locale selection to never choose a lang-only locale.
This avoids us using the non-standard lang-only locale when communicating off device. Fixes 1810133.
Diffstat (limited to 'telephony')
-rw-r--r--telephony/java/com/android/internal/telephony/PhoneBase.java21
1 files changed, 8 insertions, 13 deletions
diff --git a/telephony/java/com/android/internal/telephony/PhoneBase.java b/telephony/java/com/android/internal/telephony/PhoneBase.java
index 20c54fb..1ff0f7e 100644
--- a/telephony/java/com/android/internal/telephony/PhoneBase.java
+++ b/telephony/java/com/android/internal/telephony/PhoneBase.java
@@ -490,7 +490,7 @@ public abstract class PhoneBase implements Phone {
if (null == language) {
return; // no match possible
}
- language.toLowerCase();
+ language = language.toLowerCase();
if (null == country) {
country = "";
}
@@ -503,13 +503,12 @@ public abstract class PhoneBase implements Phone {
final int N = locales.length;
String bestMatch = null;
for(int i = 0; i < N; i++) {
- if (locales[i]!=null && locales[i].length() >= 2 &&
+ // only match full (lang + country) locales
+ if (locales[i]!=null && locales[i].length() >= 5 &&
locales[i].substring(0,2).equals(language)) {
- if (locales[i].length() >= 5) {
- if (locales[i].substring(3,5).equals(country)) {
- bestMatch = locales[i];
- break;
- }
+ if (locales[i].substring(3,5).equals(country)) {
+ bestMatch = locales[i];
+ break;
} else if (null == bestMatch) {
bestMatch = locales[i];
}
@@ -518,12 +517,8 @@ public abstract class PhoneBase implements Phone {
if (null != bestMatch) {
IActivityManager am = ActivityManagerNative.getDefault();
Configuration config = am.getConfiguration();
- if (bestMatch.length() >= 5) {
- config.locale = new Locale(bestMatch.substring(0,2),
- bestMatch.substring(3,5));
- } else {
- config.locale = new Locale(bestMatch.substring(0,2));
- }
+ config.locale = new Locale(bestMatch.substring(0,2),
+ bestMatch.substring(3,5));
config.userSetLocale = true;
am.updateConfiguration(config);
}