Add an API to get the last used input method subtype

Bug: 4075039

- Voice input requires to know the last used input method subtype.

Change-Id: I603a4fb88a2af5195e52188adfa6585ad80304fa
This commit is contained in:
satok
2011-04-11 14:26:04 +09:00
parent c02c97ef75
commit 68f1b78b7b
4 changed files with 31 additions and 0 deletions

View File

@ -1399,6 +1399,24 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
}
}
public InputMethodSubtype getLastInputMethodSubtype() {
synchronized (mMethodMap) {
final Pair<String, String> lastIme = mSettings.getLastInputMethodAndSubtypeLocked();
// TODO: Handle the case of the last IME with no subtypes
if (lastIme == null || TextUtils.isEmpty(lastIme.first)
|| TextUtils.isEmpty(lastIme.second)) return null;
final InputMethodInfo lastImi = mMethodMap.get(lastIme.first);
if (lastImi == null) return null;
try {
final int lastSubtypeHash = Integer.valueOf(lastIme.second);
return lastImi.getSubtypeAt(getSubtypeIdFromHashCode(
lastImi, lastSubtypeHash));
} catch (NumberFormatException e) {
return null;
}
}
}
private void setInputMethodWithSubtypeId(IBinder token, String id, int subtypeId) {
synchronized (mMethodMap) {
if (token == null) {