aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2012-03-29 00:10:35 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-03-29 00:10:35 -0700
commitaaa9e8626a336125dbb15765a01eb078ce1ca8f6 (patch)
tree446958df8499dca2b77cb28c96f1889fbb8bd48d /java/src
parent5bf11402079424c0f5bb98e9d49f7e587d283682 (diff)
parent7769b76fc997c2afea169668ff1eee9d158b74f9 (diff)
downloadlatinime-aaa9e8626a336125dbb15765a01eb078ce1ca8f6.tar.gz
latinime-aaa9e8626a336125dbb15765a01eb078ce1ca8f6.tar.xz
latinime-aaa9e8626a336125dbb15765a01eb078ce1ca8f6.zip
Merge "Fix race condition while changing the system locale"
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LocaleUtils.java12
1 files changed, 7 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/latin/LocaleUtils.java b/java/src/com/android/inputmethod/latin/LocaleUtils.java
index e05b47cb7..cf60089c5 100644
--- a/java/src/com/android/inputmethod/latin/LocaleUtils.java
+++ b/java/src/com/android/inputmethod/latin/LocaleUtils.java
@@ -168,12 +168,14 @@ public class LocaleUtils {
* @param newLocale the locale to change to.
* @return the old locale.
*/
- public static Locale setSystemLocale(final Resources res, final Locale newLocale) {
+ public static synchronized Locale setSystemLocale(final Resources res, final Locale newLocale) {
final Configuration conf = res.getConfiguration();
- final Locale saveLocale = conf.locale;
- conf.locale = newLocale;
- res.updateConfiguration(conf, res.getDisplayMetrics());
- return saveLocale;
+ final Locale oldLocale = conf.locale;
+ if (newLocale != null && !newLocale.equals(oldLocale)) {
+ conf.locale = newLocale;
+ res.updateConfiguration(conf, res.getDisplayMetrics());
+ }
+ return oldLocale;
}
private static final HashMap<String, Locale> sLocaleCache = new HashMap<String, Locale>();