aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2012-03-29 14:36:45 +0900
committerTadashi G. Takaoka <takaoka@google.com>2012-03-29 14:36:45 +0900
commit7769b76fc997c2afea169668ff1eee9d158b74f9 (patch)
treebd17c30ebb0ac3dbb69ad6ae0ac3391df72cfcce /java/src
parentfc50a410782008e510fb95aa69d583a8f8e40c3f (diff)
downloadlatinime-7769b76fc997c2afea169668ff1eee9d158b74f9.tar.gz
latinime-7769b76fc997c2afea169668ff1eee9d158b74f9.tar.xz
latinime-7769b76fc997c2afea169668ff1eee9d158b74f9.zip
Fix race condition while changing the system locale
Bug: 6128216 Change-Id: Ie153e3eb18feeb97aada6a7708075f5152f11999
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>();