summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yohei Yukawa <yukawa@google.com> 2022-10-17 21:38:39 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-10-17 21:38:39 +0000
commit4f1033f742553979d333415b6e75e51d3b039777 (patch)
tree7627965086234b583da619661aa1f076efb0cccf
parent70c78e08a6d3fefc8d0d39aa25ac3f6af3d27b46 (diff)
parent444285617b7dadcb92a31b91e59fecc1cb136f3e (diff)
Merge "Inline ImeFocusController#onInteractive()"
-rw-r--r--core/java/android/view/ImeFocusController.java15
-rw-r--r--core/java/android/view/inputmethod/InputMethodManager.java31
2 files changed, 13 insertions, 33 deletions
diff --git a/core/java/android/view/ImeFocusController.java b/core/java/android/view/ImeFocusController.java
index bb6c78a8fe7a..4de7c4fdd513 100644
--- a/core/java/android/view/ImeFocusController.java
+++ b/core/java/android/view/ImeFocusController.java
@@ -132,19 +132,6 @@ public final class ImeFocusController {
}
/**
- * 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);
}
/**
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index 4a0a4bf39690..66b181f6c468 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -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()) {