Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8a0e78af authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Stop supporting null IME token in IMM#setInputMethodAndSubtype()"

parents c3925ebc 4773ee18
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -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);
+0 −2
Original line number Diff line number Diff line
@@ -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();
+3 −3
Original line number Diff line number Diff line
@@ -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) {
+0 −6
Original line number Diff line number Diff line
@@ -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) {