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

This commit is contained in:
Wilson Wu
2022-10-04 02:55:36 +00:00
committed by Android (Google) Code Review

View File

@@ -723,14 +723,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);
}
/**
@@ -805,7 +799,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;
}
@@ -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")
private View getServedViewLocked() {
return mCurRootView != null ? mCurRootView.getImeFocusController().getServedViewLocked()
@@ -1141,7 +1148,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);
}
}
}
@@ -2362,7 +2369,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;
}