From 325c57bb61ecbbf194781da343bac59c1e479734 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Fri, 1 Apr 2022 00:22:27 +0800 Subject: [PATCH] Skip window exit animation if display has transition While shell transition is enabled, since change [1], it also considers parent transition. And because display rotation is transition with shell transition, all windows are unable to remove while rotating display. Then if an activity is relaunched for the configuration change, its old window will also appear in the animation, which looks weird. Because the window removal transaction should be applied with shell start transaction to perform a display level animation, so the exit animations are unnecessary. [1]: I5a4f6fcdf16c5ce40298385d2153e108f43378f2 Bug: 227327391 Test: adb shell setprop persist.wm.debug.shell_transit 1; reboot Set animation scale to 10x and rotate device. atest ChangeAppRotationTest Change-Id: I2d9eb308aaa5d7853e833a022ca5cced99da922e --- .../java/com/android/server/wm/WindowState.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 3200291ad2632..133096d1957ab 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -2578,11 +2578,17 @@ class WindowState extends WindowContainer implements WindowManagerP return; } + // Remove immediately if there is display transition because the animation is + // usually unnoticeable (e.g. covered by rotation animation) and the animation + // bounds could be inconsistent, such as depending on when the window applies + // its draw transaction with new rotation. + final boolean allowExitAnimation = !getDisplayContent().inTransition(); + if (wasVisible) { final int transit = (!startingWindow) ? TRANSIT_EXIT : TRANSIT_PREVIEW_DONE; // Try starting an animation. - if (mWinAnimator.applyAnimationLocked(transit, false)) { + if (allowExitAnimation && mWinAnimator.applyAnimationLocked(transit, false)) { ProtoLog.v(WM_DEBUG_ANIM, "Set animatingExit: reason=remove/applyAnimation win=%s", this); mAnimatingExit = true; @@ -2596,7 +2602,8 @@ class WindowState extends WindowContainer implements WindowManagerP mWmService.mAccessibilityController.onWindowTransition(this, transit); } } - final boolean isAnimating = mAnimatingExit || isExitAnimationRunningSelfOrParent(); + final boolean isAnimating = allowExitAnimation + && (mAnimatingExit || isExitAnimationRunningSelfOrParent()); final boolean lastWindowIsStartingWindow = startingWindow && mActivityRecord != null && mActivityRecord.isLastWindow(this); // We delay the removal of a window if it has a showing surface that can be used to run @@ -5256,12 +5263,6 @@ class WindowState extends WindowContainer implements WindowManagerP if (mControllableInsetProvider != null) { return; } - if (getDisplayContent().inTransition()) { - // Skip because the animation is usually unnoticeable (e.g. covered by rotation - // animation) and the animation bounds could be inconsistent, such as depending - // on when the window applies its draw transaction with new rotation. - return; - } final DisplayInfo displayInfo = getDisplayInfo(); anim.initialize(mWindowFrames.mFrame.width(), mWindowFrames.mFrame.height(),