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

Commit 786f31f2 authored by Ming-Shin Lu's avatar Ming-Shin Lu
Browse files

Remove InputMethodManagerDelegate#isRestartOnNextWindowFocus

As isRestartOnNextWindowFocus is to check
InputMethodManager#mRestartOnNextWindowFocus flag if the input
connection is needed to force re-start when calling
startInputAsyncOnWindowFocusGain during gaining the window focus
from ImeFocusController#onPostWindowFocus next time.
(e.g. Switching IME apps from IME picker dialog)

Since in startInputOnWindowAyncFocusGain can just check
mRestartOnNextWindowFocus directly without exposing
isRestartOnNextWindowFocus, we could just simplied with inlining
the check logic.

Also, noticed in startInputAsyncOnWindowFocusGain has already reverted
CL[1]'s asynchronize starting input logic for some reasons, as a result,
renaming to startInputOnWindowFocusGain in case misleading.

[1]: I6aa4a664cfd0c86f75cee2457715317194bbe5e2

Bug: 244504062
Test: atest CtsInputMethodTestCases
Change-Id: I9335262136950021efb7b4b73c7eeb930e1333bb
parent ea0c2ee2
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -137,12 +137,6 @@ public final class ImeFocusController {
        boolean forceFocus = false;
        final InputMethodManagerDelegate immDelegate = getImmDelegate();
        synchronized (immDelegate.getLockObject()) {
            // TODO(b/244504062): Remove isRestartOnNextWindowFocus.
            if (immDelegate.isRestartOnNextWindowFocus(true /* reset */)) {
                if (DEBUG) Log.v(TAG, "Restarting due to isRestartOnNextWindowFocus as true");
                forceFocus = true;
            }

            // Update mNextServedView when focusedView changed.
            onViewFocusChanged(viewForWindowFocus, true);

@@ -155,7 +149,7 @@ public final class ImeFocusController {
            }
        }

        immDelegate.startInputAsyncOnWindowFocusGain(viewForWindowFocus,
        immDelegate.startInputOnWindowFocusGain(viewForWindowFocus,
                windowAttribute.softInputMode, windowAttribute.flags, forceFocus);
    }

@@ -321,7 +315,7 @@ public final class ImeFocusController {
         * {@link InputMethodManagerDelegate#getLockObject()} while {@link InputMethodManager}
         * calling into app-code in different threads.
         */
        void startInputAsyncOnWindowFocusGain(View rootView,
        void startInputOnWindowFocusGain(View rootView,
                @WindowManager.LayoutParams.SoftInputModeFlags int softInputMode, int windowFlags,
                boolean forceNewFocus);
        void finishInput();
@@ -330,7 +324,6 @@ public final class ImeFocusController {
        void finishComposingText();
        void setCurrentRootView(ViewRootImpl rootView);
        boolean isCurrentRootView(ViewRootImpl rootView);
        boolean isRestartOnNextWindowFocus(boolean reset);
        boolean hasActiveConnection(View view);

        /**
+11 −16
Original line number Diff line number Diff line
@@ -771,10 +771,10 @@ public final class InputMethodManager {
        }

        /**
         * For {@link ImeFocusController} to start input asynchronously when focus gain.
         * For {@link ImeFocusController} to start input when gaining the window focus.
         */
        @Override
        public void startInputAsyncOnWindowFocusGain(View focusedView,
        public void startInputOnWindowFocusGain(View focusedView,
                @SoftInputModeFlags int softInputMode, int windowFlags, boolean forceNewFocus) {
            int startInputFlags = getStartInputFlags(focusedView, 0);
            startInputFlags |= StartInputFlags.WINDOW_GAINED_FOCUS;
@@ -787,6 +787,15 @@ public final class InputMethodManager {
            if (controller == null) {
                return;
            }

            synchronized (mH) {
                if (mRestartOnNextWindowFocus) {
                    if (DEBUG) Log.v(TAG, "Restarting due to mRestartOnNextWindowFocus as true");
                    mRestartOnNextWindowFocus = false;
                    forceNewFocus = true;
                }
            }

            if (controller.checkFocus(forceNewFocus, false)) {
                // We need to restart input on the current focus view.  This
                // should be done in conjunction with telling the system service
@@ -859,20 +868,6 @@ public final class InputMethodManager {
            }
        }

        /**
         * For {@link ImeFocusController#checkFocus} if needed to force check new focus.
         */
        @Override
        public boolean isRestartOnNextWindowFocus(boolean reset) {
            synchronized (mH) {
                final boolean result = mRestartOnNextWindowFocus;
                if (reset) {
                    mRestartOnNextWindowFocus = false;
                }
                return result;
            }
        }

        /**
         * Checks whether the active input connection (if any) is for the given view.
         *