From 1230839d3259eb7ca5f6fb53df415147b67f59d9 Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Tue, 2 Nov 2021 01:37:05 +0800 Subject: [PATCH] Fix IME flicker when switching recents tasks CL[1] fixed the IME relative layer issue on editor dialog fragment when swiping up to recents without seeing the IME behinds the dimming layer. However, this introduced another IME flickering when switching tasks with selecting task on the overview screen. The scenerio is: - Focusing an app to show IME - Swiping up to go to the overview screen - Selecting another task The flickering happens to see the "transformed" IME surface that originally belongs to the previous task, but accidentally on top of the selected task during animating the recents task. That's because we removed recents animation animating state in DC#assignRelativeLayerForIme, so that IME can placed on the selected task, but it doesn't make sense to have relative Z of the IME, if the task is not yet to be the IME control target. Consolide "canImeTargetSetRelativeLayer" check in DC#assignRelativeLayerForIme with checking if the current layering target is IME control target. Will not set relative Z if the target is not yet to be IME control target. [1]: I3024443c21cfb1c7971f3999640039caea10d0d5 Bug: 201139555 Test: atest ZOrderingTests Change-Id: Iae65d6047c02dae241f2df21c666a03cca58fd0b --- services/core/java/com/android/server/wm/DisplayContent.java | 1 + .../wmtests/src/com/android/server/wm/ZOrderingTests.java | 3 +++ 2 files changed, 4 insertions(+) diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index f3d46f07dd969..683af4baa2a8e 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -4930,6 +4930,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp if (imeTarget != null && !(imeTarget.mActivityRecord != null && imeTarget.mActivityRecord.hasStartingWindow())) { final boolean canImeTargetSetRelativeLayer = imeTarget.getSurfaceControl() != null + && imeTarget == mImeControlTarget && !imeTarget.inMultiWindowMode() && imeTarget.mToken.getActivity(app -> app.isAnimating(TRANSITION | PARENTS, ANIMATION_TYPE_ALL & ~ANIMATION_TYPE_RECENTS)) == null; diff --git a/services/tests/wmtests/src/com/android/server/wm/ZOrderingTests.java b/services/tests/wmtests/src/com/android/server/wm/ZOrderingTests.java index dfbdedee37c46..722aee7a8f6e8 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ZOrderingTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ZOrderingTests.java @@ -297,6 +297,7 @@ public class ZOrderingTests extends WindowTestsBase { final WindowState appAboveImeTarget = createWindow("appAboveImeTarget"); mDisplayContent.setImeLayeringTarget(imeAppTarget); + mDisplayContent.setImeControlTarget(imeAppTarget); mDisplayContent.assignChildLayers(mTransaction); // Ime should be above all app windows except for non-fullscreen app window above it and @@ -343,6 +344,7 @@ public class ZOrderingTests extends WindowTestsBase { @Test public void testAssignWindowLayers_ForStatusBarImeTarget() { mDisplayContent.setImeLayeringTarget(mStatusBarWindow); + mDisplayContent.setImeControlTarget(mStatusBarWindow); mDisplayContent.assignChildLayers(mTransaction); assertWindowHigher(mImeWindow, mChildAppWindowAbove); @@ -408,6 +410,7 @@ public class ZOrderingTests extends WindowTestsBase { mAppWindow.mActivityRecord, "imeAppTarget"); mDisplayContent.setImeInputTarget(imeAppTarget); mDisplayContent.setImeLayeringTarget(imeAppTarget); + mDisplayContent.setImeControlTarget(imeAppTarget); mDisplayContent.updateImeParent(); // Simulate the ime layering target task is animating with recents animation.