From 6d468c513f49a1d64e5da2c9fbe625710c75e20a Mon Sep 17 00:00:00 2001 From: satok Date: Wed, 7 Sep 2011 12:36:07 +0900 Subject: [PATCH] Fix NPE in settings Bug: 5246032 Change-Id: I452dab9bf863fb8cba142467f338088ee8b30283 --- java/src/com/android/inputmethod/deprecated/VoiceProxy.java | 4 ++-- java/src/com/android/inputmethod/latin/Settings.java | 4 ++-- java/src/com/android/inputmethod/latin/SubtypeSwitcher.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/java/src/com/android/inputmethod/deprecated/VoiceProxy.java b/java/src/com/android/inputmethod/deprecated/VoiceProxy.java index 9397483ce..a4dfa10d2 100644 --- a/java/src/com/android/inputmethod/deprecated/VoiceProxy.java +++ b/java/src/com/android/inputmethod/deprecated/VoiceProxy.java @@ -717,8 +717,8 @@ public class VoiceProxy implements VoiceInput.UiListener { mHasUsedVoiceInputUnsupportedLocale = sp.getBoolean(PREF_HAS_USED_VOICE_INPUT_UNSUPPORTED_LOCALE, false); - mLocaleSupportedForVoiceInput = SubtypeSwitcher.getInstance().isVoiceSupported( - SubtypeSwitcher.getInstance().getInputLocaleStr()); + mLocaleSupportedForVoiceInput = SubtypeSwitcher.isVoiceSupported( + mService, SubtypeSwitcher.getInstance().getInputLocaleStr()); final String voiceMode = sp.getString(PREF_VOICE_MODE, mService.getString(R.string.voice_mode_main)); diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java index e99bb7016..e0eae180d 100644 --- a/java/src/com/android/inputmethod/latin/Settings.java +++ b/java/src/com/android/inputmethod/latin/Settings.java @@ -580,8 +580,8 @@ public class Settings extends InputMethodSettingsActivity // Get the current list of supported locales and check the current locale against // that list, to decide whether to put a warning that voice input will not work in // the current language as part of the pop-up confirmation dialog. - boolean localeSupported = SubtypeSwitcher.getInstance().isVoiceSupported( - Locale.getDefault().toString()); + boolean localeSupported = SubtypeSwitcher.isVoiceSupported( + this, Locale.getDefault().toString()); final CharSequence message; if (localeSupported) { diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java index 56f14de57..f9dda6a40 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java @@ -539,14 +539,14 @@ public class SubtypeSwitcher { } - public boolean isVoiceSupported(String locale) { + public static boolean isVoiceSupported(Context context, String locale) { // Get the current list of supported locales and check the current locale against that // list. We cache this value so as not to check it every time the user starts a voice // input. Because this method is called by onStartInputView, this should mean that as // long as the locale doesn't change while the user is keeping the IME open, the // value should never be stale. String supportedLocalesString = VoiceProxy.getSupportedLocalesString( - mService.getContentResolver()); + context.getContentResolver()); List voiceInputSupportedLocales = Arrays.asList( supportedLocalesString.split("\\s+")); return voiceInputSupportedLocales.contains(locale);