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

Commit 4f1033f7 authored by Yohei Yukawa's avatar Yohei Yukawa Committed by Android (Google) Code Review
Browse files

Merge "Inline ImeFocusController#onInteractive()"

parents 70c78e08 44428561
Loading
Loading
Loading
Loading
+0 −15
Original line number Diff line number Diff line
@@ -131,19 +131,6 @@ public final class ImeFocusController {
        mHasImeFocus = false;
    }

    /**
     * Calling IMS#onStartInput when the device screen-on again).
     */
    @UiThread
    public void onInteractive() {
        final InputMethodManagerDelegate immDelegate = getImmDelegate();
        if (!immDelegate.isCurrentRootView(mViewRootImpl)) {
            return;
        }
        final View focusedView = mViewRootImpl.mView.findFocus();
        onViewFocusChanged(focusedView, focusedView != null);
    }

    /**
     * @param windowAttribute {@link WindowManager.LayoutParams} to be checked.
     * @return Whether the window is in local focus mode or not.
@@ -179,8 +166,6 @@ public final class ImeFocusController {
        boolean checkFocus(boolean forceNewFocus, boolean startInput, ViewRootImpl viewRootImpl);
        void onViewDetachedFromWindow(View view, ViewRootImpl viewRootImpl);
        void onWindowDismissed(ViewRootImpl viewRootImpl);

        boolean isCurrentRootView(ViewRootImpl rootView);
    }

    /**
+13 −18
Original line number Diff line number Diff line
@@ -903,18 +903,6 @@ public final class InputMethodManager {
            mImeDispatcher.switchRootView(mCurRootView, rootView);
            mCurRootView = rootView;
        }

        /**
         * Used for {@link ImeFocusController} to return if the root view from the
         * controller is this {@link InputMethodManager} currently focused.
         * TODO: Address event-order problem when get current root view in multi-threads.
         */
        @Override
        public boolean isCurrentRootView(ViewRootImpl rootView) {
            synchronized (mH) {
                return mCurRootView == rootView;
            }
        }
    }

    /** @hide */
@@ -1182,17 +1170,24 @@ public final class InputMethodManager {
                    synchronized (mH) {
                        mActive = interactive;
                        mFullscreenMode = fullscreen;

                        if (interactive) {
                            // Report active state to ImeFocusController to handle IME input
                            // connection lifecycle callback when it allowed.
                            final ImeFocusController controller = getFocusController();
                            final View rootView =
                                    mCurRootView != null ? mCurRootView.getView() : null;
                            if (controller == null || rootView == null) {
                            if (rootView == null) {
                                return;
                            }
                            rootView.post(controller::onInteractive);
                            // Find the next view focus to start the input connection when the
                            // device was interactive.
                            final ViewRootImpl currentViewRootImpl = mCurRootView;
                            rootView.post(() -> {
                                synchronized (mH) {
                                    if (mCurRootView != currentViewRootImpl) {
                                        return;
                                    }
                                }
                                final View focusedView = currentViewRootImpl.getView().findFocus();
                                onViewFocusChangedInternal(focusedView, focusedView != null);
                            });
                        } else {
                            finishInputLocked();
                            if (isImeSessionAvailableLocked()) {