From 80d69d3fe0b82eae9c4c1c01545a6fcf79ee72c3 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Fri, 24 Jun 2022 17:14:09 +0800 Subject: [PATCH] Respect letterbox config for exiting pip with fixed orientation 1. If the display ignores orientation request, no need to send the target rotation to PipTaskOrganizer. Otherwise the animation for PiP-to-fullscreen will have a rotation effect. 2. Because requested orientation is ignored, the activity with fixed orientation will be letterboxed. Then when expanding pip, it should resolve letterbox policy configuration. Otherwise there will be additional non-letterbox config change that causes to flicker. Fix: 235599028 Test: DiplayContentTests#testFixedRotationWithPip Change-Id: Icc94238d349e19627e6d9316f7525b9e531c71b5 --- .../com/android/server/wm/ActivityRecord.java | 16 +++++++--------- .../com/android/server/wm/DisplayContent.java | 3 ++- .../android/server/wm/DisplayContentTests.java | 7 +++++++ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index b3b392c149a15..9a050e3400d80 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -7788,11 +7788,15 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A newParentConfiguration.windowConfiguration.getWindowingMode(); final boolean isFixedOrientationLetterboxAllowed = parentWindowingMode == WINDOWING_MODE_MULTI_WINDOW - || parentWindowingMode == WINDOWING_MODE_FULLSCREEN; + || parentWindowingMode == WINDOWING_MODE_FULLSCREEN + // Switching from PiP to fullscreen. + || (parentWindowingMode == WINDOWING_MODE_PINNED + && resolvedConfig.windowConfiguration.getWindowingMode() + == WINDOWING_MODE_FULLSCREEN); // TODO(b/181207944): Consider removing the if condition and always run // resolveFixedOrientationConfiguration() since this should be applied for all cases. if (isFixedOrientationLetterboxAllowed) { - resolveFixedOrientationConfiguration(newParentConfiguration, parentWindowingMode); + resolveFixedOrientationConfiguration(newParentConfiguration); } if (mCompatDisplayInsets != null) { @@ -8084,8 +8088,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A *

If letterboxed due to fixed orientation then aspect ratio restrictions are also applied * in this method. */ - private void resolveFixedOrientationConfiguration(@NonNull Configuration newParentConfig, - int windowingMode) { + private void resolveFixedOrientationConfiguration(@NonNull Configuration newParentConfig) { mLetterboxBoundsForFixedOrientationAndAspectRatio = null; mIsEligibleForFixedOrientationLetterbox = false; final Rect parentBounds = newParentConfig.windowConfiguration.getBounds(); @@ -8105,11 +8108,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (organizedTf != null && !organizedTf.fillsParent()) { return; } - if (windowingMode == WINDOWING_MODE_PINNED) { - // PiP bounds have higher priority than the requested orientation. Otherwise the - // activity may be squeezed into a small piece. - return; - } final Rect resolvedBounds = getResolvedOverrideConfiguration().windowConfiguration.getBounds(); diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index ad3b8ee119d31..a1bf91514d8b8 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -1610,7 +1610,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp if (mTransitionController.useShellTransitionsRotation()) { return ROTATION_UNDEFINED; } - if (!WindowManagerService.ENABLE_FIXED_ROTATION_TRANSFORM) { + if (!WindowManagerService.ENABLE_FIXED_ROTATION_TRANSFORM + || getIgnoreOrientationRequest()) { return ROTATION_UNDEFINED; } if (r.mOrientation == ActivityInfo.SCREEN_ORIENTATION_BEHIND) { 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 d737963f80e7d..40e266c713281 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java @@ -1699,6 +1699,13 @@ public class DisplayContentTests extends WindowTestsBase { assertFalse(displayContent.mPinnedTaskController.isFreezingTaskConfig(pinnedTask)); assertEquals(pinnedActivity.getConfiguration().orientation, displayContent.getConfiguration().orientation); + + // No need to apply rotation if the display ignores orientation request. + doCallRealMethod().when(displayContent).rotationForActivityInDifferentOrientation(any()); + pinnedActivity.mOrientation = SCREEN_ORIENTATION_LANDSCAPE; + displayContent.setIgnoreOrientationRequest(true); + assertEquals(WindowConfiguration.ROTATION_UNDEFINED, + displayContent.rotationForActivityInDifferentOrientation(pinnedActivity)); } @Test