Loading services/core/java/com/android/server/wm/DisplayContent.java +1 −1 Original line number Diff line number Diff line Loading @@ -1935,7 +1935,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp } else if (mFixedRotationLaunchingApp != null && r == null) { mWmService.mDisplayNotificationController.dispatchFixedRotationFinished(this); // Keep async rotation controller if the next transition of display is requested. if (!mTransitionController.isCollecting(this)) { if (!mTransitionController.hasCollectingRotationChange(this, getRotation())) { finishAsyncRotationIfPossible(); } } Loading services/core/java/com/android/server/wm/TransitionController.java +11 −0 Original line number Diff line number Diff line Loading @@ -577,6 +577,17 @@ class TransitionController { return mCollectingTransition != null ? mCollectingTransition.mType : TRANSIT_NONE; } /** * Returns {@code true} if the window container is in the collecting transition, and its * collected rotation is different from the target rotation. */ boolean hasCollectingRotationChange(@NonNull WindowContainer<?> wc, int targetRotation) { final Transition transition = mCollectingTransition; if (transition == null || !transition.mParticipants.contains(wc)) return false; final Transition.ChangeInfo changeInfo = transition.mChanges.get(wc); return changeInfo != null && changeInfo.mRotation != targetRotation; } /** * @see #requestTransitionIfNeeded(int, int, WindowContainer, WindowContainer, RemoteTransition) */ Loading services/tests/wmtests/src/com/android/server/wm/TransitionTests.java +21 −0 Original line number Diff line number Diff line Loading @@ -1239,6 +1239,27 @@ public class TransitionTests extends WindowTestsBase { assertEquals(freeze, controller.shouldFreezeInsetsPosition(w)); } @Test public void testFinishRotationControllerWithFixedRotation() { final ActivityRecord app = new ActivityBuilder(mAtm).setCreateTask(true).build(); mDisplayContent.setFixedRotationLaunchingAppUnchecked(app); registerTestTransitionPlayer(); mDisplayContent.setLastHasContent(); mDisplayContent.requestChangeTransitionIfNeeded(1 /* changes */, null /* displayChange */); assertNotNull(mDisplayContent.getAsyncRotationController()); mDisplayContent.setFixedRotationLaunchingAppUnchecked(null); assertNull("Clear rotation controller if rotation is not changed", mDisplayContent.getAsyncRotationController()); mDisplayContent.setFixedRotationLaunchingAppUnchecked(app); assertNotNull(mDisplayContent.getAsyncRotationController()); mDisplayContent.getDisplayRotation().setRotation( mDisplayContent.getWindowConfiguration().getRotation() + 1); mDisplayContent.setFixedRotationLaunchingAppUnchecked(null); assertNotNull("Keep rotation controller if rotation will be changed", mDisplayContent.getAsyncRotationController()); } @Test public void testDeferRotationForTransientLaunch() { final TestTransitionPlayer player = registerTestTransitionPlayer(); Loading Loading
services/core/java/com/android/server/wm/DisplayContent.java +1 −1 Original line number Diff line number Diff line Loading @@ -1935,7 +1935,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp } else if (mFixedRotationLaunchingApp != null && r == null) { mWmService.mDisplayNotificationController.dispatchFixedRotationFinished(this); // Keep async rotation controller if the next transition of display is requested. if (!mTransitionController.isCollecting(this)) { if (!mTransitionController.hasCollectingRotationChange(this, getRotation())) { finishAsyncRotationIfPossible(); } } Loading
services/core/java/com/android/server/wm/TransitionController.java +11 −0 Original line number Diff line number Diff line Loading @@ -577,6 +577,17 @@ class TransitionController { return mCollectingTransition != null ? mCollectingTransition.mType : TRANSIT_NONE; } /** * Returns {@code true} if the window container is in the collecting transition, and its * collected rotation is different from the target rotation. */ boolean hasCollectingRotationChange(@NonNull WindowContainer<?> wc, int targetRotation) { final Transition transition = mCollectingTransition; if (transition == null || !transition.mParticipants.contains(wc)) return false; final Transition.ChangeInfo changeInfo = transition.mChanges.get(wc); return changeInfo != null && changeInfo.mRotation != targetRotation; } /** * @see #requestTransitionIfNeeded(int, int, WindowContainer, WindowContainer, RemoteTransition) */ Loading
services/tests/wmtests/src/com/android/server/wm/TransitionTests.java +21 −0 Original line number Diff line number Diff line Loading @@ -1239,6 +1239,27 @@ public class TransitionTests extends WindowTestsBase { assertEquals(freeze, controller.shouldFreezeInsetsPosition(w)); } @Test public void testFinishRotationControllerWithFixedRotation() { final ActivityRecord app = new ActivityBuilder(mAtm).setCreateTask(true).build(); mDisplayContent.setFixedRotationLaunchingAppUnchecked(app); registerTestTransitionPlayer(); mDisplayContent.setLastHasContent(); mDisplayContent.requestChangeTransitionIfNeeded(1 /* changes */, null /* displayChange */); assertNotNull(mDisplayContent.getAsyncRotationController()); mDisplayContent.setFixedRotationLaunchingAppUnchecked(null); assertNull("Clear rotation controller if rotation is not changed", mDisplayContent.getAsyncRotationController()); mDisplayContent.setFixedRotationLaunchingAppUnchecked(app); assertNotNull(mDisplayContent.getAsyncRotationController()); mDisplayContent.getDisplayRotation().setRotation( mDisplayContent.getWindowConfiguration().getRotation() + 1); mDisplayContent.setFixedRotationLaunchingAppUnchecked(null); assertNotNull("Keep rotation controller if rotation will be changed", mDisplayContent.getAsyncRotationController()); } @Test public void testDeferRotationForTransientLaunch() { final TestTransitionPlayer player = registerTestTransitionPlayer(); Loading