Loading services/core/java/com/android/server/wm/AppCompatAspectRatioPolicy.java +6 −1 Original line number Diff line number Diff line Loading @@ -295,9 +295,14 @@ class AppCompatAspectRatioPolicy { // {@link ActivityRecord#shouldCreateAppCompatDisplayInsets()} will be false for // both activities that are naturally resizeable and activities that have been // forced resizeable. // Camera compat mode is an exception to this, where the activity is letterboxed // to an aspect ratio commonly found on phones, e.g. 16:9, to avoid issues like // stretching of the camera preview. || (Flags.ignoreAspectRatioRestrictionsForResizeableFreeformActivities() && task.getWindowingMode() == WINDOWING_MODE_FREEFORM && !mActivityRecord.shouldCreateAppCompatDisplayInsets())) { && !mActivityRecord.shouldCreateAppCompatDisplayInsets() && !AppCompatCameraPolicy.shouldCameraCompatControlAspectRatio( mActivityRecord))) { return false; } Loading services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +16 −8 Original line number Diff line number Diff line Loading @@ -4953,7 +4953,8 @@ public class SizeCompatTests extends WindowTestsBase { } @Test @EnableFlags(Flags.FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING) @EnableFlags({Flags.FLAG_IGNORE_ASPECT_RATIO_RESTRICTIONS_FOR_RESIZEABLE_FREEFORM_ACTIVITIES, Flags.FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING}) public void testCameraCompatAspectRatioAppliedForFixedOrientationCameraActivities() { // Needed to create camera compat policy in DisplayContent. allowDesktopMode(); Loading @@ -4965,7 +4966,8 @@ public class SizeCompatTests extends WindowTestsBase { setupCameraCompatAspectRatio(cameraCompatAspectRatio, display); // Create task on test display. final Task task = new TaskBuilder(mSupervisor).setDisplay(display).build(); final Task task = new TaskBuilder(mSupervisor).setDisplay(display) .setWindowingMode(WINDOWING_MODE_FREEFORM).build(); // Create fixed portrait activity. final ActivityRecord fixedOrientationActivity = new ActivityBuilder(mAtm) Loading @@ -4978,7 +4980,8 @@ public class SizeCompatTests extends WindowTestsBase { } @Test @EnableFlags(Flags.FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING) @EnableFlags({Flags.FLAG_IGNORE_ASPECT_RATIO_RESTRICTIONS_FOR_RESIZEABLE_FREEFORM_ACTIVITIES, Flags.FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING}) public void testCameraCompatAspectRatioForFixedOrientationCameraActivitiesPortraitWindow() { // Needed to create camera compat policy in DisplayContent. allowDesktopMode(); Loading @@ -4990,7 +4993,8 @@ public class SizeCompatTests extends WindowTestsBase { setupCameraCompatAspectRatio(cameraCompatAspectRatio, display); // Create task on test display. final Task task = new TaskBuilder(mSupervisor).setDisplay(display).build(); final Task task = new TaskBuilder(mSupervisor).setDisplay(display) .setWindowingMode(WINDOWING_MODE_FREEFORM).build(); // Create fixed portrait activity. final ActivityRecord fixedOrientationActivity = new ActivityBuilder(mAtm) Loading @@ -5003,7 +5007,8 @@ public class SizeCompatTests extends WindowTestsBase { } @Test @EnableFlags(Flags.FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING) @EnableFlags({Flags.FLAG_IGNORE_ASPECT_RATIO_RESTRICTIONS_FOR_RESIZEABLE_FREEFORM_ACTIVITIES, Flags.FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING}) public void testCameraCompatAspectRatioAppliedInsteadOfDefaultAspectRatio() { // Needed to create camera compat policy in DisplayContent. allowDesktopMode(); Loading @@ -5015,7 +5020,8 @@ public class SizeCompatTests extends WindowTestsBase { setupCameraCompatAspectRatio(cameraCompatAspectRatio, display); // Create task on test display. final Task task = new TaskBuilder(mSupervisor).setDisplay(display).build(); final Task task = new TaskBuilder(mSupervisor).setDisplay(display) .setWindowingMode(WINDOWING_MODE_FREEFORM).build(); // App's target min aspect ratio - this should not be used, as camera controls aspect ratio. final float targetMinAspectRatio = 4.0f; Loading @@ -5032,7 +5038,8 @@ public class SizeCompatTests extends WindowTestsBase { } @Test @EnableFlags(Flags.FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING) @EnableFlags({Flags.FLAG_IGNORE_ASPECT_RATIO_RESTRICTIONS_FOR_RESIZEABLE_FREEFORM_ACTIVITIES, Flags.FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING}) public void testCameraCompatAspectRatio_defaultAspectRatioAppliedWhenGreater() { // Needed to create camera compat policy in DisplayContent. allowDesktopMode(); Loading @@ -5044,7 +5051,8 @@ public class SizeCompatTests extends WindowTestsBase { setupCameraCompatAspectRatio(cameraCompatAspectRatio, display); // Create task on test display. final Task task = new TaskBuilder(mSupervisor).setDisplay(display).build(); final Task task = new TaskBuilder(mSupervisor).setDisplay(display) .setWindowingMode(WINDOWING_MODE_FREEFORM).build(); // App's target min aspect ratio bigger than camera compat aspect ratio - use that instead. final float targetMinAspectRatio = 6.0f; Loading Loading
services/core/java/com/android/server/wm/AppCompatAspectRatioPolicy.java +6 −1 Original line number Diff line number Diff line Loading @@ -295,9 +295,14 @@ class AppCompatAspectRatioPolicy { // {@link ActivityRecord#shouldCreateAppCompatDisplayInsets()} will be false for // both activities that are naturally resizeable and activities that have been // forced resizeable. // Camera compat mode is an exception to this, where the activity is letterboxed // to an aspect ratio commonly found on phones, e.g. 16:9, to avoid issues like // stretching of the camera preview. || (Flags.ignoreAspectRatioRestrictionsForResizeableFreeformActivities() && task.getWindowingMode() == WINDOWING_MODE_FREEFORM && !mActivityRecord.shouldCreateAppCompatDisplayInsets())) { && !mActivityRecord.shouldCreateAppCompatDisplayInsets() && !AppCompatCameraPolicy.shouldCameraCompatControlAspectRatio( mActivityRecord))) { return false; } Loading
services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +16 −8 Original line number Diff line number Diff line Loading @@ -4953,7 +4953,8 @@ public class SizeCompatTests extends WindowTestsBase { } @Test @EnableFlags(Flags.FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING) @EnableFlags({Flags.FLAG_IGNORE_ASPECT_RATIO_RESTRICTIONS_FOR_RESIZEABLE_FREEFORM_ACTIVITIES, Flags.FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING}) public void testCameraCompatAspectRatioAppliedForFixedOrientationCameraActivities() { // Needed to create camera compat policy in DisplayContent. allowDesktopMode(); Loading @@ -4965,7 +4966,8 @@ public class SizeCompatTests extends WindowTestsBase { setupCameraCompatAspectRatio(cameraCompatAspectRatio, display); // Create task on test display. final Task task = new TaskBuilder(mSupervisor).setDisplay(display).build(); final Task task = new TaskBuilder(mSupervisor).setDisplay(display) .setWindowingMode(WINDOWING_MODE_FREEFORM).build(); // Create fixed portrait activity. final ActivityRecord fixedOrientationActivity = new ActivityBuilder(mAtm) Loading @@ -4978,7 +4980,8 @@ public class SizeCompatTests extends WindowTestsBase { } @Test @EnableFlags(Flags.FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING) @EnableFlags({Flags.FLAG_IGNORE_ASPECT_RATIO_RESTRICTIONS_FOR_RESIZEABLE_FREEFORM_ACTIVITIES, Flags.FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING}) public void testCameraCompatAspectRatioForFixedOrientationCameraActivitiesPortraitWindow() { // Needed to create camera compat policy in DisplayContent. allowDesktopMode(); Loading @@ -4990,7 +4993,8 @@ public class SizeCompatTests extends WindowTestsBase { setupCameraCompatAspectRatio(cameraCompatAspectRatio, display); // Create task on test display. final Task task = new TaskBuilder(mSupervisor).setDisplay(display).build(); final Task task = new TaskBuilder(mSupervisor).setDisplay(display) .setWindowingMode(WINDOWING_MODE_FREEFORM).build(); // Create fixed portrait activity. final ActivityRecord fixedOrientationActivity = new ActivityBuilder(mAtm) Loading @@ -5003,7 +5007,8 @@ public class SizeCompatTests extends WindowTestsBase { } @Test @EnableFlags(Flags.FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING) @EnableFlags({Flags.FLAG_IGNORE_ASPECT_RATIO_RESTRICTIONS_FOR_RESIZEABLE_FREEFORM_ACTIVITIES, Flags.FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING}) public void testCameraCompatAspectRatioAppliedInsteadOfDefaultAspectRatio() { // Needed to create camera compat policy in DisplayContent. allowDesktopMode(); Loading @@ -5015,7 +5020,8 @@ public class SizeCompatTests extends WindowTestsBase { setupCameraCompatAspectRatio(cameraCompatAspectRatio, display); // Create task on test display. final Task task = new TaskBuilder(mSupervisor).setDisplay(display).build(); final Task task = new TaskBuilder(mSupervisor).setDisplay(display) .setWindowingMode(WINDOWING_MODE_FREEFORM).build(); // App's target min aspect ratio - this should not be used, as camera controls aspect ratio. final float targetMinAspectRatio = 4.0f; Loading @@ -5032,7 +5038,8 @@ public class SizeCompatTests extends WindowTestsBase { } @Test @EnableFlags(Flags.FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING) @EnableFlags({Flags.FLAG_IGNORE_ASPECT_RATIO_RESTRICTIONS_FOR_RESIZEABLE_FREEFORM_ACTIVITIES, Flags.FLAG_ENABLE_CAMERA_COMPAT_FOR_DESKTOP_WINDOWING}) public void testCameraCompatAspectRatio_defaultAspectRatioAppliedWhenGreater() { // Needed to create camera compat policy in DisplayContent. allowDesktopMode(); Loading @@ -5044,7 +5051,8 @@ public class SizeCompatTests extends WindowTestsBase { setupCameraCompatAspectRatio(cameraCompatAspectRatio, display); // Create task on test display. final Task task = new TaskBuilder(mSupervisor).setDisplay(display).build(); final Task task = new TaskBuilder(mSupervisor).setDisplay(display) .setWindowingMode(WINDOWING_MODE_FREEFORM).build(); // App's target min aspect ratio bigger than camera compat aspect ratio - use that instead. final float targetMinAspectRatio = 6.0f; Loading