Loading core/java/android/view/inputmethod/InputMethodManager.java +10 −9 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -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); Loading core/java/com/android/internal/view/IInputMethodManager.aidl +0 −2 Original line number Diff line number Diff line Loading @@ -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(); Loading services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +3 −3 Original line number Diff line number Diff line Loading @@ -3087,10 +3087,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } @Override public void setInputMethodAndSubtype(IBinder token, String id, InputMethodSubtype subtype) { @BinderThread private void setInputMethodAndSubtype(IBinder token, String id, InputMethodSubtype subtype) { synchronized (mMethodMap) { if (!calledFromValidUserLocked()) { if (!calledWithValidTokenLocked(token)) { return; } if (subtype != null) { Loading services/core/java/com/android/server/inputmethod/MultiClientInputMethodManagerService.java +0 −6 Original line number Diff line number Diff line Loading @@ -1566,12 +1566,6 @@ public final class MultiClientInputMethodManagerService { reportNotSupported(); } @BinderThread @Override public void setInputMethodAndSubtype(IBinder token, String id, InputMethodSubtype subtype) { reportNotSupported(); } @BinderThread @Override public void registerSuggestionSpansForNotification(SuggestionSpan[] suggestionSpans) { Loading Loading
core/java/android/view/inputmethod/InputMethodManager.java +10 −9 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -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); Loading
core/java/com/android/internal/view/IInputMethodManager.aidl +0 −2 Original line number Diff line number Diff line Loading @@ -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(); Loading
services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +3 −3 Original line number Diff line number Diff line Loading @@ -3087,10 +3087,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } @Override public void setInputMethodAndSubtype(IBinder token, String id, InputMethodSubtype subtype) { @BinderThread private void setInputMethodAndSubtype(IBinder token, String id, InputMethodSubtype subtype) { synchronized (mMethodMap) { if (!calledFromValidUserLocked()) { if (!calledWithValidTokenLocked(token)) { return; } if (subtype != null) { Loading
services/core/java/com/android/server/inputmethod/MultiClientInputMethodManagerService.java +0 −6 Original line number Diff line number Diff line Loading @@ -1566,12 +1566,6 @@ public final class MultiClientInputMethodManagerService { reportNotSupported(); } @BinderThread @Override public void setInputMethodAndSubtype(IBinder token, String id, InputMethodSubtype subtype) { reportNotSupported(); } @BinderThread @Override public void registerSuggestionSpansForNotification(SuggestionSpan[] suggestionSpans) { Loading