Skip to content

Commit 5c2d5cd

Browse files
Riddle HsuAndroid (Google) Code Review
authored andcommitted
Merge "Clear fixed rotation if rotated recents activity becomes top" into rvc-qpr-dev
2 parents 23ace73 + a924b83 commit 5c2d5cd

2 files changed

Lines changed: 27 additions & 10 deletions

File tree

services/core/java/com/android/server/wm/DisplayContent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5728,7 +5728,7 @@ void onFinishRecentsAnimation() {
57285728
}
57295729

57305730
if (animatingRecents != null && animatingRecents == mFixedRotationLaunchingApp
5731-
&& animatingRecents.isVisible()) {
5731+
&& animatingRecents.isVisible() && animatingRecents != topRunningActivity()) {
57325732
// The recents activity should be going to be invisible (switch to another app or
57335733
// return to original top). Only clear the top launching record without finishing
57345734
// the transform immediately because it won't affect display orientation. And before

services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -393,23 +393,25 @@ public void testClearFixedRotationLaunchingAppAfterCleanupAnimation() {
393393
// Simulate giving up the swipe up gesture to keep the original activity as top.
394394
mController.cleanupAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION);
395395
// The rotation transform should be cleared after updating orientation with display.
396-
assertFalse(activity.hasFixedRotationTransform());
397-
assertFalse(mDefaultDisplay.hasTopFixedRotationLaunchingApp());
396+
assertTopFixedRotationLaunchingAppCleared(activity);
398397

399398
// Simulate swiping up recents (home) in different rotation.
400399
final ActivityRecord home = mDefaultDisplay.getDefaultTaskDisplayArea().getHomeActivity();
401-
mDefaultDisplay.setFixedRotationLaunchingApp(home, (mDefaultDisplay.getRotation() + 1) % 4);
402-
mController = new RecentsAnimationController(mWm, mMockRunner, mAnimationCallbacks,
403-
mDefaultDisplay.getDisplayId());
404-
initializeRecentsAnimationController(mController, home);
405-
assertTrue(home.hasFixedRotationTransform());
400+
startRecentsInDifferentRotation(home);
406401

402+
// If the recents activity becomes the top running activity (e.g. the original top activity
403+
// is either finishing or moved to back during recents animation), the display orientation
404+
// will be determined by it so the fixed rotation must be cleared.
405+
activity.finishing = true;
406+
mController.cleanupAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION);
407+
assertTopFixedRotationLaunchingAppCleared(home);
408+
409+
startRecentsInDifferentRotation(home);
407410
// Assume recents activity becomes invisible for some reason (e.g. screen off).
408411
home.setVisible(false);
409412
mController.cleanupAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION);
410413
// Although there won't be a transition finish callback, the fixed rotation must be cleared.
411-
assertFalse(home.hasFixedRotationTransform());
412-
assertFalse(mDefaultDisplay.hasTopFixedRotationLaunchingApp());
414+
assertTopFixedRotationLaunchingAppCleared(home);
413415
}
414416

415417
@Test
@@ -503,6 +505,21 @@ private ActivityRecord createHomeActivity() {
503505
return homeActivity;
504506
}
505507

508+
private void startRecentsInDifferentRotation(ActivityRecord recentsActivity) {
509+
final DisplayContent displayContent = recentsActivity.mDisplayContent;
510+
displayContent.setFixedRotationLaunchingApp(recentsActivity,
511+
(displayContent.getRotation() + 1) % 4);
512+
mController = new RecentsAnimationController(mWm, mMockRunner, mAnimationCallbacks,
513+
displayContent.getDisplayId());
514+
initializeRecentsAnimationController(mController, recentsActivity);
515+
assertTrue(recentsActivity.hasFixedRotationTransform());
516+
}
517+
518+
private static void assertTopFixedRotationLaunchingAppCleared(ActivityRecord activity) {
519+
assertFalse(activity.hasFixedRotationTransform());
520+
assertFalse(activity.mDisplayContent.hasTopFixedRotationLaunchingApp());
521+
}
522+
506523
private static void initializeRecentsAnimationController(RecentsAnimationController controller,
507524
ActivityRecord activity) {
508525
controller.initialize(activity.getActivityType(), new SparseBooleanArray(), activity);

0 commit comments

Comments
 (0)