Fix NPE in getLastInputMethodSubtype

Bug: 4991393
Change-Id: I4ced2a2ca4815c7cee84a72dc6131fb8c4ee7216
This commit is contained in:
satok
2011-07-05 13:28:06 +09:00
parent 0d244a6fea
commit 0e7d7d6323

View File

@@ -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;
}