Loading services/core/java/com/android/server/wm/DisplayContent.java +10 −2 Original line number Diff line number Diff line Loading @@ -1486,8 +1486,16 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo return true; } @Nullable ActivityRecord getFixedRotationLaunchingApp() { return mFixedRotationLaunchingApp; /** Returns {@code true} if the top activity is transformed with the new rotation of display. */ boolean hasTopFixedRotationLaunchingApp() { return mFixedRotationLaunchingApp != null // Ignore animating recents because it hasn't really become the top. && mFixedRotationLaunchingApp != mFixedRotationTransitionListener.mAnimatingRecents; } @VisibleForTesting boolean isFixedRotationLaunchingApp(ActivityRecord r) { return mFixedRotationLaunchingApp == r; } @VisibleForTesting Loading services/core/java/com/android/server/wm/DisplayRotation.java +1 −1 Original line number Diff line number Diff line Loading @@ -582,7 +582,7 @@ public class DisplayRotation { boolean shouldRotateSeamlessly(int oldRotation, int newRotation, boolean forceUpdate) { // Display doesn't need to be frozen because application has been started in correct // rotation already, so the rest of the windows can use seamless rotation. if (mDisplayContent.getFixedRotationLaunchingApp() != null) { if (mDisplayContent.hasTopFixedRotationLaunchingApp()) { return true; } Loading services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +3 −3 Original line number Diff line number Diff line Loading @@ -1412,7 +1412,7 @@ public class ActivityRecordTests extends ActivityTestsBase { // The launching rotated app should not be cleared when waiting for remote rotation. display.continueUpdateOrientationForDiffOrienLaunchingApp(); assertNotNull(display.getFixedRotationLaunchingApp()); assertTrue(display.isFixedRotationLaunchingApp(mActivity)); // Simulate the rotation has been updated to previous one, e.g. sensor updates before the // remote rotation is completed. Loading Loading @@ -1441,7 +1441,7 @@ public class ActivityRecordTests extends ActivityTestsBase { display.setFixedRotationLaunchingAppUnchecked(mActivity); display.sendNewConfiguration(); assertNull(display.getFixedRotationLaunchingApp()); assertFalse(display.hasTopFixedRotationLaunchingApp()); assertFalse(mActivity.hasFixedRotationTransform()); } Loading Loading @@ -1497,7 +1497,7 @@ public class ActivityRecordTests extends ActivityTestsBase { // rotation should be applied when creating snapshot surface if the display rotation may be // changed according to the activity orientation. assertTrue(mActivity.hasFixedRotationTransform()); assertEquals(mActivity, mActivity.mDisplayContent.getFixedRotationLaunchingApp()); assertTrue(mActivity.mDisplayContent.isFixedRotationLaunchingApp(mActivity)); } /** Loading services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +18 −0 Original line number Diff line number Diff line Loading @@ -1147,6 +1147,24 @@ public class DisplayContentTests extends WindowTestsBase { assertNull(mDisplayContent.getFixedRotationAnimationController()); } @Test public void testRotateSeamlesslyWithFixedRotation() { final DisplayRotation displayRotation = mDisplayContent.getDisplayRotation(); final ActivityRecord app = mAppWindow.mActivityRecord; mDisplayContent.setFixedRotationLaunchingAppUnchecked(app); mAppWindow.mAttrs.rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_ROTATE; // Use seamless rotation if the top app is rotated. assertTrue(displayRotation.shouldRotateSeamlessly(ROTATION_0 /* oldRotation */, ROTATION_90 /* newRotation */, false /* forceUpdate */)); mDisplayContent.mFixedRotationTransitionListener.onStartRecentsAnimation(app); // Use normal rotation because animating recents is an intermediate state. assertFalse(displayRotation.shouldRotateSeamlessly(ROTATION_0 /* oldRotation */, ROTATION_90 /* newRotation */, false /* forceUpdate */)); } @Test public void testRemoteRotation() { DisplayContent dc = createNewDisplay(); Loading services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java +5 −5 Original line number Diff line number Diff line Loading @@ -343,7 +343,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase { initializeRecentsAnimationController(mController, homeActivity); assertEquals(homeActivity, mDefaultDisplay.getFixedRotationLaunchingApp()); assertTrue(mDefaultDisplay.isFixedRotationLaunchingApp(homeActivity)); // Check that the home app is in portrait assertEquals(Configuration.ORIENTATION_PORTRAIT, Loading @@ -353,7 +353,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase { // top rotated record should be cleared. mController.cleanupAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION); assertFalse(homeActivity.hasFixedRotationTransform()); assertNull(mDefaultDisplay.getFixedRotationLaunchingApp()); assertFalse(mDefaultDisplay.hasTopFixedRotationLaunchingApp()); } @Test Loading @@ -367,7 +367,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase { (mDefaultDisplay.getRotation() + 1) % 4); assertTrue(activity.hasFixedRotationTransform()); assertEquals(activity, mDefaultDisplay.getFixedRotationLaunchingApp()); assertTrue(mDefaultDisplay.isFixedRotationLaunchingApp(activity)); // Before the transition is done, the recents animation is triggered. initializeRecentsAnimationController(mController, homeActivity); Loading @@ -377,7 +377,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase { mController.cleanupAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION); // The rotation transform should be cleared after updating orientation with display. assertFalse(activity.hasFixedRotationTransform()); assertNull(mDefaultDisplay.getFixedRotationLaunchingApp()); assertFalse(mDefaultDisplay.hasTopFixedRotationLaunchingApp()); } @Test Loading Loading @@ -436,7 +436,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase { // The transform state should keep because we expect to listen the signal from the // transition executed by moving the task to front. assertTrue(homeActivity.hasFixedRotationTransform()); assertEquals(homeActivity, mDefaultDisplay.getFixedRotationLaunchingApp()); assertTrue(mDefaultDisplay.isFixedRotationLaunchingApp(homeActivity)); mDefaultDisplay.mFixedRotationTransitionListener.onAppTransitionFinishedLocked( homeActivity.token); Loading Loading
services/core/java/com/android/server/wm/DisplayContent.java +10 −2 Original line number Diff line number Diff line Loading @@ -1486,8 +1486,16 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo return true; } @Nullable ActivityRecord getFixedRotationLaunchingApp() { return mFixedRotationLaunchingApp; /** Returns {@code true} if the top activity is transformed with the new rotation of display. */ boolean hasTopFixedRotationLaunchingApp() { return mFixedRotationLaunchingApp != null // Ignore animating recents because it hasn't really become the top. && mFixedRotationLaunchingApp != mFixedRotationTransitionListener.mAnimatingRecents; } @VisibleForTesting boolean isFixedRotationLaunchingApp(ActivityRecord r) { return mFixedRotationLaunchingApp == r; } @VisibleForTesting Loading
services/core/java/com/android/server/wm/DisplayRotation.java +1 −1 Original line number Diff line number Diff line Loading @@ -582,7 +582,7 @@ public class DisplayRotation { boolean shouldRotateSeamlessly(int oldRotation, int newRotation, boolean forceUpdate) { // Display doesn't need to be frozen because application has been started in correct // rotation already, so the rest of the windows can use seamless rotation. if (mDisplayContent.getFixedRotationLaunchingApp() != null) { if (mDisplayContent.hasTopFixedRotationLaunchingApp()) { return true; } Loading
services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +3 −3 Original line number Diff line number Diff line Loading @@ -1412,7 +1412,7 @@ public class ActivityRecordTests extends ActivityTestsBase { // The launching rotated app should not be cleared when waiting for remote rotation. display.continueUpdateOrientationForDiffOrienLaunchingApp(); assertNotNull(display.getFixedRotationLaunchingApp()); assertTrue(display.isFixedRotationLaunchingApp(mActivity)); // Simulate the rotation has been updated to previous one, e.g. sensor updates before the // remote rotation is completed. Loading Loading @@ -1441,7 +1441,7 @@ public class ActivityRecordTests extends ActivityTestsBase { display.setFixedRotationLaunchingAppUnchecked(mActivity); display.sendNewConfiguration(); assertNull(display.getFixedRotationLaunchingApp()); assertFalse(display.hasTopFixedRotationLaunchingApp()); assertFalse(mActivity.hasFixedRotationTransform()); } Loading Loading @@ -1497,7 +1497,7 @@ public class ActivityRecordTests extends ActivityTestsBase { // rotation should be applied when creating snapshot surface if the display rotation may be // changed according to the activity orientation. assertTrue(mActivity.hasFixedRotationTransform()); assertEquals(mActivity, mActivity.mDisplayContent.getFixedRotationLaunchingApp()); assertTrue(mActivity.mDisplayContent.isFixedRotationLaunchingApp(mActivity)); } /** Loading
services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +18 −0 Original line number Diff line number Diff line Loading @@ -1147,6 +1147,24 @@ public class DisplayContentTests extends WindowTestsBase { assertNull(mDisplayContent.getFixedRotationAnimationController()); } @Test public void testRotateSeamlesslyWithFixedRotation() { final DisplayRotation displayRotation = mDisplayContent.getDisplayRotation(); final ActivityRecord app = mAppWindow.mActivityRecord; mDisplayContent.setFixedRotationLaunchingAppUnchecked(app); mAppWindow.mAttrs.rotationAnimation = WindowManager.LayoutParams.ROTATION_ANIMATION_ROTATE; // Use seamless rotation if the top app is rotated. assertTrue(displayRotation.shouldRotateSeamlessly(ROTATION_0 /* oldRotation */, ROTATION_90 /* newRotation */, false /* forceUpdate */)); mDisplayContent.mFixedRotationTransitionListener.onStartRecentsAnimation(app); // Use normal rotation because animating recents is an intermediate state. assertFalse(displayRotation.shouldRotateSeamlessly(ROTATION_0 /* oldRotation */, ROTATION_90 /* newRotation */, false /* forceUpdate */)); } @Test public void testRemoteRotation() { DisplayContent dc = createNewDisplay(); Loading
services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java +5 −5 Original line number Diff line number Diff line Loading @@ -343,7 +343,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase { initializeRecentsAnimationController(mController, homeActivity); assertEquals(homeActivity, mDefaultDisplay.getFixedRotationLaunchingApp()); assertTrue(mDefaultDisplay.isFixedRotationLaunchingApp(homeActivity)); // Check that the home app is in portrait assertEquals(Configuration.ORIENTATION_PORTRAIT, Loading @@ -353,7 +353,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase { // top rotated record should be cleared. mController.cleanupAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION); assertFalse(homeActivity.hasFixedRotationTransform()); assertNull(mDefaultDisplay.getFixedRotationLaunchingApp()); assertFalse(mDefaultDisplay.hasTopFixedRotationLaunchingApp()); } @Test Loading @@ -367,7 +367,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase { (mDefaultDisplay.getRotation() + 1) % 4); assertTrue(activity.hasFixedRotationTransform()); assertEquals(activity, mDefaultDisplay.getFixedRotationLaunchingApp()); assertTrue(mDefaultDisplay.isFixedRotationLaunchingApp(activity)); // Before the transition is done, the recents animation is triggered. initializeRecentsAnimationController(mController, homeActivity); Loading @@ -377,7 +377,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase { mController.cleanupAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION); // The rotation transform should be cleared after updating orientation with display. assertFalse(activity.hasFixedRotationTransform()); assertNull(mDefaultDisplay.getFixedRotationLaunchingApp()); assertFalse(mDefaultDisplay.hasTopFixedRotationLaunchingApp()); } @Test Loading Loading @@ -436,7 +436,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase { // The transform state should keep because we expect to listen the signal from the // transition executed by moving the task to front. assertTrue(homeActivity.hasFixedRotationTransform()); assertEquals(homeActivity, mDefaultDisplay.getFixedRotationLaunchingApp()); assertTrue(mDefaultDisplay.isFixedRotationLaunchingApp(homeActivity)); mDefaultDisplay.mFixedRotationTransitionListener.onAppTransitionFinishedLocked( homeActivity.token); Loading