summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Felix Stern <fstern@google.com> 2024-12-18 09:16:41 -0800
committer Android Build Coastguard Worker <android-build-coastguard-worker@google.com> 2025-01-09 11:36:05 -0800
commit6538fac5c89c9ac9b14b9b1d9493f2870712208d (patch)
tree4fefd5a06caa7f6095787cb9155fcd17332b5271
parentec8c7a6bf399eaefa5b81f6e97350b24a6be8d25 (diff)
Removing hide IME call onWindowLostFocus for STATE_ALWAYS_HIDDEN
The IME should only be hidden (for softInputMode == STATE_ALWAYS_HIDDEN), if IME focus changes, not window focus. Fix: 378098975 Test: Show language picker in Chrome Flag: EXEMPT refactor (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:1108597063eb998fb2fbf97cab2777a1808cfd5f) Merged-In: Ife12ebd0337c21c41fd3226aa7b76fba9fb82485 Change-Id: Ife12ebd0337c21c41fd3226aa7b76fba9fb82485
-rw-r--r--core/java/android/view/inputmethod/InputMethodManager.java41
1 files changed, 20 insertions, 21 deletions
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index f82e5f984f5d..d5f471edfdd2 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -938,27 +938,6 @@ public final class InputMethodManager {
synchronized (mH) {
if (mCurRootView == viewRootImpl) {
mCurRootViewWindowFocused = false;
-
- if (Flags.refactorInsetsController() && mCurRootView != null) {
- final int softInputMode = mCurRootView.mWindowAttributes.softInputMode;
- final int state =
- softInputMode & WindowManager.LayoutParams.SOFT_INPUT_MASK_STATE;
- if (state == WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN) {
- // when losing focus (e.g., by going to another window), we reset the
- // requestedVisibleTypes of WindowInsetsController by hiding the IME
- final var statsToken = ImeTracker.forLogging().onStart(
- ImeTracker.TYPE_HIDE, ImeTracker.ORIGIN_CLIENT,
- SoftInputShowHideReason.HIDE_WINDOW_LOST_FOCUS,
- false /* fromUser */);
- if (DEBUG) {
- Log.d(TAG, "onWindowLostFocus, hiding IME because "
- + "of STATE_ALWAYS_HIDDEN");
- }
- mCurRootView.getInsetsController().hide(WindowInsets.Type.ime(),
- false /* fromIme */, statsToken);
- }
- }
-
clearCurRootViewIfNeeded();
}
}
@@ -1012,6 +991,26 @@ public final class InputMethodManager {
@GuardedBy("mH")
private void setCurrentRootViewLocked(ViewRootImpl rootView) {
final boolean wasEmpty = mCurRootView == null;
+ if (Flags.refactorInsetsController() && !wasEmpty && mCurRootView != rootView) {
+ final int softInputMode = mCurRootView.mWindowAttributes.softInputMode;
+ final int state =
+ softInputMode & WindowManager.LayoutParams.SOFT_INPUT_MASK_STATE;
+ if (state == WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN) {
+ // when losing input focus (e.g., by going to another window), we reset the
+ // requestedVisibleTypes of WindowInsetsController by hiding the IME
+ final var statsToken = ImeTracker.forLogging().onStart(
+ ImeTracker.TYPE_HIDE, ImeTracker.ORIGIN_CLIENT,
+ SoftInputShowHideReason.HIDE_WINDOW_LOST_FOCUS,
+ false /* fromUser */);
+ if (DEBUG) {
+ Log.d(TAG, "setCurrentRootViewLocked, hiding IME because "
+ + "of STATE_ALWAYS_HIDDEN");
+ }
+ mCurRootView.getInsetsController().hide(WindowInsets.Type.ime(),
+ false /* fromIme */, statsToken);
+ }
+ }
+
mImeDispatcher.switchRootView(mCurRootView, rootView);
mCurRootView = rootView;
if (wasEmpty && mCurRootView != null) {