From c7ca36845edb9937f7f9d09d50505ade3c8abf9f Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Sun, 9 Sep 2018 20:48:38 -0700 Subject: Stop relying on IMM in IMS for token-guarded IME APIs This is a follow up CL to previous CLs [1][2][3] that made sure that APIs that are exposed only to IMEs should live in InputMethodService instead of InputMethodManager. Now that we have a dedicated Binder inferface [4] that allows InputMethodService (IMS) to directly send IPCs to InputMethodManagerService (IMMS) without relying on InputMethodManager (IMM), it is natural for the above public APIs in IMS to stop relying on IMM. This CL also addresses a small concern that it is no longer obvious when those APIs become available. Previously, it was a bit more obvious that passing null IME token doesn't work so IME developers could imagine that those APIs were unavailable until attachToken() is called. With this CL, InputMethodPrivilegedOperations starts showing warning messages when called too early, which we hope help IME developers understand why those APIs do nothing when called too early. [1]: I3163f3cbe557c85103ca287bee0874a3b4194032 d8d03a8e1b5b7f4b05d7f99a19d356ffd95edb58 [2]: If6a786c5774805d041ea9672ef2721e4a38df7fc fbc2f7acd581eca7180a3d916936fb4e758279e1 [3]: I6efd5ca473e33e6faeadb7eea7772b9d2b8ca12b 164cfba536644095b962b45379020a792d3c51c8 [4]: I2f3ec3c5de546fb3603275a4b64000ed3f863b65 c54c1171640519ae0ad8da1f32477295d96db1b8 Bug: 114418674 Test: atest CtsInputMethodTestCases CtsInputMethodServiceHostTestCases Change-Id: I995c4b922f91b94438c1292392b2c3030598594f --- .../android/inputmethodservice/InputMethodService.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'core/java/android/inputmethodservice/InputMethodService.java') diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index d3abe7f38808..7f259e2f9f4c 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -1170,7 +1170,7 @@ public class InputMethodService extends AbstractInputMethodService { * used input method and subtype. */ public final boolean switchToPreviousInputMethod() { - return mImm.switchToPreviousInputMethodInternal(mToken); + return mPrivOps.switchToPreviousInputMethod(); } /** @@ -1182,7 +1182,7 @@ public class InputMethodService extends AbstractInputMethodService { * input method and subtype. */ public final boolean switchToNextInputMethod(boolean onlyCurrentIme) { - return mImm.switchToNextInputMethodInternal(mToken, onlyCurrentIme); + return mPrivOps.switchToNextInputMethod(onlyCurrentIme); } /** @@ -1195,7 +1195,7 @@ public class InputMethodService extends AbstractInputMethodService { * between IMEs and subtypes. */ public final boolean shouldOfferSwitchingToNextInputMethod() { - return mImm.shouldOfferSwitchingToNextInputMethodInternal(mToken); + return mPrivOps.shouldOfferSwitchingToNextInputMethod(); } public boolean getCurrentInputStarted() { @@ -1513,12 +1513,12 @@ public class InputMethodService extends AbstractInputMethodService { public void showStatusIcon(@DrawableRes int iconResId) { mStatusIcon = iconResId; - mImm.showStatusIconInternal(mToken, getPackageName(), iconResId); + mPrivOps.updateStatusIcon(getPackageName(), iconResId); } public void hideStatusIcon() { mStatusIcon = 0; - mImm.hideStatusIconInternal(mToken); + mPrivOps.updateStatusIcon(null, 0); } /** @@ -1529,7 +1529,7 @@ public class InputMethodService extends AbstractInputMethodService { * @param id Unique identifier of the new input method to start. */ public void switchInputMethod(String id) { - mImm.setInputMethodInternal(mToken, id); + mPrivOps.setInputMethod(id); } /** @@ -1541,7 +1541,7 @@ public class InputMethodService extends AbstractInputMethodService { * @param subtype The new subtype of the new input method to be switched to. */ public final void switchInputMethod(String id, InputMethodSubtype subtype) { - mImm.setInputMethodAndSubtypeInternal(mToken, id, subtype); + mPrivOps.setInputMethodAndSubtype(id, subtype); } public void setExtractView(View view) { @@ -2132,7 +2132,7 @@ public class InputMethodService extends AbstractInputMethodService { * @param flags Provides additional operating flags. */ public void requestHideSelf(int flags) { - mImm.hideSoftInputFromInputMethodInternal(mToken, flags); + mPrivOps.hideMySoftInput(flags); } /** @@ -2144,7 +2144,7 @@ public class InputMethodService extends AbstractInputMethodService { * @param flags Provides additional operating flags. */ public final void requestShowSelf(int flags) { - mImm.showSoftInputFromInputMethodInternal(mToken, flags); + mPrivOps.showMySoftInput(flags); } private boolean handleBack(boolean doIt) { -- cgit v1.2.3