diff options
| author | 2020-06-22 14:18:18 +0000 | |
|---|---|---|
| committer | 2020-06-22 14:18:18 +0000 | |
| commit | f6cfb1b53e92b175b79980ec227ef3a8beb5c8e1 (patch) | |
| tree | 050f426a949a06b9eba8b9fd4de4e3e488d38ca7 | |
| parent | 069ae9664d7d402800c077ace78478e997b9bfe7 (diff) | |
| parent | 2df350a13fb481b77d26e98d289b970c6a985c0d (diff) | |
Merge "Merge "Finish fixed rotation while the task has done transition" into rvc-dev am: 1a3468740a am: 9b5948f616 am: 0e00683b40" into rvc-qpr-dev-plus-aosp
| -rw-r--r-- | services/core/java/com/android/server/wm/DisplayContent.java | 39 | ||||
| -rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java | 25 |
2 files changed, 53 insertions, 11 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 512cd8b659bc..17d0f08b19f9 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -1464,9 +1464,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo return true; } if (checkOpening) { - if (!mAppTransition.isTransitionSet() && !mOpeningApps.contains(r)) { + if (!mAppTransition.isTransitionSet() || !mOpeningApps.contains(r)) { // Apply normal rotation animation in case of the activity set different requested - // orientation without activity switch. + // orientation without activity switch, or the transition is unset due to starting + // window was transferred ({@link #mSkipAppTransitionAnimation}). return false; } } else if (r != topRunningActivity()) { @@ -5680,16 +5681,36 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo if (r == null || r == mAnimatingRecents) { return; } - if (mFixedRotationLaunchingApp != null - && mFixedRotationLaunchingApp.hasFixedRotationTransform(r)) { - // Waiting until all of the associated activities have done animation, or the - // orientation would be updated too early and cause flickers. - if (!mFixedRotationLaunchingApp.hasAnimatingFixedRotationTransition()) { - continueUpdateOrientationForDiffOrienLaunchingApp(); + if (mFixedRotationLaunchingApp == null) { + // In most cases this is a no-op if the activity doesn't have fixed rotation. + // Otherwise it could be from finishing recents animation while the display has + // different orientation. + r.finishFixedRotationTransform(); + return; + } + if (mFixedRotationLaunchingApp.hasFixedRotationTransform(r)) { + if (mFixedRotationLaunchingApp.hasAnimatingFixedRotationTransition()) { + // Waiting until all of the associated activities have done animation, or the + // orientation would be updated too early and cause flickering. + return; } } else { - r.finishFixedRotationTransform(); + // Handle a corner case that the task of {@link #mFixedRotationLaunchingApp} is no + // longer animating but the corresponding transition finished event won't notify. + // E.g. activity A transferred starting window to B, only A will receive transition + // finished event. A doesn't have fixed rotation but B is the rotated launching app. + final Task task = r.getTask(); + if (task == null || task != mFixedRotationLaunchingApp.getTask()) { + // Different tasks won't be in one activity transition animation. + return; + } + if (task.isAppTransitioning()) { + return; + // Continue to update orientation because the transition of the top rotated + // launching activity is done. + } } + continueUpdateOrientationForDiffOrienLaunchingApp(); } @Override 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 0b04480877fc..689674011d30 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java @@ -1135,8 +1135,6 @@ public class DisplayContentTests extends WindowTestsBase { // Launch another activity before the transition is finished. final ActivityRecord app2 = new ActivityTestsBase.StackBuilder(mWm.mRoot) .setDisplay(mDisplayContent).build().getTopMostActivity(); - mDisplayContent.prepareAppTransition(WindowManager.TRANSIT_ACTIVITY_OPEN, - false /* alwaysKeepCurrent */); mDisplayContent.mOpeningApps.add(app2); app2.setRequestedOrientation(newOrientation); @@ -1163,6 +1161,29 @@ public class DisplayContentTests extends WindowTestsBase { } @Test + public void testFinishFixedRotationNoAppTransitioningTask() { + final ActivityRecord app = mAppWindow.mActivityRecord; + final Task task = app.getTask(); + final ActivityRecord app2 = new ActivityTestsBase.ActivityBuilder(mWm.mAtmService) + .setTask(task).build(); + mDisplayContent.setFixedRotationLaunchingApp(app2, (mDisplayContent.getRotation() + 1) % 4); + doReturn(true).when(task).isAppTransitioning(); + // If the task is animating transition, this should be no-op. + mDisplayContent.mFixedRotationTransitionListener.onAppTransitionFinishedLocked(app.token); + + assertTrue(app2.hasFixedRotationTransform()); + assertTrue(mDisplayContent.hasTopFixedRotationLaunchingApp()); + + doReturn(false).when(task).isAppTransitioning(); + // Although this notifies app instead of app2 that uses the fixed rotation, app2 should + // still finish the transform because there is no more transition event. + mDisplayContent.mFixedRotationTransitionListener.onAppTransitionFinishedLocked(app.token); + + assertFalse(app2.hasFixedRotationTransform()); + assertFalse(mDisplayContent.hasTopFixedRotationLaunchingApp()); + } + + @Test public void testRotateSeamlesslyWithFixedRotation() { final DisplayRotation displayRotation = mDisplayContent.getDisplayRotation(); final ActivityRecord app = mAppWindow.mActivityRecord; |