From bf6b428749369dc140b3ddc0475ec7b50daf8ec1 Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Tue, 19 Oct 2021 12:31:54 +0800 Subject: [PATCH] Fix unexpected surface visible after closing animation As CL[1] introduced a behavior to keep the window surface when performing the closing transition. However in ActivityRecord#postApplyAnimation didn't call onAnimationFinished when app transition finished because the logic of delayed for isAnimating added TRANSITION flag to keep delaying the finish callback. That makes ActivityRecord#onExitAnimationDone will not be executed expectedly and some surfaces will end up not remove and caused some app compatibility issue. (i.e. Launching activity from nova launcher's shortcut and going to home to all apps will see the previous shortcut surface persisted on the screen) Since adding TRANSITION flag here maybe too rough and might be error-prone since "transitioning" is not yet to be running animation, basically we don't expect it should delay the finished animation callback. [1]: I4da65a8d302af6ab846a19132397bfbac4ff2f4e Fix: 202373844 Test: atest ActivityRecordTests#testInClosingAnimation_doNotHideSurface Test: manual as issue steps: 1. Have Nova launcher by default 2. Launch a activity from nova launcher's shortcut 3. Swipe up to get the applications drawer 4. Click and type the top searchbox to filter apps 5: Expect there is no icon surface shown to block the typing on the soft-keyboard. Change-Id: Id3b653f93404f41febf654ece1f57cc6262ae257 --- services/core/java/com/android/server/wm/ActivityRecord.java | 2 +- .../src/com/android/server/wm/ActivityRecordTests.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 6d144e1da2349..fd9124baa7c72 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -4973,7 +4973,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A */ private void postApplyAnimation(boolean visible) { final boolean usingShellTransitions = mTransitionController.isShellTransitionsEnabled(); - final boolean delayed = isAnimating(TRANSITION | PARENTS | CHILDREN, + final boolean delayed = isAnimating(PARENTS | CHILDREN, ANIMATION_TYPE_APP_TRANSITION | ANIMATION_TYPE_WINDOW_ANIMATION | ANIMATION_TYPE_RECENTS); if (!delayed && !usingShellTransitions) { diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java index 65733d7a41295..b093974290e06 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -77,6 +77,7 @@ import static com.android.server.wm.ActivityRecord.State.RESUMED; import static com.android.server.wm.ActivityRecord.State.STARTED; import static com.android.server.wm.ActivityRecord.State.STOPPED; import static com.android.server.wm.ActivityRecord.State.STOPPING; +import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION; import static com.android.server.wm.TaskFragment.TASK_FRAGMENT_VISIBILITY_INVISIBLE; import static com.android.server.wm.TaskFragment.TASK_FRAGMENT_VISIBILITY_VISIBLE; import static com.android.server.wm.TaskFragment.TASK_FRAGMENT_VISIBILITY_VISIBLE_BEHIND_TRANSLUCENT; @@ -3026,6 +3027,10 @@ public class ActivityRecordTests extends WindowTestsBase { // Because the app is waiting for transition, it should not hide the surface. assertTrue(app.mActivityRecord.isSurfaceShowing()); + + // Ensure onAnimationFinished will callback when the closing animation is finished. + verify(app.mActivityRecord).onAnimationFinished(eq(ANIMATION_TYPE_APP_TRANSITION), + eq(null)); } private void assertHasStartingWindow(ActivityRecord atoken) {