Reduce the transaction fee of getEnabledInputMethodSubtypeList
Bug: 8467480
Change-Id: Ic1fddfe433e097041fcb09d1fd341d77d7d8b13b
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index 4df4734..c8ce6fa 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -613,7 +613,8 @@
public List<InputMethodSubtype> getEnabledInputMethodSubtypeList(InputMethodInfo imi,
boolean allowsImplicitlySelectedSubtypes) {
try {
- return mService.getEnabledInputMethodSubtypeList(imi, allowsImplicitlySelectedSubtypes);
+ return mService.getEnabledInputMethodSubtypeList(
+ imi == null ? null : imi.getId(), allowsImplicitlySelectedSubtypes);
} catch (RemoteException e) {
throw new RuntimeException(e);
}
diff --git a/core/java/com/android/internal/view/IInputMethodManager.aidl b/core/java/com/android/internal/view/IInputMethodManager.aidl
index 82b2654..0149ef9 100644
--- a/core/java/com/android/internal/view/IInputMethodManager.aidl
+++ b/core/java/com/android/internal/view/IInputMethodManager.aidl
@@ -32,7 +32,7 @@
interface IInputMethodManager {
List<InputMethodInfo> getInputMethodList();
List<InputMethodInfo> getEnabledInputMethodList();
- List<InputMethodSubtype> getEnabledInputMethodSubtypeList(in InputMethodInfo imi,
+ List<InputMethodSubtype> getEnabledInputMethodSubtypeList(in String imiId,
boolean allowsImplicitlySelectedSubtypes);
InputMethodSubtype getLastInputMethodSubtype();
// TODO: We should change the return type from List to List<Parcelable>
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index da584e2..f442f11 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -969,19 +969,25 @@
}
/**
- * @param imi if null, returns enabled subtypes for the current imi
+ * @param imiId if null, returns enabled subtypes for the current imi
* @return enabled subtypes of the specified imi
*/
@Override
- public List<InputMethodSubtype> getEnabledInputMethodSubtypeList(InputMethodInfo imi,
+ public List<InputMethodSubtype> getEnabledInputMethodSubtypeList(String imiId,
boolean allowsImplicitlySelectedSubtypes) {
// TODO: Make this work even for non-current users?
if (!calledFromValidUser()) {
- return Collections.emptyList();
+ return Collections.<InputMethodSubtype>emptyList();
}
synchronized (mMethodMap) {
- if (imi == null && mCurMethodId != null) {
+ final InputMethodInfo imi;
+ if (imiId == null && mCurMethodId != null) {
imi = mMethodMap.get(mCurMethodId);
+ } else {
+ imi = mMethodMap.get(imiId);
+ }
+ if (imi == null) {
+ return Collections.<InputMethodSubtype>emptyList();
}
return mSettings.getEnabledInputMethodSubtypeListLocked(
mContext, imi, allowsImplicitlySelectedSubtypes);