summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/inputmethod/InputMethodManager.java38
1 files changed, 21 insertions, 17 deletions
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index d5f471edfdd2..c64448a7c17e 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -992,23 +992,7 @@ public final class InputMethodManager {
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);
- }
+ onImeFocusLost(mCurRootView);
}
mImeDispatcher.switchRootView(mCurRootView, rootView);
@@ -1019,6 +1003,26 @@ public final class InputMethodManager {
}
}
+ private void onImeFocusLost(@NonNull ViewRootImpl previousRootView) {
+ final int softInputMode = previousRootView.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, "onImeFocusLost, hiding IME because "
+ + "of STATE_ALWAYS_HIDDEN");
+ }
+ previousRootView.getInsetsController().hide(WindowInsets.Type.ime(),
+ false /* fromIme */, statsToken);
+ }
+ }
+
/** @hide */
public DelegateImpl getDelegate() {
return mDelegate;