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

Commit a44c775f authored by Shan Huang's avatar Shan Huang Committed by Automerger Merge Worker
Browse files

Merge "Fix IME callback not unregistered when IME is up during an IMM client...

Merge "Fix IME callback not unregistered when IME is up during an IMM client switch." into tm-dev am: 43572500 am: f8df7f60

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18699773



Change-Id: Icc9d37c4738b5b5ed908d61ea08b99c42b2a5558
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents b6932726 f8df7f60
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -807,11 +807,6 @@ public class InputMethodService extends AbstractInputMethodService {
                @NonNull EditorInfo editorInfo, boolean restarting,
                @NonNull IBinder startInputToken, @InputMethodNavButtonFlags int navButtonFlags,
                @NonNull ImeOnBackInvokedDispatcher imeDispatcher) {
            mImeDispatcher = imeDispatcher;
            if (mWindow != null) {
                mWindow.getOnBackInvokedDispatcher().setImeOnBackInvokedDispatcher(
                        imeDispatcher);
            }
            mPrivOps.reportStartInputAsync(startInputToken);
            mNavigationBarController.onNavButtonFlagsChanged(navButtonFlags);
            if (restarting) {
@@ -819,6 +814,15 @@ public class InputMethodService extends AbstractInputMethodService {
            } else {
                startInput(inputConnection, editorInfo);
            }
            // Update the IME dispatcher last, so that the previously registered back callback
            // (if any) can be unregistered using the old dispatcher if {@link #doFinishInput()}
            // is called from {@link #startInput(InputConnection, EditorInfo)} or
            // {@link #restartInput(InputConnection, EditorInfo)}.
            mImeDispatcher = imeDispatcher;
            if (mWindow != null) {
                mWindow.getOnBackInvokedDispatcher().setImeOnBackInvokedDispatcher(
                        imeDispatcher);
            }
        }

        /**
@@ -3871,6 +3875,11 @@ public class InputMethodService extends AbstractInputMethodService {
    };

    private void compatHandleBack() {
        if (!mDecorViewVisible) {
            Log.e(TAG, "Back callback invoked on a hidden IME. Removing the callback...");
            unregisterCompatOnBackInvokedCallback();
            return;
        }
        final KeyEvent downEvent = createBackKeyEvent(
                KeyEvent.ACTION_DOWN, false /* isTracking */);
        onKeyDown(KeyEvent.KEYCODE_BACK, downEvent);