Inline ImeFocusController#onInteractive()

Now that

  ImeFocusController#onInteractive()

is simple enough to be inlined, which allows us to also remove

  InputMethodManagerDelegate#isCurrentRootView().

This is mechanical refactoring.  There must be no behavior change.

Bug: 234882948
Test: presubmit
Change-Id: I4f001e7cef6e274a481cd1dc9ce314f3b19313dd
This commit is contained in:
Yohei Yukawa
2022-10-17 12:08:13 -07:00
parent ccc6931412
commit 444285617b
2 changed files with 13 additions and 33 deletions

View File

@@ -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);
}
/**

View File

@@ -902,18 +902,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 */
@@ -1181,17 +1169,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()) {