summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRiddle Hsu <riddlehsu@google.com>2024-02-06 17:19:37 +0800
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-04-15 09:04:18 +0000
commitd29506a33b0cee50a1033d59765166190ec2948e (patch)
tree8e46896875dc1a786dc056e845ef91fe3f7e44e4
parentfbff3ae537ff52ad238373c4e6e05431d3dc16df (diff)
Hide window immediately if itself doesn't run hide animation
The condition was overextended in commit 9bca6b4 which checks if the parent container of the window is animating. That causes the window to wait for animation finish to update visibility, but the animation finish callback won't happen because itself is not animating. Then the window that should be hidden remains on screen. Bug: 302431573 Test: atest WindowStateTests#testIsOnScreen_hiddenByPolicy (cherry picked from commit 9add9281ffc120c81a7d125892803f1beb5ddcb3) (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:10a7f0914c87f4af521b5cbb13e84a83dacebf82) Merged-In: Iafc2b2c2a24d8fc8d147354ef2f0b4afeeb510c5 Change-Id: Iafc2b2c2a24d8fc8d147354ef2f0b4afeeb510c5
-rw-r--r--services/core/java/com/android/server/wm/WindowState.java6
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java20
2 files changed, 24 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 06978a5338ea..3dfcf1ff55a8 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -3089,8 +3089,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
return false;
}
if (doAnimation) {
- mWinAnimator.applyAnimationLocked(TRANSIT_EXIT, false);
- if (!isAnimating(TRANSITION | PARENTS)) {
+ // If a hide animation is applied, then let onAnimationFinished
+ // -> checkPolicyVisibilityChange hide the window. Otherwise make doAnimation false
+ // to commit invisible immediately.
+ if (!mWinAnimator.applyAnimationLocked(TRANSIT_EXIT, false /* isEntrance */)) {
doAnimation = false;
}
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
index 0ddd3135506e..7fb5c9687796 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
@@ -229,6 +229,26 @@ public class WindowStateTests extends WindowTestsBase {
assertTrue(window.isOnScreen());
window.hide(false /* doAnimation */, false /* requestAnim */);
assertFalse(window.isOnScreen());
+
+ // Verifies that a window without animation can be hidden even if its parent is animating.
+ window.show(false /* doAnimation */, false /* requestAnim */);
+ assertTrue(window.isVisibleByPolicy());
+ window.getParent().startAnimation(mTransaction, mock(AnimationAdapter.class),
+ false /* hidden */, SurfaceAnimator.ANIMATION_TYPE_WINDOW_ANIMATION);
+ window.mAttrs.windowAnimations = 0;
+ window.hide(true /* doAnimation */, true /* requestAnim */);
+ assertFalse(window.isSelfAnimating(0, SurfaceAnimator.ANIMATION_TYPE_WINDOW_ANIMATION));
+ assertFalse(window.isVisibleByPolicy());
+ assertFalse(window.isOnScreen());
+
+ // Verifies that a window with animation can be hidden after the hide animation is finished.
+ window.show(false /* doAnimation */, false /* requestAnim */);
+ window.mAttrs.windowAnimations = android.R.style.Animation_Dialog;
+ window.hide(true /* doAnimation */, true /* requestAnim */);
+ assertTrue(window.isSelfAnimating(0, SurfaceAnimator.ANIMATION_TYPE_WINDOW_ANIMATION));
+ assertTrue(window.isVisibleByPolicy());
+ window.cancelAnimation();
+ assertFalse(window.isVisibleByPolicy());
}
@Test