From 17dc363a63a20d18cd8161f917899b39aed6ddd6 Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Fri, 20 Aug 2010 18:28:22 +0900 Subject: [PATCH] Fix an NPE found in KeyboardSwitcher.isAlphabetMode() Change-Id: I03d3d9b25147632d25c1502f796acad4cdaeb239 --- java/src/com/android/inputmethod/latin/KeyboardSwitcher.java | 3 +++ java/src/com/android/inputmethod/latin/LatinIME.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java index d04930303..88a2b8398 100644 --- a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java @@ -335,6 +335,9 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } boolean isAlphabetMode() { + if (mCurrentId == null) { + return false; + } int currentMode = mCurrentId.mKeyboardMode; for (Integer mode : ALPHABET_MODES) { if (currentMode == mode) { diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 9bd16adb2..0f724f00a 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -968,7 +968,7 @@ public class LatinIME extends InputMethodService public void updateShiftKeyState(EditorInfo attr) { InputConnection ic = getCurrentInputConnection(); - if (attr != null && mKeyboardSwitcher.isAlphabetMode() && ic != null) { + if (ic != null && attr != null && mKeyboardSwitcher.isAlphabetMode()) { mKeyboardSwitcher.setShifted(mCapsLock || getCursorCapsMode(ic, attr) != 0); } }