Allow WindowState to assign layer during transition.

But don't build the layer info into finish transaction.
So when an Activity contains multiple WindowState, the layers can be
update according to the hierarchy order. Keeps the layers as zero can
confuse surface flinger. Also this shouldn't affect transition since
window state won't participat transition directly.

Bug: 270906945
Bug: 275459505
Test: manual, launch app and monitor the z order of windows can change
during transition animation.

Change-Id: I10daa1c4d9403dc29e5c740670d43a7590f647c0
This commit is contained in:
wilsonshih
2023-05-10 15:08:03 +08:00
parent b0658303cd
commit 848544b4ad
2 changed files with 9 additions and 3 deletions

View File

@@ -503,8 +503,14 @@ class TransitionController {
* playing, but can be "opened-up" for certain transition operations like calculating layers
* for finishTransaction.
*/
boolean canAssignLayers() {
return mBuildingFinishLayers || !isPlaying();
boolean canAssignLayers(@NonNull WindowContainer wc) {
// Don't build window state into finish transaction in case another window is added or
// removed during transition playing.
if (mBuildingFinishLayers) {
return wc.asWindowState() == null;
}
// Always allow WindowState to assign layers since it won't affect transition.
return wc.asWindowState() != null || !isPlaying();
}
@WindowConfiguration.WindowingMode

View File

@@ -2596,7 +2596,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
void assignLayer(Transaction t, int layer) {
// Don't assign layers while a transition animation is playing
// TODO(b/173528115): establish robust best-practices around z-order fighting.
if (!mTransitionController.canAssignLayers()) return;
if (!mTransitionController.canAssignLayers(this)) return;
final boolean changed = layer != mLastLayer || mLastRelativeToLayer != null;
if (mSurfaceControl != null && changed) {
setLayer(t, layer);