From 0eaca7aa99b052abcc0cf9edb701b6c597b2e311 Mon Sep 17 00:00:00 2001 From: satok Date: Thu, 3 Jun 2010 20:00:45 +0900 Subject: [PATCH] Fix NPE and addded logOnWarning Change-Id: I4cca905ce044c014490ada6d00a76d79a20ed885 --- .../com/android/inputmethod/latin/KeyboardSwitcher.java | 7 ++++++- java/src/com/android/inputmethod/latin/LatinIME.java | 3 ++- java/src/com/android/inputmethod/latin/LatinImeLogger.java | 7 +++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java index 56342930e..48451e783 100644 --- a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java @@ -28,6 +28,7 @@ import android.preference.PreferenceManager; public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceChangeListener { + public static final int MODE_NONE = 0; public static final int MODE_TEXT = 1; public static final int MODE_SYMBOLS = 2; public static final int MODE_PHONE = 3; @@ -74,7 +75,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha private KeyboardId mCurrentId; private Map mKeyboards; - private int mMode = MODE_TEXT; /** One of the MODE_XXX values */ + private int mMode = MODE_NONE; /** One of the MODE_XXX values */ private int mImeOptions; private int mTextMode = MODE_TEXT_QWERTY; private boolean mIsSymbols; @@ -276,6 +277,10 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha ? new KeyboardId(R.xml.kbd_phone_symbols, hasVoice) : makeSymbolsId(hasVoice); } switch (mode) { + case MODE_NONE: + LatinImeLogger.logOnWarning( + "getKeyboardId:" + mode + "," + imeOptions + "," + isSymbols); + /* fall through */ case MODE_TEXT: if (mTextMode == MODE_TEXT_ALPHA) { return new KeyboardId(R.xml.kbd_alpha, KEYBOARDMODE_NORMAL, true, hasVoice); diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index edc2e087f..520974580 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -812,7 +812,8 @@ public class LatinIME extends InputMethodService mKeyboardSwitcher = new KeyboardSwitcher(this, this); } mKeyboardSwitcher.setLanguageSwitcher(mLanguageSwitcher); - if (mKeyboardSwitcher.getInputView() != null) { + if (mKeyboardSwitcher.getInputView() != null + && mKeyboardSwitcher.getKeyboardMode() != KeyboardSwitcher.MODE_NONE) { mKeyboardSwitcher.setVoiceMode(mEnableVoice && mEnableVoiceButton, mVoiceOnPrimary); } mKeyboardSwitcher.makeKeyboards(true); diff --git a/java/src/com/android/inputmethod/latin/LatinImeLogger.java b/java/src/com/android/inputmethod/latin/LatinImeLogger.java index 9a02eb133..0cc4fa62c 100644 --- a/java/src/com/android/inputmethod/latin/LatinImeLogger.java +++ b/java/src/com/android/inputmethod/latin/LatinImeLogger.java @@ -570,6 +570,13 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang } } + public static void logOnWarning(String warning) { + if (sLogEnabled) { + sLatinImeLogger.sendLogToDropBox( + ID_EXCEPTION, new String[] {warning, ""}); + } + } + public static void onStartSuggestion() { if (sLogEnabled) { sSuggestDicMap.clear();