From 957496a9fcf83aead6858ed1cdfc0c072094f610 Mon Sep 17 00:00:00 2001 From: Evan Rosky Date: Fri, 16 Sep 2022 00:15:37 +0000 Subject: [PATCH] Don't assume exiting non-app windows are animating in transition If a non-app window exits itself (via relayout), even if that window is in a transition subtree, don't mark it as mAnimatingExit. We don't actually have any situations (yet) where shell-transitions animate non-app/wallpaper windows so if WM isn't animating that window (via winAnimator.applyAnimationLocked), then it has no WM-side animation and thus it can't be mAnimatingExit. This matches legacy app-transitions which, also, do not animate non-app windows. For context, NotificationShade was closing itself during a display change. This meant that inTransition() was true (because everything is in the display). However, this was after the animation already started and nothing ever collected the NotificationShade's Token (since the animation is done in client -- as is the case with all of these non-app windows currently). Bug: 247005789 Test: toggle desktop-mode from notification shade and verify that its surface goes away. Change-Id: Ib4f6924a1e6517d192abd3f77e4eccdd9da13004 --- .../android/server/wm/WindowManagerService.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 66c962d855b7e..c9115e4dd7fce 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -124,7 +124,10 @@ import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_BACKGROUND_ import static com.android.server.wm.RootWindowContainer.MATCH_ATTACHED_TASK_OR_RECENT_TASKS; import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_ALL; import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION; +import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_RECENTS; +import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_WINDOW_ANIMATION; import static com.android.server.wm.WindowContainer.AnimationFlags.CHILDREN; +import static com.android.server.wm.WindowContainer.AnimationFlags.PARENTS; import static com.android.server.wm.WindowContainer.AnimationFlags.TRANSITION; import static com.android.server.wm.WindowManagerDebugConfig.DEBUG; import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DISPLAY; @@ -2633,10 +2636,22 @@ public class WindowManagerService extends IWindowManager.Stub if (win.isWinVisibleLw() && win.mDisplayContent.okToAnimate()) { String reason = null; if (winAnimator.applyAnimationLocked(transit, false)) { + // This is a WMCore-driven window animation. reason = "applyAnimation"; focusMayChange = true; win.mAnimatingExit = true; - } else if (win.isExitAnimationRunningSelfOrParent()) { + } else if ( + // This is already animating via a WMCore-driven window animation + win.isSelfAnimating(0 /* flags */, ANIMATION_TYPE_WINDOW_ANIMATION) + // Or already animating as part of a legacy app-transition + || win.isAnimating(PARENTS | TRANSITION, + ANIMATION_TYPE_APP_TRANSITION | ANIMATION_TYPE_RECENTS) + // Or already animating as part of a shell-transition. + || (win.inTransition() + // Filter out non-app windows since transitions don't animate those + // (but may still "wait" on them for readiness) + && (win.mActivityRecord != null || win.mIsWallpaper))) { + // TODO(b/247005789): set mAnimatingExit somewhere in shell-transitions setup. reason = "animating"; win.mAnimatingExit = true; } else if (win.mDisplayContent.mWallpaperController.isWallpaperTarget(win)