Merge "Calculate the correct surface layers for finishTransaction" into tm-qpr-dev

This commit is contained in:
Evan Rosky
2022-07-13 21:07:02 +00:00
committed by Android (Google) Code Review
3 changed files with 26 additions and 4 deletions

View File

@@ -533,9 +533,14 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
} }
// Need to update layers on involved displays since they were all paused while // Need to update layers on involved displays since they were all paused while
// the animation played. This puts the layers back into the correct order. // the animation played. This puts the layers back into the correct order.
for (int i = displays.size() - 1; i >= 0; --i) { mController.mBuildingFinishLayers = true;
if (displays.valueAt(i) == null) continue; try {
displays.valueAt(i).assignChildLayers(t); for (int i = displays.size() - 1; i >= 0; --i) {
if (displays.valueAt(i) == null) continue;
displays.valueAt(i).assignChildLayers(t);
}
} finally {
mController.mBuildingFinishLayers = false;
} }
if (rootLeash.isValid()) { if (rootLeash.isValid()) {
t.reparent(rootLeash, null); t.reparent(rootLeash, null);

View File

@@ -100,6 +100,14 @@ class TransitionController {
// TODO(b/188595497): remove when not needed. // TODO(b/188595497): remove when not needed.
final StatusBarManagerInternal mStatusBar; final StatusBarManagerInternal mStatusBar;
/**
* `true` when building surface layer order for the finish transaction. We want to prevent
* wm from touching z-order of surfaces during transitions, but we still need to be able to
* calculate the layers for the finishTransaction. So, when assigning layers into the finish
* transaction, set this to true so that the {@link canAssignLayers} will allow it.
*/
boolean mBuildingFinishLayers = false;
TransitionController(ActivityTaskManagerService atm, TransitionController(ActivityTaskManagerService atm,
TaskSnapshotController taskSnapshotController, TaskSnapshotController taskSnapshotController,
TransitionTracer transitionTracer) { TransitionTracer transitionTracer) {
@@ -309,6 +317,15 @@ class TransitionController {
return false; return false;
} }
/**
* Whether WM can assign layers to window surfaces at this time. This is usually false while
* playing, but can be "opened-up" for certain transition operations like calculating layers
* for finishTransaction.
*/
boolean canAssignLayers() {
return mBuildingFinishLayers || !isPlaying();
}
@WindowConfiguration.WindowingMode @WindowConfiguration.WindowingMode
int getWindowingModeAtStart(@NonNull WindowContainer wc) { int getWindowingModeAtStart(@NonNull WindowContainer wc) {
if (mCollectingTransition == null) return wc.getWindowingMode(); if (mCollectingTransition == null) return wc.getWindowingMode();

View File

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