summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Riddle Hsu <riddlehsu@google.com> 2020-05-11 05:00:11 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-05-11 05:00:11 +0000
commitda95e26cc7bc95cd48213c4c08370e1b48b0c77f (patch)
tree08d58361ef14eefa5a583e802e150f0474e8ff8c
parent94cfc91ab298779e85fc35a3cc96be3a16f29524 (diff)
parent70a920cdd0e1574b2224a399f6347c888e5ab97d (diff)
Merge "Update display orientation that was interrupted by recents animation" into rvc-dev
-rw-r--r--services/core/java/com/android/server/wm/DisplayContent.java23
-rw-r--r--services/core/java/com/android/server/wm/RecentsAnimationController.java7
-rw-r--r--services/core/java/com/android/server/wm/WindowToken.java5
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java42
4 files changed, 59 insertions, 18 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index 0f09752b6f34..e31eaf76b100 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -5527,7 +5527,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
/**
* The animating activity which shows the recents task list. It is set between
* {@link RecentsAnimationController#initialize} and
- * {@link RecentsAnimationController#cancelAnimation}.
+ * {@link RecentsAnimationController#cleanupAnimation}.
*/
private ActivityRecord mAnimatingRecents;
@@ -5550,14 +5550,25 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
* If {@link #mAnimatingRecents} still has fixed rotation, it should be moved to top so we
* don't clear {@link #mFixedRotationLaunchingApp} that will be handled by transition.
*/
- void onFinishRecentsAnimation() {
+ void onFinishRecentsAnimation(boolean moveRecentsToBack) {
final ActivityRecord animatingRecents = mAnimatingRecents;
mAnimatingRecents = null;
- if (animatingRecents != null && animatingRecents == mFixedRotationLaunchingApp
- && !animatingRecents.hasFixedRotationTransform()) {
- // The recents activity won't be the top, such as giving up the swipe up gesture
- // and return to the original top.
+ if (!moveRecentsToBack) {
+ // The recents activity will be the top, such as staying at recents list or
+ // returning to home (if home and recents are the same activity).
+ return;
+ }
+
+ if (animatingRecents != null && animatingRecents == mFixedRotationLaunchingApp) {
+ // Because it won't affect display orientation, just finish the transform.
+ animatingRecents.finishFixedRotationTransform();
mFixedRotationLaunchingApp = null;
+ } else {
+ // If there is already a launching activity that is not the recents, before its
+ // transition is completed, the recents animation may be started. So if the recents
+ // activity won't be the top, the display orientation should be updated according
+ // to the current top activity.
+ continueUpdateOrientationForDiffOrienLaunchingApp();
}
}
diff --git a/services/core/java/com/android/server/wm/RecentsAnimationController.java b/services/core/java/com/android/server/wm/RecentsAnimationController.java
index c96c664c10e5..d6ddcd0cc9f9 100644
--- a/services/core/java/com/android/server/wm/RecentsAnimationController.java
+++ b/services/core/java/com/android/server/wm/RecentsAnimationController.java
@@ -734,13 +734,10 @@ public class RecentsAnimationController implements DeathRecipient {
if (reorderMode == REORDER_MOVE_TO_TOP || reorderMode == REORDER_KEEP_IN_PLACE) {
mDisplayContent.mAppTransition.notifyAppTransitionFinishedLocked(
mTargetActivityRecord.token);
- } else {
- // The target activity will be moved to original position (non-top). Since it won't
- // affect display orientation, just finish the transform.
- mTargetActivityRecord.finishFixedRotationTransform();
}
}
- mDisplayContent.mFixedRotationTransitionListener.onFinishRecentsAnimation();
+ mDisplayContent.mFixedRotationTransitionListener.onFinishRecentsAnimation(
+ reorderMode == REORDER_MOVE_TO_ORIGINAL_POSITION /* moveRecentsToBack */);
// Notify that the animation has ended
if (mStatusBar != null) {
diff --git a/services/core/java/com/android/server/wm/WindowToken.java b/services/core/java/com/android/server/wm/WindowToken.java
index 472773e1bb1a..148264a01ae0 100644
--- a/services/core/java/com/android/server/wm/WindowToken.java
+++ b/services/core/java/com/android/server/wm/WindowToken.java
@@ -671,6 +671,11 @@ class WindowToken extends WindowContainer<WindowState> {
pw.print(" waitingToShow=true");
}
pw.println();
+ if (hasFixedRotationTransform()) {
+ pw.print(prefix);
+ pw.print("fixedRotationConfig=");
+ pw.println(mFixedRotationTransformState.mRotatedOverrideConfiguration);
+ }
}
@Override
diff --git a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java
index 906646894ee0..209db62f38de 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java
@@ -16,7 +16,6 @@
package com.android.server.wm;
-import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.view.Display.DEFAULT_DISPLAY;
@@ -159,7 +158,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase {
hiddenActivity.setVisible(false);
mDefaultDisplay.getConfiguration().windowConfiguration.setRotation(
mDefaultDisplay.getRotation());
- mController.initialize(ACTIVITY_TYPE_HOME, new SparseBooleanArray(), homeActivity);
+ initializeRecentsAnimationController(mController, homeActivity);
// Ensure that we are animating the target activity as well
assertTrue(mController.isAnimatingTask(homeActivity.getTask()));
@@ -182,7 +181,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase {
mDefaultDisplay.getConfiguration().windowConfiguration.setRotation(
mDefaultDisplay.getRotation());
- mController.initialize(ACTIVITY_TYPE_HOME, new SparseBooleanArray(), homeActivity);
+ initializeRecentsAnimationController(mController, homeActivity);
mController.startAnimation();
// Ensure that we are animating the app and wallpaper target
@@ -205,7 +204,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase {
mDefaultDisplay.getConfiguration().windowConfiguration.setRotation(
mDefaultDisplay.getRotation());
- mController.initialize(ACTIVITY_TYPE_HOME, new SparseBooleanArray(), homeActivity);
+ initializeRecentsAnimationController(mController, homeActivity);
mController.startAnimation();
// Cancel the animation and ensure the controller is still running
@@ -231,7 +230,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase {
doReturn(true).when(mDefaultDisplay.mWallpaperController).isWallpaperVisible();
// Start and finish the animation
- mController.initialize(ACTIVITY_TYPE_HOME, new SparseBooleanArray(), homeActivity);
+ initializeRecentsAnimationController(mController, homeActivity);
mController.startAnimation();
assertTrue(mController.isAnimatingTask(homeActivity.getTask()));
@@ -342,7 +341,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase {
assertEquals(Configuration.ORIENTATION_LANDSCAPE,
mDefaultDisplay.getConfiguration().orientation);
- mController.initialize(ACTIVITY_TYPE_HOME, new SparseBooleanArray(), homeActivity);
+ initializeRecentsAnimationController(mController, homeActivity);
assertEquals(homeActivity, mDefaultDisplay.mFixedRotationLaunchingApp);
@@ -358,6 +357,30 @@ public class RecentsAnimationControllerTest extends WindowTestsBase {
}
@Test
+ public void testClearFixedRotationLaunchingAppAfterCleanupAnimation() {
+ final ActivityRecord homeActivity = createHomeActivity();
+ homeActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+ final ActivityRecord activity = createActivityRecord(mDefaultDisplay,
+ WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD);
+ // Assume an activity is launching to different rotation.
+ mDefaultDisplay.setFixedRotationLaunchingApp(activity,
+ (mDefaultDisplay.getRotation() + 1) % 4);
+
+ assertTrue(activity.hasFixedRotationTransform());
+ assertEquals(activity, mDefaultDisplay.mFixedRotationLaunchingApp);
+
+ // Before the transition is done, the recents animation is triggered.
+ initializeRecentsAnimationController(mController, homeActivity);
+ assertFalse(homeActivity.hasFixedRotationTransform());
+
+ // Simulate giving up the swipe up gesture to keep the original activity as top.
+ mController.cleanupAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION);
+ // The rotation transform should be cleared after updating orientation with display.
+ assertFalse(activity.hasFixedRotationTransform());
+ assertNull(mDefaultDisplay.mFixedRotationLaunchingApp);
+ }
+
+ @Test
public void testWallpaperHasFixedRotationApplied() {
mWm.mIsFixedRotationTransformEnabled = true;
mWm.setRecentsAnimationController(mController);
@@ -394,7 +417,7 @@ public class RecentsAnimationControllerTest extends WindowTestsBase {
doReturn(true).when(mDefaultDisplay.mWallpaperController).isWallpaperVisible();
// Start the recents animation
- mController.initialize(ACTIVITY_TYPE_HOME, new SparseBooleanArray(), homeActivity);
+ initializeRecentsAnimationController(mController, homeActivity);
mDefaultDisplay.mWallpaperController.adjustWallpaperWindows();
@@ -433,6 +456,11 @@ public class RecentsAnimationControllerTest extends WindowTestsBase {
return homeActivity;
}
+ private static void initializeRecentsAnimationController(RecentsAnimationController controller,
+ ActivityRecord activity) {
+ controller.initialize(activity.getActivityType(), new SparseBooleanArray(), activity);
+ }
+
private static void verifyNoMoreInteractionsExceptAsBinder(IInterface binder) {
verify(binder, atLeast(0)).asBinder();
verifyNoMoreInteractions(binder);