diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 5b760a41aabd5..a4fd735bc81fe 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -718,14 +718,8 @@ public final class InputMethodManager { ImeTracing.getInstance().triggerClientDump( "InputMethodManager.DelegateImpl#startInput", InputMethodManager.this, null /* icProto */); - synchronized (mH) { - mCurrentEditorInfo = null; - mCompletions = null; - mServedConnecting = true; - } - return startInputInner(startInputReason, - focusedView != null ? focusedView.getWindowToken() : null, startInputFlags, - softInputMode, windowFlags); + return startInputOnWindowFocusGainInternal(startInputReason, focusedView, + startInputFlags, softInputMode, windowFlags); } /** @@ -800,7 +794,7 @@ public final class InputMethodManager { // should be done in conjunction with telling the system service // about the window gaining focus, to help make the transition // smooth. - if (startInput(StartInputReason.WINDOW_FOCUS_GAIN, + if (startInputOnWindowFocusGainInternal(StartInputReason.WINDOW_FOCUS_GAIN, focusedView, startInputFlags, softInputMode, windowFlags)) { return; } @@ -924,6 +918,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") private View getServedViewLocked() { return mCurRootView != null ? mCurRootView.getImeFocusController().getServedViewLocked() @@ -1136,7 +1143,7 @@ public final class InputMethodManager { .checkFocus(mRestartOnNextWindowFocus, false)) { final int reason = active ? StartInputReason.ACTIVATED_BY_IMMS : StartInputReason.DEACTIVATED_BY_IMMS; - mDelegate.startInput(reason, null, 0, 0, 0); + startInputOnWindowFocusGainInternal(reason, null, 0, 0, 0); } } } @@ -2357,7 +2364,7 @@ public final class InputMethodManager { // The view is running on a different thread than our own, so // we need to reschedule our work for over there. 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; }