From ce30ad87498150bc417bff79d13f1e0a8df9f959 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Fri, 8 Apr 2022 17:19:52 -0600 Subject: [PATCH] Clear ZBoost when removing animation leash Otherwise after launching a translucent activity, the previous activity may still have top layer. The mNeedsZBoost was cleared at onAnimationFinished. But it needs reassignLayer to take effect. The order was onAnimationLeashLost -> reassignLayer -> onAnimationFinished -> clear mNeedsZBoost. So the boosted layer is not restored. Keep original place that clears mNeedsZBoost in case the callback is not called if there was no animation leash. It was no problem because there was random unnecessary assignWindowLayers from wallpaper even if it has nothing change. After commit f649375 optimizes that, the existing issue is revealed. Fixes: 228233527 Test: AppWindowTokenAnimationTests#clipAfterAnim_boundsLayerZBoosted Change-Id: Ic4a3a106569173f24e56de213bc31dd6f287d4f5 --- .../core/java/com/android/server/wm/WindowContainer.java | 1 + .../com/android/server/wm/AppWindowTokenAnimationTests.java | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java index 214524c2f42cc..9d5b381083d51 100644 --- a/services/core/java/com/android/server/wm/WindowContainer.java +++ b/services/core/java/com/android/server/wm/WindowContainer.java @@ -3181,6 +3181,7 @@ class WindowContainer extends ConfigurationContainer< mLastLayer = -1; mWmService.mSurfaceAnimationRunner.onAnimationLeashLost(mAnimationLeash, t); mAnimationLeash = null; + mNeedsZBoost = false; reassignLayer(t); updateSurfacePosition(t); } diff --git a/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenAnimationTests.java b/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenAnimationTests.java index ebefeaff7f263..e4628c45a15b9 100644 --- a/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenAnimationTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenAnimationTests.java @@ -88,6 +88,11 @@ public class AppWindowTokenAnimationTests extends WindowTestsBase { verify(mTransaction).setLayer(eq(mActivity.mAnimationBoundsLayer), intThat(layer -> layer > topActivity.getLastLayer())); + + // The layer should be restored after the animation leash is removed. + mActivity.onAnimationLeashLost(mTransaction); + assertThat(mActivity.mNeedsZBoost).isFalse(); + assertThat(topActivity.getLastLayer()).isGreaterThan(mActivity.getLastLayer()); } @Test