diff options
4 files changed, 15 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 1c636220b5c5..8e0435f1908f 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -1424,7 +1424,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp mWaitingForConfig = true; if (mTransitionController.isShellTransitionsEnabled()) { requestChangeTransitionIfNeeded(changes, null /* displayChange */); - } else { + } else if (mLastHasContent) { mWmService.startFreezingDisplay(0 /* exitAnim */, 0 /* enterAnim */, this); } sendNewConfiguration(); @@ -3220,6 +3220,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp */ void requestChangeTransitionIfNeeded(@ActivityInfo.Config int changes, @Nullable TransitionRequestInfo.DisplayChange displayChange) { + if (!mLastHasContent) return; final TransitionController controller = mTransitionController; if (controller.isCollecting()) { if (displayChange != null) { @@ -5088,6 +5089,11 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp return mLastHasContent; } + @VisibleForTesting + void setLastHasContent() { + mLastHasContent = true; + } + void registerPointerEventListener(@NonNull PointerEventListener listener) { mPointerEventDispatcher.registerInputEventListener(listener); } diff --git a/services/core/java/com/android/server/wm/FadeRotationAnimationController.java b/services/core/java/com/android/server/wm/FadeRotationAnimationController.java index c85e04dbfa15..2cefd9935870 100644 --- a/services/core/java/com/android/server/wm/FadeRotationAnimationController.java +++ b/services/core/java/com/android/server/wm/FadeRotationAnimationController.java @@ -256,7 +256,7 @@ public class FadeRotationAnimationController extends FadeAnimationController { false /* applyFixedTransformationHint */); for (int i = mTargetWindowTokens.size() - 1; i >= 0; i--) { final SurfaceControl leash = mTargetWindowTokens.valueAt(i); - if (leash != null) { + if (leash != null && leash.isValid()) { rotator.applyTransform(t, leash); } } @@ -265,7 +265,7 @@ public class FadeRotationAnimationController extends FadeAnimationController { // Hide the windows immediately because a screenshot layer should cover the screen. for (int i = mTargetWindowTokens.size() - 1; i >= 0; i--) { final SurfaceControl leash = mTargetWindowTokens.valueAt(i); - if (leash != null) { + if (leash != null && leash.isValid()) { t.setAlpha(leash, 0f); } } diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java index 2ef59f6ac5c9..2f78b588f305 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java @@ -1718,6 +1718,7 @@ public class DisplayContentTests extends WindowTestsBase { @Test public void testShellTransitRotation() { DisplayContent dc = createNewDisplay(); + dc.setLastHasContent(); final TestTransitionPlayer testPlayer = registerTestTransitionPlayer(); final DisplayRotation dr = dc.getDisplayRotation(); diff --git a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java index ed3888c7aedd..141588a87585 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java @@ -488,6 +488,7 @@ public class TransitionTests extends WindowTestsBase { final TestTransitionPlayer player = registerTestTransitionPlayer(); mDisplayContent.getDisplayRotation().setRotation(mDisplayContent.getRotation() + 1); + mDisplayContent.setLastHasContent(); mDisplayContent.requestChangeTransitionIfNeeded(1 /* any changes */, null /* displayChange */); final FadeRotationAnimationController fadeController = @@ -536,6 +537,7 @@ public class TransitionTests extends WindowTestsBase { null /* remoteTransition */, null /* displayChange */); mDisplayContent.getDisplayRotation().setRotation(mDisplayContent.getRotation() + 1); final int anyChanges = 1; + mDisplayContent.setLastHasContent(); mDisplayContent.requestChangeTransitionIfNeeded(anyChanges, null /* displayChange */); transition.setKnownConfigChanges(mDisplayContent, anyChanges); final FadeRotationAnimationController fadeController = @@ -550,9 +552,11 @@ public class TransitionTests extends WindowTestsBase { assertTrue(app.getTask().inTransition()); final SurfaceControl.Transaction startTransaction = mock(SurfaceControl.Transaction.class); + final SurfaceControl leash = statusBar.mToken.getAnimationLeash(); + doReturn(true).when(leash).isValid(); player.onTransactionReady(startTransaction); // The leash should be unrotated. - verify(startTransaction).setMatrix(eq(statusBar.mToken.getAnimationLeash()), any(), any()); + verify(startTransaction).setMatrix(eq(leash), any(), any()); // The redrawn window will be faded in when the transition finishes. And because this test // only use one non-activity window, the fade rotation controller should also be cleared. |