Loading core/java/android/content/pm/ActivityInfo.java +11 −0 Original line number Diff line number Diff line Loading @@ -1057,6 +1057,17 @@ public class ActivityInfo extends ComponentInfo implements Parcelable { @TestApi public static final long ALWAYS_SANDBOX_DISPLAY_APIS = 185004937L; // buganizer id /** * This change id excludes the packages it is applied to from ignoreOrientationRequest behaviour * that can be enabled by the device manufacturers for the com.android.server.wm.DisplayArea * or for the whole display. * @hide */ @ChangeId @Overridable @Disabled public static final long OVERRIDE_RESPECT_REQUESTED_ORIENTATION = 236283604L; // buganizer id /** * This change id excludes the packages it is applied to from the camera compat force rotation * treatment. See com.android.server.wm.DisplayRotationCompatPolicy for context. Loading services/core/java/com/android/server/wm/DisplayArea.java +17 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.wm; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; Loading Loading @@ -245,7 +246,22 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> { || orientation == ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) { return false; } return getIgnoreOrientationRequest(); return getIgnoreOrientationRequest() && !shouldRespectOrientationRequestDueToPerAppOverride(); } private boolean shouldRespectOrientationRequestDueToPerAppOverride() { if (mDisplayContent == null) { return false; } ActivityRecord activity = mDisplayContent.topRunningActivity( /* considerKeyguardState= */ true); return activity != null && activity.getTaskFragment() != null // Checking TaskFragment rather than ActivityRecord to ensure that transition // between fullscreen and PiP would work well. Checking TaskFragment rather than // Task to ensure that Activity Embedding is excluded. && activity.getTaskFragment().getWindowingMode() == WINDOWING_MODE_FULLSCREEN && activity.mLetterboxUiController.isOverrideRespectRequestedOrientationEnabled(); } boolean getIgnoreOrientationRequest() { Loading services/core/java/com/android/server/wm/LetterboxUiController.java +9 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static android.content.pm.ActivityInfo.OVERRIDE_ENABLE_COMPAT_FAKE_FOCUS; import static android.content.pm.ActivityInfo.OVERRIDE_ENABLE_COMPAT_IGNORE_REQUESTED_ORIENTATION; import static android.content.pm.ActivityInfo.OVERRIDE_LANDSCAPE_ORIENTATION_TO_REVERSE_LANDSCAPE; import static android.content.pm.ActivityInfo.OVERRIDE_ORIENTATION_ONLY_FOR_CAMERA; import static android.content.pm.ActivityInfo.OVERRIDE_RESPECT_REQUESTED_ORIENTATION; import static android.content.pm.ActivityInfo.OVERRIDE_UNDEFINED_ORIENTATION_TO_NOSENSOR; import static android.content.pm.ActivityInfo.OVERRIDE_UNDEFINED_ORIENTATION_TO_PORTRAIT; import static android.content.pm.ActivityInfo.OVERRIDE_USE_DISPLAY_LANDSCAPE_NATURAL_ORIENTATION; Loading Loading @@ -143,6 +144,8 @@ final class LetterboxUiController { private final boolean mIsOverrideOrientationOnlyForCameraEnabled; // Corresponds to OVERRIDE_USE_DISPLAY_LANDSCAPE_NATURAL_ORIENTATION private final boolean mIsOverrideUseDisplayLandscapeNaturalOrientationEnabled; // Corresponds to OVERRIDE_RESPECT_REQUESTED_ORIENTATION private final boolean mIsOverrideRespectRequestedOrientationEnabled; // Corresponds to OVERRIDE_CAMERA_COMPAT_DISABLE_FORCE_ROTATION private final boolean mIsOverrideCameraCompatDisableForceRotationEnabled; Loading Loading @@ -272,6 +275,8 @@ final class LetterboxUiController { isCompatChangeEnabled(OVERRIDE_ORIENTATION_ONLY_FOR_CAMERA); mIsOverrideUseDisplayLandscapeNaturalOrientationEnabled = isCompatChangeEnabled(OVERRIDE_USE_DISPLAY_LANDSCAPE_NATURAL_ORIENTATION); mIsOverrideRespectRequestedOrientationEnabled = isCompatChangeEnabled(OVERRIDE_RESPECT_REQUESTED_ORIENTATION); mIsOverrideCameraCompatDisableForceRotationEnabled = isCompatChangeEnabled(OVERRIDE_CAMERA_COMPAT_DISABLE_FORCE_ROTATION); Loading Loading @@ -418,6 +423,10 @@ final class LetterboxUiController { mIsRefreshAfterRotationRequested = isRequested; } boolean isOverrideRespectRequestedOrientationEnabled() { return mIsOverrideRespectRequestedOrientationEnabled; } /** * Whether should fix display orientation to landscape natural orientation when a task is * fullscreen and the display is ignoring orientation requests. Loading services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +37 −0 Original line number Diff line number Diff line Loading @@ -1875,6 +1875,43 @@ public class SizeCompatTests extends WindowTestsBase { activity.getBounds().width(), 0.5); } @Test @EnableCompatChanges({ActivityInfo.OVERRIDE_RESPECT_REQUESTED_ORIENTATION}) public void testOverrideRespectRequestedOrientationIsEnabled_orientationIsRespected() { // Set up a display in landscape setUpDisplaySizeWithApp(2800, 1400); final ActivityRecord activity = buildActivityRecord(/* supportsSizeChanges= */ false, RESIZE_MODE_UNRESIZEABLE, SCREEN_ORIENTATION_PORTRAIT); activity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); // Display should be rotated. assertEquals(SCREEN_ORIENTATION_PORTRAIT, activity.mDisplayContent.getOrientation()); // No size compat mode assertFalse(activity.inSizeCompatMode()); } @Test @EnableCompatChanges({ActivityInfo.OVERRIDE_RESPECT_REQUESTED_ORIENTATION}) public void testOverrideRespectRequestedOrientationIsEnabled_multiWindow_orientationIgnored() { // Set up a display in landscape setUpDisplaySizeWithApp(2800, 1400); final ActivityRecord activity = buildActivityRecord(/* supportsSizeChanges= */ false, RESIZE_MODE_UNRESIZEABLE, SCREEN_ORIENTATION_PORTRAIT); TaskFragment taskFragment = activity.getTaskFragment(); spyOn(taskFragment); activity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); doReturn(WINDOWING_MODE_MULTI_WINDOW).when(taskFragment).getWindowingMode(); // Display should not be rotated. assertEquals(SCREEN_ORIENTATION_UNSPECIFIED, activity.mDisplayContent.getOrientation()); // No size compat mode assertFalse(activity.inSizeCompatMode()); } @Test public void testSplitAspectRatioForUnresizableLandscapeApps() { // Set up a display in portrait and ignoring orientation request. Loading Loading
core/java/android/content/pm/ActivityInfo.java +11 −0 Original line number Diff line number Diff line Loading @@ -1057,6 +1057,17 @@ public class ActivityInfo extends ComponentInfo implements Parcelable { @TestApi public static final long ALWAYS_SANDBOX_DISPLAY_APIS = 185004937L; // buganizer id /** * This change id excludes the packages it is applied to from ignoreOrientationRequest behaviour * that can be enabled by the device manufacturers for the com.android.server.wm.DisplayArea * or for the whole display. * @hide */ @ChangeId @Overridable @Disabled public static final long OVERRIDE_RESPECT_REQUESTED_ORIENTATION = 236283604L; // buganizer id /** * This change id excludes the packages it is applied to from the camera compat force rotation * treatment. See com.android.server.wm.DisplayRotationCompatPolicy for context. Loading
services/core/java/com/android/server/wm/DisplayArea.java +17 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.wm; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; Loading Loading @@ -245,7 +246,22 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> { || orientation == ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) { return false; } return getIgnoreOrientationRequest(); return getIgnoreOrientationRequest() && !shouldRespectOrientationRequestDueToPerAppOverride(); } private boolean shouldRespectOrientationRequestDueToPerAppOverride() { if (mDisplayContent == null) { return false; } ActivityRecord activity = mDisplayContent.topRunningActivity( /* considerKeyguardState= */ true); return activity != null && activity.getTaskFragment() != null // Checking TaskFragment rather than ActivityRecord to ensure that transition // between fullscreen and PiP would work well. Checking TaskFragment rather than // Task to ensure that Activity Embedding is excluded. && activity.getTaskFragment().getWindowingMode() == WINDOWING_MODE_FULLSCREEN && activity.mLetterboxUiController.isOverrideRespectRequestedOrientationEnabled(); } boolean getIgnoreOrientationRequest() { Loading
services/core/java/com/android/server/wm/LetterboxUiController.java +9 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static android.content.pm.ActivityInfo.OVERRIDE_ENABLE_COMPAT_FAKE_FOCUS; import static android.content.pm.ActivityInfo.OVERRIDE_ENABLE_COMPAT_IGNORE_REQUESTED_ORIENTATION; import static android.content.pm.ActivityInfo.OVERRIDE_LANDSCAPE_ORIENTATION_TO_REVERSE_LANDSCAPE; import static android.content.pm.ActivityInfo.OVERRIDE_ORIENTATION_ONLY_FOR_CAMERA; import static android.content.pm.ActivityInfo.OVERRIDE_RESPECT_REQUESTED_ORIENTATION; import static android.content.pm.ActivityInfo.OVERRIDE_UNDEFINED_ORIENTATION_TO_NOSENSOR; import static android.content.pm.ActivityInfo.OVERRIDE_UNDEFINED_ORIENTATION_TO_PORTRAIT; import static android.content.pm.ActivityInfo.OVERRIDE_USE_DISPLAY_LANDSCAPE_NATURAL_ORIENTATION; Loading Loading @@ -143,6 +144,8 @@ final class LetterboxUiController { private final boolean mIsOverrideOrientationOnlyForCameraEnabled; // Corresponds to OVERRIDE_USE_DISPLAY_LANDSCAPE_NATURAL_ORIENTATION private final boolean mIsOverrideUseDisplayLandscapeNaturalOrientationEnabled; // Corresponds to OVERRIDE_RESPECT_REQUESTED_ORIENTATION private final boolean mIsOverrideRespectRequestedOrientationEnabled; // Corresponds to OVERRIDE_CAMERA_COMPAT_DISABLE_FORCE_ROTATION private final boolean mIsOverrideCameraCompatDisableForceRotationEnabled; Loading Loading @@ -272,6 +275,8 @@ final class LetterboxUiController { isCompatChangeEnabled(OVERRIDE_ORIENTATION_ONLY_FOR_CAMERA); mIsOverrideUseDisplayLandscapeNaturalOrientationEnabled = isCompatChangeEnabled(OVERRIDE_USE_DISPLAY_LANDSCAPE_NATURAL_ORIENTATION); mIsOverrideRespectRequestedOrientationEnabled = isCompatChangeEnabled(OVERRIDE_RESPECT_REQUESTED_ORIENTATION); mIsOverrideCameraCompatDisableForceRotationEnabled = isCompatChangeEnabled(OVERRIDE_CAMERA_COMPAT_DISABLE_FORCE_ROTATION); Loading Loading @@ -418,6 +423,10 @@ final class LetterboxUiController { mIsRefreshAfterRotationRequested = isRequested; } boolean isOverrideRespectRequestedOrientationEnabled() { return mIsOverrideRespectRequestedOrientationEnabled; } /** * Whether should fix display orientation to landscape natural orientation when a task is * fullscreen and the display is ignoring orientation requests. Loading
services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +37 −0 Original line number Diff line number Diff line Loading @@ -1875,6 +1875,43 @@ public class SizeCompatTests extends WindowTestsBase { activity.getBounds().width(), 0.5); } @Test @EnableCompatChanges({ActivityInfo.OVERRIDE_RESPECT_REQUESTED_ORIENTATION}) public void testOverrideRespectRequestedOrientationIsEnabled_orientationIsRespected() { // Set up a display in landscape setUpDisplaySizeWithApp(2800, 1400); final ActivityRecord activity = buildActivityRecord(/* supportsSizeChanges= */ false, RESIZE_MODE_UNRESIZEABLE, SCREEN_ORIENTATION_PORTRAIT); activity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); // Display should be rotated. assertEquals(SCREEN_ORIENTATION_PORTRAIT, activity.mDisplayContent.getOrientation()); // No size compat mode assertFalse(activity.inSizeCompatMode()); } @Test @EnableCompatChanges({ActivityInfo.OVERRIDE_RESPECT_REQUESTED_ORIENTATION}) public void testOverrideRespectRequestedOrientationIsEnabled_multiWindow_orientationIgnored() { // Set up a display in landscape setUpDisplaySizeWithApp(2800, 1400); final ActivityRecord activity = buildActivityRecord(/* supportsSizeChanges= */ false, RESIZE_MODE_UNRESIZEABLE, SCREEN_ORIENTATION_PORTRAIT); TaskFragment taskFragment = activity.getTaskFragment(); spyOn(taskFragment); activity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); doReturn(WINDOWING_MODE_MULTI_WINDOW).when(taskFragment).getWindowingMode(); // Display should not be rotated. assertEquals(SCREEN_ORIENTATION_UNSPECIFIED, activity.mDisplayContent.getOrientation()); // No size compat mode assertFalse(activity.inSizeCompatMode()); } @Test public void testSplitAspectRatioForUnresizableLandscapeApps() { // Set up a display in portrait and ignoring orientation request. Loading