summaryrefslogtreecommitdiff
path: root/services/java/com/android/server/InputMethodManagerService.java
diff options
context:
space:
mode:
authorsatok <satok@google.com>2011-07-05 13:28:06 +0900
committersatok <satok@google.com>2011-07-05 13:32:15 +0900
commit0e7d7d632309409e2bc51d5317cf7a92a7541433 (patch)
tree11d50dc576f559345009f57906f136a75c1cec0b /services/java/com/android/server/InputMethodManagerService.java
parent0d244a6fead28ca140bfd6dd42ef0339da752e36 (diff)
Fix NPE in getLastInputMethodSubtype
Bug: 4991393 Change-Id: I4ced2a2ca4815c7cee84a72dc6131fb8c4ee7216
Diffstat (limited to 'services/java/com/android/server/InputMethodManagerService.java')
-rw-r--r--services/java/com/android/server/InputMethodManagerService.java7
1 files changed, 5 insertions, 2 deletions
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index 14abf808b71f..2d55433d9cd0 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -1623,8 +1623,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
if (lastImi == null) return null;
try {
final int lastSubtypeHash = Integer.valueOf(lastIme.second);
- return lastImi.getSubtypeAt(getSubtypeIdFromHashCode(
- lastImi, lastSubtypeHash));
+ final int lastSubtypeId = getSubtypeIdFromHashCode(lastImi, lastSubtypeHash);
+ if (lastSubtypeId < 0 || lastSubtypeId >= lastImi.getSubtypeCount()) {
+ return null;
+ }
+ return lastImi.getSubtypeAt(lastSubtypeId);
} catch (NumberFormatException e) {
return null;
}