diff options
author | 2013-10-04 20:24:41 +0900 | |
---|---|---|
committer | 2013-10-04 22:04:59 +0900 | |
commit | 43a8a0c5270a54742dcfff9dc441cf2747cb4e06 (patch) | |
tree | a47ddfab3f656dc3f44fba64620fdf1292233f02 /java/src | |
parent | 14d31d464037c31e7f7d382a8a86f6acf4694b06 (diff) | |
download | latinime-43a8a0c5270a54742dcfff9dc441cf2747cb4e06.tar.gz latinime-43a8a0c5270a54742dcfff9dc441cf2747cb4e06.tar.xz latinime-43a8a0c5270a54742dcfff9dc441cf2747cb4e06.zip |
Fallback on empty locales.
This is a very rare corner case.
Bug: 11072132
Change-Id: Iad2aa69511f7dc99105284a049c63f2f997b8ef0
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 0f3d28976..d85a8a3ae 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -605,8 +605,24 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } private void initSuggest() { - final Locale subtypeLocale = mSubtypeSwitcher.getCurrentSubtypeLocale(); - final String localeStr = subtypeLocale.toString(); + final Locale switcherSubtypeLocale = mSubtypeSwitcher.getCurrentSubtypeLocale(); + final String switcherLocaleStr = switcherSubtypeLocale.toString(); + final Locale subtypeLocale; + final String localeStr; + if (TextUtils.isEmpty(switcherLocaleStr)) { + // This happens in very rare corner cases - for example, immediately after a switch + // to LatinIME has been requested, about a frame later another switch happens. In this + // case, we are about to go down but we still don't know it, however the system tells + // us there is no current subtype so the locale is the empty string. Take the best + // possible guess instead -- it's bound to have no consequences, and we have no way + // of knowing anyway. + Log.e(TAG, "System is reporting no current subtype."); + subtypeLocale = getResources().getConfiguration().locale; + localeStr = subtypeLocale.toString(); + } else { + subtypeLocale = switcherSubtypeLocale; + localeStr = switcherLocaleStr; + } final Suggest newSuggest = new Suggest(this /* Context */, subtypeLocale, this /* SuggestInitializationListener */); |