Loading core/java/android/content/pm/ActivityInfo.java +5 −4 Original line number Diff line number Diff line Loading @@ -1605,11 +1605,11 @@ public class ActivityInfo extends ComponentInfo implements Parcelable { * fullscreen. While display rotation is fixed to landscape, the orientation requested by the * activity will be still respected by bounds resolution logic. For instance, if an activity * requests portrait orientation and this override is set, then activity will appear in the * letterbox mode for fixed orientation with the display rotated to the lanscape natural * letterbox mode for fixed orientation with the display rotated to the landscape natural * orientation. * * <p>This override is applicable only when natural orientation of the device is * landscape and display ignores orientation requestes. * landscape and display ignores orientation requests. * * <p>Main use case for this override are camera-using activities that are portrait-only and * assume alignment with natural device orientation. Such activities can automatically be Loading @@ -1626,8 +1626,9 @@ public class ActivityInfo extends ComponentInfo implements Parcelable { /** * Enables {@link #SCREEN_ORIENTATION_USER} which overrides any orientation requested * by the activity. Fixed orientation apps can be overridden to fullscreen on large * screen devices with ignoreOrientationRequest enabled with this override. * by the activity. Fixed-orientation and fixed–aspect ratio apps can be overridden * to full screen on large screen devices when this override is enabled. The override * applies only to default displays that have {@code ignoreOrientationRequest} set to true. * * @hide */ Loading services/core/java/com/android/server/wm/AppCompatAspectRatioOverrides.java +37 −5 Original line number Diff line number Diff line Loading @@ -27,10 +27,12 @@ import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_DISPLAY_SI import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_FULLSCREEN; import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_SPLIT_SCREEN; import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_UNSET; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.WindowManager.PROPERTY_COMPAT_ALLOW_MIN_ASPECT_RATIO_OVERRIDE; import static android.view.WindowManager.PROPERTY_COMPAT_ALLOW_ORIENTATION_OVERRIDE; import static android.view.WindowManager.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_FULLSCREEN_OVERRIDE; import static android.view.WindowManager.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE; import static android.window.DesktopExperienceFlags.LIMIT_SYSTEM_FULLSCREEN_OVERRIDE_TO_DEFAULT_DISPLAY; import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM; import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME; Loading @@ -40,6 +42,7 @@ import static com.android.server.wm.AppCompatUtils.isChangeEnabled; import static com.android.server.wm.AppCompatUtils.isDisplayIgnoreActivitySizeRestrictions; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.res.Configuration; Loading Loading @@ -79,6 +82,8 @@ class AppCompatAspectRatioOverrides { private final AppCompatDeviceStateQuery mAppCompatDeviceStateQuery; @NonNull private final AppCompatReachabilityOverrides mAppCompatReachabilityOverrides; @Nullable private Boolean mIsSystemFullscreenOverrideEnabled; AppCompatAspectRatioOverrides(@NonNull ActivityRecord activityRecord, @NonNull AppCompatConfiguration appCompatConfiguration, Loading Loading @@ -161,12 +166,31 @@ class AppCompatAspectRatioOverrides { } boolean isSystemOverrideToFullscreenEnabled() { final int aspectRatio = getUserMinAspectRatioOverrideCode(); return isSystemOverrideToFullscreenEnabled(mActivityRecord.mDisplayContent); } return isChangeEnabled(mActivityRecord, OVERRIDE_ANY_ORIENTATION_TO_USER) boolean isSystemOverrideToFullscreenEnabled(@Nullable DisplayContent dc) { if (mIsSystemFullscreenOverrideEnabled != null) { return mIsSystemFullscreenOverrideEnabled; } final int aspectRatio = getUserMinAspectRatioOverrideCode(); final boolean baseOverride = isChangeEnabled(mActivityRecord, OVERRIDE_ANY_ORIENTATION_TO_USER) && !mAllowOrientationOverrideOptProp.isFalse() && (aspectRatio == USER_MIN_ASPECT_RATIO_UNSET || aspectRatio == USER_MIN_ASPECT_RATIO_FULLSCREEN); if (dc != null && LIMIT_SYSTEM_FULLSCREEN_OVERRIDE_TO_DEFAULT_DISPLAY.isTrue()) { // If attached to display, cache full-screen override to maintain consistent // override behaviour when activity is moved between displays. // Only apply full-screen override if activity was started in default display. mIsSystemFullscreenOverrideEnabled = baseOverride && dc.getDisplayId() == DEFAULT_DISPLAY; return mIsSystemFullscreenOverrideEnabled; } return baseOverride; } /** Loading @@ -183,13 +207,21 @@ class AppCompatAspectRatioOverrides { } /** * Whether to ignore fixed orientation, aspect ratio and resizability of activity. * Whether to ignore fixed orientation, aspect ratio, and resizability of the activity. */ boolean hasFullscreenOverride() { return shouldApplyUserFullscreenOverride() || isSystemOverrideToFullscreenEnabled() || shouldIgnoreActivitySizeRestrictionsForDisplay(); } /** * Whether to ignore fixed orientation, aspect ratio, and resizability of the activity. */ boolean hasFullscreenOverride(@NonNull DisplayContent dc) { return shouldApplyUserFullscreenOverride() || isSystemOverrideToFullscreenEnabled(dc) || shouldIgnoreActivitySizeRestrictionsForDisplay(); } boolean shouldIgnoreActivitySizeRestrictionsForDisplay() { return isDisplayIgnoreActivitySizeRestrictions(mActivityRecord) && !mAllowOrientationOverrideOptProp.isFalse(); Loading services/core/java/com/android/server/wm/Task.java +2 −1 Original line number Diff line number Diff line Loading @@ -1917,10 +1917,11 @@ class Task extends TaskFragment { private void updateForceResizeOverrides(@NonNull ActivityRecord r) { final AppCompatResizeOverrides resizeOverrides = r.mAppCompatController .getResizeOverrides(); // Pass task's displayContent as activity's displayContent is not attached yet. mForceResizeOverride = resizeOverrides.shouldOverrideForceResizeApp() || r.isUniversalResizeable() || r.mAppCompatController.getAspectRatioOverrides() .hasFullscreenOverride(); .hasFullscreenOverride(mDisplayContent); mForceNonResizeOverride = resizeOverrides.shouldOverrideForceNonResizeApp(); } Loading services/tests/wmtests/src/com/android/server/wm/AppCompatActivityRobot.java +4 −0 Original line number Diff line number Diff line Loading @@ -163,6 +163,10 @@ class AppCompatActivityRobot { doReturn(enabled).when(mDisplayContent).isDisplayIgnoreActivitySizeRestrictions(); } void setDisplayId(int displayId) { doReturn(displayId).when(mDisplayContent).getDisplayId(); } void configureTaskBounds(@NonNull Rect taskBounds) { doReturn(taskBounds).when(mTaskStack.top()).getBounds(); } Loading services/tests/wmtests/src/com/android/server/wm/AppCompatAspectRatioOverridesTest.java +57 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.content.pm.ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_3_2; import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_FULLSCREEN; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Surface.ROTATION_90; import static android.view.WindowManager.PROPERTY_COMPAT_ALLOW_MIN_ASPECT_RATIO_OVERRIDE; import static android.view.WindowManager.PROPERTY_COMPAT_ALLOW_ORIENTATION_OVERRIDE; Loading @@ -32,6 +33,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import android.compat.testing.PlatformCompatChangeRule; import android.content.pm.ActivityInfo; import android.platform.test.annotations.EnableFlags; import android.platform.test.annotations.Presubmit; Loading Loading @@ -381,6 +383,61 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { }); } @Test @EnableFlags(Flags.FLAG_LIMIT_SYSTEM_FULLSCREEN_OVERRIDE_TO_DEFAULT_DISPLAY) @EnableCompatChanges(ActivityInfo.OVERRIDE_ANY_ORIENTATION_TO_USER) public void testSystemFullscreenOverride_isDefaultDisplay_true() { runTestScenario((robot) -> { robot.applyOnActivity((a) -> { a.setDisplayId(DEFAULT_DISPLAY); a.createActivityWithComponent(); a.setIgnoreOrientationRequest(true); a.configureTopActivity(/* minAspect */ -1f, /* maxAspect */-1f, SCREEN_ORIENTATION_LANDSCAPE, true); }); robot.checkHasFullscreenOverride(true); }); } @Test @EnableFlags(Flags.FLAG_LIMIT_SYSTEM_FULLSCREEN_OVERRIDE_TO_DEFAULT_DISPLAY) @EnableCompatChanges(ActivityInfo.OVERRIDE_ANY_ORIENTATION_TO_USER) public void testSystemFullscreenOverride_notDefaultDisplay_false() { runTestScenario((robot) -> { robot.applyOnActivity((a) -> { a.setDisplayId(DEFAULT_DISPLAY + 2); a.createActivityWithComponent(); a.setIgnoreOrientationRequest(true); a.configureTopActivity(/* minAspect */ -1f, /* maxAspect */-1f, SCREEN_ORIENTATION_LANDSCAPE, true); }); robot.checkHasFullscreenOverride(false); }); } @Test @EnableFlags(Flags.FLAG_LIMIT_SYSTEM_FULLSCREEN_OVERRIDE_TO_DEFAULT_DISPLAY) @EnableCompatChanges(ActivityInfo.OVERRIDE_ANY_ORIENTATION_TO_USER) public void testSystemFullscreenOverride_movedOutOfDefaultDisplay_true() { runTestScenario((robot) -> { robot.applyOnActivity((a) -> { a.setDisplayId(DEFAULT_DISPLAY); a.createActivityWithComponent(); a.setIgnoreOrientationRequest(true); a.configureTopActivity(/* minAspect */ -1f, /* maxAspect */-1f, SCREEN_ORIENTATION_LANDSCAPE, true); // Simulate display move. a.setDisplayId(DEFAULT_DISPLAY + 2); }); robot.checkHasFullscreenOverride(true); }); } /** * Runs a test scenario providing a Robot. */ Loading Loading
core/java/android/content/pm/ActivityInfo.java +5 −4 Original line number Diff line number Diff line Loading @@ -1605,11 +1605,11 @@ public class ActivityInfo extends ComponentInfo implements Parcelable { * fullscreen. While display rotation is fixed to landscape, the orientation requested by the * activity will be still respected by bounds resolution logic. For instance, if an activity * requests portrait orientation and this override is set, then activity will appear in the * letterbox mode for fixed orientation with the display rotated to the lanscape natural * letterbox mode for fixed orientation with the display rotated to the landscape natural * orientation. * * <p>This override is applicable only when natural orientation of the device is * landscape and display ignores orientation requestes. * landscape and display ignores orientation requests. * * <p>Main use case for this override are camera-using activities that are portrait-only and * assume alignment with natural device orientation. Such activities can automatically be Loading @@ -1626,8 +1626,9 @@ public class ActivityInfo extends ComponentInfo implements Parcelable { /** * Enables {@link #SCREEN_ORIENTATION_USER} which overrides any orientation requested * by the activity. Fixed orientation apps can be overridden to fullscreen on large * screen devices with ignoreOrientationRequest enabled with this override. * by the activity. Fixed-orientation and fixed–aspect ratio apps can be overridden * to full screen on large screen devices when this override is enabled. The override * applies only to default displays that have {@code ignoreOrientationRequest} set to true. * * @hide */ Loading
services/core/java/com/android/server/wm/AppCompatAspectRatioOverrides.java +37 −5 Original line number Diff line number Diff line Loading @@ -27,10 +27,12 @@ import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_DISPLAY_SI import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_FULLSCREEN; import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_SPLIT_SCREEN; import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_UNSET; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.WindowManager.PROPERTY_COMPAT_ALLOW_MIN_ASPECT_RATIO_OVERRIDE; import static android.view.WindowManager.PROPERTY_COMPAT_ALLOW_ORIENTATION_OVERRIDE; import static android.view.WindowManager.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_FULLSCREEN_OVERRIDE; import static android.view.WindowManager.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE; import static android.window.DesktopExperienceFlags.LIMIT_SYSTEM_FULLSCREEN_OVERRIDE_TO_DEFAULT_DISPLAY; import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM; import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME; Loading @@ -40,6 +42,7 @@ import static com.android.server.wm.AppCompatUtils.isChangeEnabled; import static com.android.server.wm.AppCompatUtils.isDisplayIgnoreActivitySizeRestrictions; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.res.Configuration; Loading Loading @@ -79,6 +82,8 @@ class AppCompatAspectRatioOverrides { private final AppCompatDeviceStateQuery mAppCompatDeviceStateQuery; @NonNull private final AppCompatReachabilityOverrides mAppCompatReachabilityOverrides; @Nullable private Boolean mIsSystemFullscreenOverrideEnabled; AppCompatAspectRatioOverrides(@NonNull ActivityRecord activityRecord, @NonNull AppCompatConfiguration appCompatConfiguration, Loading Loading @@ -161,12 +166,31 @@ class AppCompatAspectRatioOverrides { } boolean isSystemOverrideToFullscreenEnabled() { final int aspectRatio = getUserMinAspectRatioOverrideCode(); return isSystemOverrideToFullscreenEnabled(mActivityRecord.mDisplayContent); } return isChangeEnabled(mActivityRecord, OVERRIDE_ANY_ORIENTATION_TO_USER) boolean isSystemOverrideToFullscreenEnabled(@Nullable DisplayContent dc) { if (mIsSystemFullscreenOverrideEnabled != null) { return mIsSystemFullscreenOverrideEnabled; } final int aspectRatio = getUserMinAspectRatioOverrideCode(); final boolean baseOverride = isChangeEnabled(mActivityRecord, OVERRIDE_ANY_ORIENTATION_TO_USER) && !mAllowOrientationOverrideOptProp.isFalse() && (aspectRatio == USER_MIN_ASPECT_RATIO_UNSET || aspectRatio == USER_MIN_ASPECT_RATIO_FULLSCREEN); if (dc != null && LIMIT_SYSTEM_FULLSCREEN_OVERRIDE_TO_DEFAULT_DISPLAY.isTrue()) { // If attached to display, cache full-screen override to maintain consistent // override behaviour when activity is moved between displays. // Only apply full-screen override if activity was started in default display. mIsSystemFullscreenOverrideEnabled = baseOverride && dc.getDisplayId() == DEFAULT_DISPLAY; return mIsSystemFullscreenOverrideEnabled; } return baseOverride; } /** Loading @@ -183,13 +207,21 @@ class AppCompatAspectRatioOverrides { } /** * Whether to ignore fixed orientation, aspect ratio and resizability of activity. * Whether to ignore fixed orientation, aspect ratio, and resizability of the activity. */ boolean hasFullscreenOverride() { return shouldApplyUserFullscreenOverride() || isSystemOverrideToFullscreenEnabled() || shouldIgnoreActivitySizeRestrictionsForDisplay(); } /** * Whether to ignore fixed orientation, aspect ratio, and resizability of the activity. */ boolean hasFullscreenOverride(@NonNull DisplayContent dc) { return shouldApplyUserFullscreenOverride() || isSystemOverrideToFullscreenEnabled(dc) || shouldIgnoreActivitySizeRestrictionsForDisplay(); } boolean shouldIgnoreActivitySizeRestrictionsForDisplay() { return isDisplayIgnoreActivitySizeRestrictions(mActivityRecord) && !mAllowOrientationOverrideOptProp.isFalse(); Loading
services/core/java/com/android/server/wm/Task.java +2 −1 Original line number Diff line number Diff line Loading @@ -1917,10 +1917,11 @@ class Task extends TaskFragment { private void updateForceResizeOverrides(@NonNull ActivityRecord r) { final AppCompatResizeOverrides resizeOverrides = r.mAppCompatController .getResizeOverrides(); // Pass task's displayContent as activity's displayContent is not attached yet. mForceResizeOverride = resizeOverrides.shouldOverrideForceResizeApp() || r.isUniversalResizeable() || r.mAppCompatController.getAspectRatioOverrides() .hasFullscreenOverride(); .hasFullscreenOverride(mDisplayContent); mForceNonResizeOverride = resizeOverrides.shouldOverrideForceNonResizeApp(); } Loading
services/tests/wmtests/src/com/android/server/wm/AppCompatActivityRobot.java +4 −0 Original line number Diff line number Diff line Loading @@ -163,6 +163,10 @@ class AppCompatActivityRobot { doReturn(enabled).when(mDisplayContent).isDisplayIgnoreActivitySizeRestrictions(); } void setDisplayId(int displayId) { doReturn(displayId).when(mDisplayContent).getDisplayId(); } void configureTaskBounds(@NonNull Rect taskBounds) { doReturn(taskBounds).when(mTaskStack.top()).getBounds(); } Loading
services/tests/wmtests/src/com/android/server/wm/AppCompatAspectRatioOverridesTest.java +57 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.content.pm.ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_3_2; import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_FULLSCREEN; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Surface.ROTATION_90; import static android.view.WindowManager.PROPERTY_COMPAT_ALLOW_MIN_ASPECT_RATIO_OVERRIDE; import static android.view.WindowManager.PROPERTY_COMPAT_ALLOW_ORIENTATION_OVERRIDE; Loading @@ -32,6 +33,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import android.compat.testing.PlatformCompatChangeRule; import android.content.pm.ActivityInfo; import android.platform.test.annotations.EnableFlags; import android.platform.test.annotations.Presubmit; Loading Loading @@ -381,6 +383,61 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { }); } @Test @EnableFlags(Flags.FLAG_LIMIT_SYSTEM_FULLSCREEN_OVERRIDE_TO_DEFAULT_DISPLAY) @EnableCompatChanges(ActivityInfo.OVERRIDE_ANY_ORIENTATION_TO_USER) public void testSystemFullscreenOverride_isDefaultDisplay_true() { runTestScenario((robot) -> { robot.applyOnActivity((a) -> { a.setDisplayId(DEFAULT_DISPLAY); a.createActivityWithComponent(); a.setIgnoreOrientationRequest(true); a.configureTopActivity(/* minAspect */ -1f, /* maxAspect */-1f, SCREEN_ORIENTATION_LANDSCAPE, true); }); robot.checkHasFullscreenOverride(true); }); } @Test @EnableFlags(Flags.FLAG_LIMIT_SYSTEM_FULLSCREEN_OVERRIDE_TO_DEFAULT_DISPLAY) @EnableCompatChanges(ActivityInfo.OVERRIDE_ANY_ORIENTATION_TO_USER) public void testSystemFullscreenOverride_notDefaultDisplay_false() { runTestScenario((robot) -> { robot.applyOnActivity((a) -> { a.setDisplayId(DEFAULT_DISPLAY + 2); a.createActivityWithComponent(); a.setIgnoreOrientationRequest(true); a.configureTopActivity(/* minAspect */ -1f, /* maxAspect */-1f, SCREEN_ORIENTATION_LANDSCAPE, true); }); robot.checkHasFullscreenOverride(false); }); } @Test @EnableFlags(Flags.FLAG_LIMIT_SYSTEM_FULLSCREEN_OVERRIDE_TO_DEFAULT_DISPLAY) @EnableCompatChanges(ActivityInfo.OVERRIDE_ANY_ORIENTATION_TO_USER) public void testSystemFullscreenOverride_movedOutOfDefaultDisplay_true() { runTestScenario((robot) -> { robot.applyOnActivity((a) -> { a.setDisplayId(DEFAULT_DISPLAY); a.createActivityWithComponent(); a.setIgnoreOrientationRequest(true); a.configureTopActivity(/* minAspect */ -1f, /* maxAspect */-1f, SCREEN_ORIENTATION_LANDSCAPE, true); // Simulate display move. a.setDisplayId(DEFAULT_DISPLAY + 2); }); robot.checkHasFullscreenOverride(true); }); } /** * Runs a test scenario providing a Robot. */ Loading