From c6924f7c55ab89169b83b7fe23f4b6460d448465 Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Mon, 16 Jan 2023 09:43:02 +0000 Subject: [PATCH] [ImeStateComputer]: Preserve last visible state for STATE_UNCHANGD In ImeVisibilityStateComputer#computeState, we only keep the legacy behavior to do nothing for handling SOFT_INPUT_STATE_CHANGED flag of the focusing window without changing the requested visiblity. However, with per-windowState based IME visiblity model, we should perserve the requested IME visiblity from the last IME targeted window to the current focusing window in case we are failing the tests related to launching a new activity with STATE_UNCHANGED from the ativity with IME shown. Fix: 265439883 Bug: 246309664 Test: atest InputMethodStressTest:com.android.inputmethod.stresstest\ .AutoShowTest#autoShow_forwardWithKeyboardOn Expect it can passed on the following test parameters combination - windowFocusFlags=0 /* no windowFocusFlags */ - softInputVisibility=1 /* STATE_UNCHANGED flag */ - softInputAdjustment=any() /* SOFT_INPUT_ADJUST_* flags */ Change-Id: I74907f27f275ba6028b4683145205f2cce2b2f45 --- .../server/inputmethod/ImeVisibilityStateComputer.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/inputmethod/ImeVisibilityStateComputer.java b/services/core/java/com/android/server/inputmethod/ImeVisibilityStateComputer.java index 795e4bf9d5cb9..db61e954893e3 100644 --- a/services/core/java/com/android/server/inputmethod/ImeVisibilityStateComputer.java +++ b/services/core/java/com/android/server/inputmethod/ImeVisibilityStateComputer.java @@ -380,7 +380,12 @@ public final class ImeVisibilityStateComputer { } break; case WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED: - // Do nothing. + // Do nothing but preserving the last IME requested visibility state. + final ImeTargetWindowState lastState = + getWindowStateOrNull(mService.mLastImeTargetWindow); + if (lastState != null) { + state.setRequestedImeVisible(lastState.mRequestedImeVisible); + } break; case WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN: if (isForwardNavigation) {