Merge "Do not force seamless rotation with animating rotated recents" into rvc-dev am: 9092277a89 am: c57d3b0c7b am: a5f5e3945d

Change-Id: Icd39c181df08b782d2e77de030df357ef2153ae2
This commit is contained in:
TreeHugger Robot
2020-05-28 03:35:48 +00:00
committed by Automerger Merge Worker
5 changed files with 37 additions and 11 deletions

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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.
@@ -1441,7 +1441,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
display.setFixedRotationLaunchingAppUnchecked(mActivity);
display.sendNewConfiguration();
assertNull(display.getFixedRotationLaunchingApp());
assertFalse(display.hasTopFixedRotationLaunchingApp());
assertFalse(mActivity.hasFixedRotationTransform());
}
@@ -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));
}
/**

View File

@@ -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();

View File

@@ -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,
@@ -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
@@ -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);
@@ -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
@@ -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);