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

Commit 91fdcd6e authored by Wilson Wu's avatar Wilson Wu Committed by Android (Google) Code Review
Browse files

Merge "Prevent InputMethodManager call into DelegateImpl (2/N)"

parents 5baed8b6 f59c93b2
Loading
Loading
Loading
Loading
+18 −11
Original line number Original line Diff line number Diff line
@@ -723,14 +723,8 @@ public final class InputMethodManager {
            ImeTracing.getInstance().triggerClientDump(
            ImeTracing.getInstance().triggerClientDump(
                    "InputMethodManager.DelegateImpl#startInput", InputMethodManager.this,
                    "InputMethodManager.DelegateImpl#startInput", InputMethodManager.this,
                    null /* icProto */);
                    null /* icProto */);
            synchronized (mH) {
            return startInputOnWindowFocusGainInternal(startInputReason, focusedView,
                mCurrentEditorInfo = null;
                    startInputFlags, softInputMode, windowFlags);
                mCompletions = null;
                mServedConnecting = true;
            }
            return startInputInner(startInputReason,
                    focusedView != null ? focusedView.getWindowToken() : null, startInputFlags,
                    softInputMode, windowFlags);
        }
        }


        /**
        /**
@@ -805,7 +799,7 @@ public final class InputMethodManager {
                // should be done in conjunction with telling the system service
                // should be done in conjunction with telling the system service
                // about the window gaining focus, to help make the transition
                // about the window gaining focus, to help make the transition
                // smooth.
                // smooth.
                if (startInput(StartInputReason.WINDOW_FOCUS_GAIN,
                if (startInputOnWindowFocusGainInternal(StartInputReason.WINDOW_FOCUS_GAIN,
                        focusedView, startInputFlags, softInputMode, windowFlags)) {
                        focusedView, startInputFlags, softInputMode, windowFlags)) {
                    return;
                    return;
                }
                }
@@ -929,6 +923,19 @@ public final class InputMethodManager {
        }
        }
    }
    }


    private boolean startInputOnWindowFocusGainInternal(@StartInputReason int startInputReason,
            View focusedView, @StartInputFlags int startInputFlags,
            @SoftInputModeFlags int softInputMode, int windowFlags) {
        synchronized (mH) {
            mCurrentEditorInfo = null;
            mCompletions = null;
            mServedConnecting = true;
        }
        return startInputInner(startInputReason,
                focusedView != null ? focusedView.getWindowToken() : null, startInputFlags,
                softInputMode, windowFlags);
    }

    @GuardedBy("mH")
    @GuardedBy("mH")
    private View getServedViewLocked() {
    private View getServedViewLocked() {
        return mCurRootView != null ? mCurRootView.getImeFocusController().getServedViewLocked()
        return mCurRootView != null ? mCurRootView.getImeFocusController().getServedViewLocked()
@@ -1141,7 +1148,7 @@ public final class InputMethodManager {
                                    .checkFocus(mRestartOnNextWindowFocus, false)) {
                                    .checkFocus(mRestartOnNextWindowFocus, false)) {
                                final int reason = active ? StartInputReason.ACTIVATED_BY_IMMS
                                final int reason = active ? StartInputReason.ACTIVATED_BY_IMMS
                                        : StartInputReason.DEACTIVATED_BY_IMMS;
                                        : StartInputReason.DEACTIVATED_BY_IMMS;
                                mDelegate.startInput(reason, null, 0, 0, 0);
                                startInputOnWindowFocusGainInternal(reason, null, 0, 0, 0);
                            }
                            }
                        }
                        }
                    }
                    }
@@ -2362,7 +2369,7 @@ public final class InputMethodManager {
            // The view is running on a different thread than our own, so
            // The view is running on a different thread than our own, so
            // we need to reschedule our work for over there.
            // we need to reschedule our work for over there.
            if (DEBUG) Log.v(TAG, "Starting input: reschedule to view thread");
            if (DEBUG) Log.v(TAG, "Starting input: reschedule to view thread");
            vh.post(() -> mDelegate.startInput(startInputReason, null, 0, 0, 0));
            vh.post(() -> startInputOnWindowFocusGainInternal(startInputReason, null, 0, 0, 0));
            return false;
            return false;
        }
        }