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

Commit ff583166 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Pass InputMethodBindingController when possible in IMMS" into main

parents 7ef888dc 3c1d8be8
Loading
Loading
Loading
Loading
+14 −15
Original line number Diff line number Diff line
@@ -2037,7 +2037,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            @StartInputReason int startInputReason,
            int unverifiedTargetSdkVersion,
            @NonNull ImeOnBackInvokedDispatcher imeDispatcher,
            @NonNull UserDataRepository.UserData userData) {
            @NonNull InputMethodBindingController bindingController) {

        // Compute the final shown display ID with validated cs.selfReportedDisplayId for this
        // session & other conditions.
@@ -2078,7 +2078,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        final boolean connectionWasActive = mCurInputConnection != null;

        // Bump up the sequence for this client and attach it.
        final var bindingController = userData.mBindingController;
        bindingController.advanceSequenceNumber();

        mCurClient = cs;
@@ -2138,7 +2137,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                        (startInputFlags & StartInputFlags.INITIAL_CONNECTION) != 0);
            }

            InputBindResult bindResult = tryReuseConnectionLocked(userData, cs);
            InputBindResult bindResult = tryReuseConnectionLocked(bindingController, cs);
            if (bindResult != null) {
                return bindResult;
            }
@@ -2252,9 +2251,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.

    @GuardedBy("ImfLock.class")
    @Nullable
    private InputBindResult tryReuseConnectionLocked(@NonNull UserDataRepository.UserData userData,
            @NonNull ClientState cs) {
        final var bindingController = userData.mBindingController;
    private InputBindResult tryReuseConnectionLocked(
            @NonNull InputMethodBindingController bindingController, @NonNull ClientState cs) {
        if (bindingController.hasMainConnection()) {
            if (getCurMethodLocked() != null) {
                // Return to client, and we will get back with it when
@@ -3641,7 +3639,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                    result = startInputOrWindowGainedFocusInternalLocked(startInputReason,
                            client, windowToken, startInputFlags, softInputMode, windowFlags,
                            editorInfo, inputConnection, remoteAccessibilityInputConnection,
                            unverifiedTargetSdkVersion, userData, imeDispatcher, cs);
                            unverifiedTargetSdkVersion, bindingController, imeDispatcher, cs);
                } finally {
                    Binder.restoreCallingIdentity(ident);
                }
@@ -3669,7 +3667,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            @SoftInputModeFlags int softInputMode, int windowFlags, EditorInfo editorInfo,
            IRemoteInputConnection inputContext,
            @Nullable IRemoteAccessibilityInputConnection remoteAccessibilityInputConnection,
            int unverifiedTargetSdkVersion, @NonNull UserDataRepository.UserData userData,
            int unverifiedTargetSdkVersion, @NonNull InputMethodBindingController bindingController,
            @NonNull ImeOnBackInvokedDispatcher imeDispatcher, @NonNull ClientState cs) {
        if (DEBUG) {
            Slog.v(TAG, "startInputOrWindowGainedFocusInternalLocked: reason="
@@ -3682,7 +3680,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                    + " softInputMode=" + InputMethodDebug.softInputModeToString(softInputMode)
                    + " windowFlags=#" + Integer.toHexString(windowFlags)
                    + " unverifiedTargetSdkVersion=" + unverifiedTargetSdkVersion
                    + " userData=" + userData
                    + " bindingController=" + bindingController
                    + " imeDispatcher=" + imeDispatcher
                    + " cs=" + cs);
        }
@@ -3711,15 +3709,16 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            if (editorInfo != null) {
                return startInputUncheckedLocked(cs, inputContext,
                        remoteAccessibilityInputConnection, editorInfo, startInputFlags,
                        startInputReason, unverifiedTargetSdkVersion, imeDispatcher, userData);
                        startInputReason, unverifiedTargetSdkVersion, imeDispatcher,
                        bindingController);
            }
            return new InputBindResult(
                    InputBindResult.ResultCode.SUCCESS_REPORT_WINDOW_FOCUS_ONLY,
                    null, null, null, null, -1, false);
        }

        mImeBindingState = new ImeBindingState(userData.mUserId, windowToken, softInputMode, cs,
                editorInfo);
        mImeBindingState = new ImeBindingState(bindingController.mUserId, windowToken,
                softInputMode, cs, editorInfo);
        mFocusedWindowPerceptible.put(windowToken, true);

        // We want to start input before showing the IME, but after closing
@@ -3744,7 +3743,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                        res = startInputUncheckedLocked(cs, inputContext,
                                remoteAccessibilityInputConnection, editorInfo, startInputFlags,
                                startInputReason, unverifiedTargetSdkVersion,
                                imeDispatcher, userData);
                                imeDispatcher, bindingController);
                        didStart = true;
                    }
                    break;
@@ -3759,7 +3758,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                // Note that we can trust client's display ID as long as it matches
                // to the display ID obtained from the window.
                if (cs.mSelfReportedDisplayId != getCurTokenDisplayIdLocked()) {
                    userData.mBindingController.unbindCurrentMethod();
                    bindingController.unbindCurrentMethod();
                }
            }
        }
@@ -3768,7 +3767,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                res = startInputUncheckedLocked(cs, inputContext,
                        remoteAccessibilityInputConnection, editorInfo, startInputFlags,
                        startInputReason, unverifiedTargetSdkVersion,
                        imeDispatcher, userData);
                        imeDispatcher, bindingController);
            } else {
                res = InputBindResult.NULL_EDITOR_INFO;
            }