Merge "Fix IME be dismissed abruptly" into sc-dev am: ebd27c999b am: 89e0c27087

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14609914

Change-Id: Id03d4f72758241655bb1adba7e44cca02f51692f
This commit is contained in:
Yohei Yukawa
2021-05-20 18:01:12 +00:00
committed by Automerger Merge Worker

View File

@@ -3372,9 +3372,9 @@ public final class ViewRootImpl implements ViewParent,
}
// TODO (b/131181940): Make sure this doesn't leak Activity with mActivityConfigCallback
// config changes.
final View focusedView = mView != null ? mView.findFocus() : null;
if (hasWindowFocus) {
mInsetsController.onWindowFocusGained(focusedView != null /* hasViewFocused */);
mInsetsController.onWindowFocusGained(
getFocusedViewOrNull() != null /* hasViewFocused */);
} else {
mInsetsController.onWindowFocusLost();
}
@@ -3423,7 +3423,8 @@ public final class ViewRootImpl implements ViewParent,
// Note: must be done after the focus change callbacks,
// so all of the view state is set up correctly.
mImeFocusController.onPostWindowFocus(focusedView, hasWindowFocus, mWindowAttributes);
mImeFocusController.onPostWindowFocus(
getFocusedViewOrNull(), hasWindowFocus, mWindowAttributes);
if (hasWindowFocus) {
// Clear the forward bit. We can just do this directly, since
@@ -6392,6 +6393,11 @@ public final class ViewRootImpl implements ViewParent,
mView.dispatchTooltipHoverEvent(event);
}
@Nullable
private View getFocusedViewOrNull() {
return mView != null ? mView.findFocus() : null;
}
/**
* Performs synthesis of new input events from unhandled input events.
*/