diff options
| author | Yohei Yukawa <yukawa@google.com> | 2018-12-24 21:13:53 -0800 |
|---|---|---|
| committer | Yohei Yukawa <yukawa@google.com> | 2018-12-24 21:13:53 -0800 |
| commit | 4773ee18a204bac6ae724875a7e6c54ab626ba59 (patch) | |
| tree | a54e1077ff5492c7bb8fa5cd49675171c3b328bf /core/java | |
| parent | 2232e861862566418da649290d86f7d2734fffb7 (diff) | |
Stop supporting null IME token in IMM#setInputMethodAndSubtype()
Hopefully no one has relied on this undocumented behavior that when
the caller has WRITE_SECURE_SETTINGS then null IME token is allowed in
IMM#setInputMethodAndSubtype().
Note that if the caller had WRITE_SECURE_SETTINGS they can achieve the
same goal by directly updating the following secure settings:
* Settings.Secure.DEFAULT_INPUT_METHOD
* Settings.Secure.SELECTED_INPUT_METHOD_SUBTYPE
Bug: 114488811
Test: CtsInputMethodServiceHostTestCases
Change-Id: Ic5c59299ace16778fc57a4ec2639508564f416a7
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/view/inputmethod/InputMethodManager.java | 19 | ||||
| -rw-r--r-- | core/java/com/android/internal/view/IInputMethodManager.aidl | 2 |
2 files changed, 10 insertions, 11 deletions
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index e57fdffdfd1a..f4eda264c101 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -2091,6 +2091,12 @@ public final class InputMethodManager { /** * Force switch to a new input method and subtype. This can only be called * from an application or a service which has a token of the currently active input method. + * + * <p>On Android {@link Build.VERSION_CODES#Q} and later devices, {@code token} cannot be + * {@code null} even with {@link android.Manifest.permission#WRITE_SECURE_SETTINGS}. Instead, + * update {@link android.provider.Settings.Secure#DEFAULT_INPUT_METHOD} and + * {@link android.provider.Settings.Secure#SELECTED_INPUT_METHOD_SUBTYPE} directly.</p> + * * @param token Supplies the identifying token given to an input method * when it was started, which allows it to perform this operation on * itself. @@ -2102,16 +2108,11 @@ public final class InputMethodManager { * the service. APIs in this class are intended for app developers interacting with the IME. */ @Deprecated - public void setInputMethodAndSubtype(IBinder token, String id, InputMethodSubtype subtype) { + public void setInputMethodAndSubtype(@NonNull IBinder token, String id, + InputMethodSubtype subtype) { if (token == null) { - // Note: null token is allowed for callers that have WRITE_SECURE_SETTINGS permission. - // Thus we cannot always rely on InputMethodPrivilegedOperationsRegistry unfortunately. - // TODO(Bug 114488811): Consider deprecating null token rule. - try { - mService.setInputMethodAndSubtype(token, id, subtype); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } + Log.e(TAG, "setInputMethodAndSubtype() does not accept null token on Android Q " + + "and later."); return; } InputMethodPrivilegedOperationsRegistry.get(token).setInputMethodAndSubtype(id, subtype); diff --git a/core/java/com/android/internal/view/IInputMethodManager.aidl b/core/java/com/android/internal/view/IInputMethodManager.aidl index f62c4402cb4e..a18f9c5082f2 100644 --- a/core/java/com/android/internal/view/IInputMethodManager.aidl +++ b/core/java/com/android/internal/view/IInputMethodManager.aidl @@ -70,8 +70,6 @@ interface IInputMethodManager { boolean isInputMethodPickerShownForTest(); // TODO(Bug 114488811): this can be removed once we deprecate special null token rule. void setInputMethod(in IBinder token, String id); - // TODO(Bug 114488811): this can be removed once we deprecate special null token rule. - void setInputMethodAndSubtype(in IBinder token, String id, in InputMethodSubtype subtype); void registerSuggestionSpansForNotification(in SuggestionSpan[] spans); boolean notifySuggestionPicked(in SuggestionSpan span, String originalString, int index); InputMethodSubtype getCurrentInputMethodSubtype(); |
