summaryrefslogtreecommitdiff
path: root/core/java/android/view/ViewRootImpl.java
diff options
context:
space:
mode:
authorYohei Yukawa <yukawa@google.com>2021-05-20 17:19:45 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-05-20 17:19:45 +0000
commitebd27c999bf101c47db550c8ed8cdfce9e093ab1 (patch)
tree8ec149a1c01166218694ade44a00a774d0d3dc25 /core/java/android/view/ViewRootImpl.java
parente7276c8260dbbac46d65db13819ad6d48b08ab26 (diff)
parente525c01439d1fc1c4c4ce48ebe4ab1a41a4bd03a (diff)
Merge "Fix IME be dismissed abruptly" into sc-dev
Diffstat (limited to 'core/java/android/view/ViewRootImpl.java')
-rw-r--r--core/java/android/view/ViewRootImpl.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 9bbd5dde2d4f..afd6878da429 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -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.
*/