summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ming-Shin Lu <lumark@google.com> 2022-06-15 03:31:06 +0000
committer Ming-Shin Lu <lumark@google.com> 2022-06-16 14:52:11 +0000
commitae6bb5a6d2332eaceb218d7a3eb68284d8656afb (patch)
treec5d5307d7b5446d93e2aa3a364895c4a4e9e8b3c
parenta3dfcbed6fb3e463f4cba188f7498f9273b70576 (diff)
Use isVisibleRequested to replace with isAnimating for IME picker dialog
In CL[1] to fix IME picker dialog may still be selected as the focus window when quick-switch to the next app from the IME layering target. Since even though the dialog surface is attached to the app where the surface hierarchy is lower than the next app, the dialog is a system window where the window hierarchy is higher than the next app. Previously we use isAnimating to check if the IME layering target is in transition state, which may costly and not reliable. In order to check if the IME layering target is leaving more efficiently, use isVisibleRequested to replace with isAnimating state and it also benefits when in shell-transition. [1]: I771d9817cd6dfcb1bf0d576d94bea9d1b9adc80e Bug: 212570341 Test: atest DisplayContentTests#\ testImeMenuDialogFocusWhenImeLayeringTargetChanges Test: manual, ensure Bug 195073688 won't happen with enabling shell-transition Change-Id: I6857c13ab8bbd0ca84d0e145fc783d4e64b8dcee
-rw-r--r--services/core/java/com/android/server/wm/DisplayContent.java4
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java12
2 files changed, 5 insertions, 11 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index 2ea6ce53caa2..2351dd75a9cf 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -130,7 +130,6 @@ import static com.android.server.wm.DisplayContentProto.RESUMED_ACTIVITY;
import static com.android.server.wm.DisplayContentProto.ROOT_DISPLAY_AREA;
import static com.android.server.wm.DisplayContentProto.SCREEN_ROTATION_ANIMATION;
import static com.android.server.wm.DisplayContentProto.SLEEP_TOKENS;
-import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_WINDOW_ANIMATION;
import static com.android.server.wm.WindowContainer.AnimationFlags.PARENTS;
import static com.android.server.wm.WindowContainer.AnimationFlags.TRANSITION;
@@ -757,8 +756,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
}
if (w.mAttrs.type == TYPE_INPUT_METHOD_DIALOG && mImeLayeringTarget != null
&& !mImeLayeringTarget.getRequestedVisibility(ITYPE_IME)
- && mImeLayeringTarget.isAnimating(PARENTS | TRANSITION,
- ANIMATION_TYPE_APP_TRANSITION)) {
+ && !mImeLayeringTarget.isVisibleRequested()) {
return false;
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
index a19b19ec6af9..d737963f80e7 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
@@ -78,10 +78,8 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
import static com.android.server.wm.ActivityTaskSupervisor.ON_TOP;
import static com.android.server.wm.DisplayContent.IME_TARGET_LAYERING;
-import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_TOKEN_TRANSFORM;
import static com.android.server.wm.WindowContainer.AnimationFlags.PARENTS;
-import static com.android.server.wm.WindowContainer.AnimationFlags.TRANSITION;
import static com.android.server.wm.WindowContainer.POSITION_TOP;
import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL;
@@ -2426,7 +2424,7 @@ public class DisplayContentTests extends WindowTestsBase {
@Test
public void testImeMenuDialogFocusWhenImeLayeringTargetChanges() {
final WindowState imeMenuDialog =
- createWindow(mImeWindow, TYPE_INPUT_METHOD_DIALOG, "imeMenuDialog");
+ createWindow(null, TYPE_INPUT_METHOD_DIALOG, "imeMenuDialog");
makeWindowVisibleAndDrawn(imeMenuDialog, mImeWindow);
assertTrue(imeMenuDialog.canReceiveKeys());
mDisplayContent.setInputMethodWindowLocked(mImeWindow);
@@ -2439,13 +2437,11 @@ public class DisplayContentTests extends WindowTestsBase {
doReturn(true).when(imeAppTarget).getRequestedVisibility(ITYPE_IME);
assertEquals(imeMenuDialog, mDisplayContent.findFocusedWindow());
- // Verify imeMenuDialog doesn't be focused window if the next IME target does not
- // request IME visible.
+ // Verify imeMenuDialog doesn't be focused window if the next IME target is closing.
final WindowState nextImeAppTarget =
createWindow(null, TYPE_BASE_APPLICATION, mDisplayContent, "nextImeAppTarget");
- spyOn(nextImeAppTarget);
- doReturn(true).when(nextImeAppTarget).isAnimating(PARENTS | TRANSITION,
- ANIMATION_TYPE_APP_TRANSITION);
+ makeWindowVisibleAndDrawn(nextImeAppTarget);
+ nextImeAppTarget.mActivityRecord.commitVisibility(false, false);
mDisplayContent.setImeLayeringTarget(nextImeAppTarget);
assertNotEquals(imeMenuDialog, mDisplayContent.findFocusedWindow());
}