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

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

Merge "Extract out IMM.DelegateImpl#checkFocus()"

parents c9c919a6 d838e9f2
Loading
Loading
Loading
Loading
+40 −35
Original line number Diff line number Diff line
@@ -835,39 +835,7 @@ public final class InputMethodManager {
        @Override
        public boolean checkFocus(boolean forceNewFocus, boolean startInput,
                ViewRootImpl viewRootImpl) {
            synchronized (mH) {
                if (mCurRootView != viewRootImpl) {
                    return false;
                }
                if (mServedView == mNextServedView && !forceNewFocus) {
                    return false;
                }
                if (DEBUG) {
                    Log.v(TAG, "checkFocus: view=" + mServedView
                            + " next=" + mNextServedView
                            + " force=" + forceNewFocus
                            + " package="
                            + (mServedView != null ? mServedView.getContext().getPackageName()
                            : "<none>"));
                }
                // Close the connection when no next served view coming.
                if (mNextServedView == null) {
                    finishInputLocked();
                    closeCurrentInput();
                    return false;
                }
                mServedView = mNextServedView;
                if (mServedInputConnection != null) {
                    mServedInputConnection.finishComposingTextFromImm();
                }
            }

            if (startInput) {
                startInputOnWindowFocusGainInternal(StartInputReason.CHECK_FOCUS,
                        null /* focusedView */,
                        0 /* startInputFlags */, 0 /* softInputMode */, 0 /* windowFlags */);
            }
            return true;
            return checkFocusInternal(forceNewFocus, startInput, viewRootImpl);
        }

        @Override
@@ -2371,8 +2339,8 @@ public final class InputMethodManager {
    }

    /**
     * Called when {@link DelegateImpl#checkFocus}, {@link #restartInput(View)},
     * {@link #MSG_BIND} or {@link #MSG_UNBIND}.
     * Called from {@link #checkFocusInternal(boolean, boolean, ViewRootImpl)},
     * {@link #restartInput(View)}, {@link #MSG_BIND} or {@link #MSG_UNBIND}.
     * Note that this method should *NOT* be called inside of {@code mH} lock to prevent start input
     * background thread may blocked by other methods which already inside {@code mH} lock.
     */
@@ -2693,6 +2661,43 @@ public final class InputMethodManager {
        }
    }

    private boolean checkFocusInternal(boolean forceNewFocus, boolean startInput,
            ViewRootImpl viewRootImpl) {
        synchronized (mH) {
            if (mCurRootView != viewRootImpl) {
                return false;
            }
            if (mServedView == mNextServedView && !forceNewFocus) {
                return false;
            }
            if (DEBUG) {
                Log.v(TAG, "checkFocus: view=" + mServedView
                        + " next=" + mNextServedView
                        + " force=" + forceNewFocus
                        + " package="
                        + (mServedView != null ? mServedView.getContext().getPackageName()
                        : "<none>"));
            }
            // Close the connection when no next served view coming.
            if (mNextServedView == null) {
                finishInputLocked();
                closeCurrentInput();
                return false;
            }
            mServedView = mNextServedView;
            if (mServedInputConnection != null) {
                mServedInputConnection.finishComposingTextFromImm();
            }
        }

        if (startInput) {
            startInputOnWindowFocusGainInternal(StartInputReason.CHECK_FOCUS,
                    null /* focusedView */,
                    0 /* startInputFlags */, 0 /* softInputMode */, 0 /* windowFlags */);
        }
        return true;
    }

    @UiThread
    private void onViewFocusChangedInternal(@Nullable View view, boolean hasFocus) {
        if (view == null || view.isTemporarilyDetached()) {