From d19ad2aa09fd27ec11e626ab239babb929c32fd6 Mon Sep 17 00:00:00 2001 From: Louis Chang Date: Thu, 23 Mar 2023 04:52:57 +0000 Subject: Fix black screen while animating a closing and changing TF A TaskFragment could be resizing to a smaller bounds while changing to be invisible. A black screen was shown during the transition. So, skip unfreeze surface in that case. Also union the staring bounds to the whole closing screen bounds, or the leash will be cropped by the target screen bounds. Bug: 267044260 Test: steps on the bug Change-Id: Ia037c5beaca12695fc6c00e38c454cb6dced1b33 Merged-In: Ia037c5beaca12695fc6c00e38c454cb6dced1b33 --- .../window/extensions/embedding/TaskFragmentAnimationRunner.java | 2 ++ services/core/java/com/android/server/wm/TaskFragment.java | 9 +++++++-- services/core/java/com/android/server/wm/WindowContainer.java | 8 ++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/TaskFragmentAnimationRunner.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/TaskFragmentAnimationRunner.java index dcc12ac07589..b917ac80256c 100644 --- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/TaskFragmentAnimationRunner.java +++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/TaskFragmentAnimationRunner.java @@ -215,6 +215,8 @@ class TaskFragmentAnimationRunner extends IRemoteAnimationRunner.Stub { } else { closingTargets.add(target); closingWholeScreenBounds.union(target.screenSpaceBounds); + // Union the start bounds since this may be the ClosingChanging animation. + closingWholeScreenBounds.union(target.startBounds); } } diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java index 19e45ff02463..a2d3e842eb10 100644 --- a/services/core/java/com/android/server/wm/TaskFragment.java +++ b/services/core/java/com/android/server/wm/TaskFragment.java @@ -2498,13 +2498,18 @@ class TaskFragment extends WindowContainer { } } - /** Records the starting bounds of the closing organized TaskFragment. */ - void setClosingChangingStartBoundsIfNeeded() { + /** + * Returns {@code true} if the starting bounds of the closing organized TaskFragment is + * recorded. Otherwise, return {@code false}. + */ + boolean setClosingChangingStartBoundsIfNeeded() { if (isOrganizedTaskFragment() && mDisplayContent != null && mDisplayContent.mChangingContainers.remove(this)) { mDisplayContent.mClosingChangingContainers.put( this, new Rect(mSurfaceFreezer.mFreezeBounds)); + return true; } + return false; } @Override diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java index ce032442e4af..d18d502eeb36 100644 --- a/services/core/java/com/android/server/wm/WindowContainer.java +++ b/services/core/java/com/android/server/wm/WindowContainer.java @@ -1299,14 +1299,18 @@ class WindowContainer extends ConfigurationContainer< // If we are losing visibility, then a snapshot isn't necessary and we are no-longer // part of a change transition. if (!visible) { + boolean skipUnfreeze = false; if (asTaskFragment() != null) { // If the organized TaskFragment is closing while resizing, we want to keep track of // its starting bounds to make sure the animation starts at the correct position. // This should be called before unfreeze() because we record the starting bounds // in SurfaceFreezer. - asTaskFragment().setClosingChangingStartBoundsIfNeeded(); + skipUnfreeze = asTaskFragment().setClosingChangingStartBoundsIfNeeded(); + } + + if (!skipUnfreeze) { + mSurfaceFreezer.unfreeze(getSyncTransaction()); } - mSurfaceFreezer.unfreeze(getSyncTransaction()); } WindowContainer parent = getParent(); if (parent != null) { -- cgit v1.2.3-59-g8ed1b