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
This commit is contained in:
Riddle Hsu
2022-04-08 17:19:52 -06:00
parent 194d7396e2
commit ce30ad8749
2 changed files with 6 additions and 0 deletions

View File

@@ -3181,6 +3181,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
mLastLayer = -1;
mWmService.mSurfaceAnimationRunner.onAnimationLeashLost(mAnimationLeash, t);
mAnimationLeash = null;
mNeedsZBoost = false;
reassignLayer(t);
updateSurfacePosition(t);
}

View File

@@ -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