Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt +24 −3 Original line number Diff line number Diff line Loading @@ -54,6 +54,12 @@ fun calculateInitialBounds( // Instead default to the desired initial bounds. val stableBounds = Rect() displayLayout.getStableBoundsForDesktopMode(stableBounds) if (hasFullscreenOverride(taskInfo)) { // If the activity has a fullscreen override applied, it should be treated as // resizeable and match the device orientation. Thus the ideal size can be // applied. return positionInScreen(idealSize, stableBounds) } val topActivityInfo = taskInfo.topActivityInfo ?: return positionInScreen(idealSize, stableBounds) Loading @@ -62,13 +68,17 @@ fun calculateInitialBounds( ORIENTATION_LANDSCAPE -> { if (taskInfo.isResizeable) { if (isFixedOrientationPortrait(topActivityInfo.screenOrientation)) { // Respect apps fullscreen width // For portrait resizeable activities, respect apps fullscreen width but // apply ideal size height. Size(taskInfo.appCompatTaskInfo.topActivityLetterboxAppWidth, idealSize.height) } else { // For landscape resizeable activities, simply apply ideal size. idealSize } } else { // If activity is unresizeable, regardless of orientation, calculate maximum // size (within the ideal size) maintaining original aspect ratio. maximizeSizeGivenAspectRatio(taskInfo, idealSize, appAspectRatio) } } Loading @@ -77,23 +87,29 @@ fun calculateInitialBounds( screenBounds.width() - (DESKTOP_MODE_LANDSCAPE_APP_PADDING * 2) if (taskInfo.isResizeable) { if (isFixedOrientationLandscape(topActivityInfo.screenOrientation)) { // Respect apps fullscreen height and apply custom app width // For landscape resizeable activities, respect apps fullscreen height and // apply custom app width. Size( customPortraitWidthForLandscapeApp, taskInfo.appCompatTaskInfo.topActivityLetterboxAppHeight ) } else { // For portrait resizeable activities, simply apply ideal size. idealSize } } else { if (isFixedOrientationLandscape(topActivityInfo.screenOrientation)) { // Apply custom app width and calculate maximum size // For landscape unresizeable activities, apply custom app width to ideal // size and calculate maximum size with this area while maintaining original // aspect ratio. maximizeSizeGivenAspectRatio( taskInfo, Size(customPortraitWidthForLandscapeApp, idealSize.height), appAspectRatio ) } else { // For portrait unresizeable activities, calculate maximum size (within the // ideal size) maintaining original aspect ratio. maximizeSizeGivenAspectRatio(taskInfo, idealSize, appAspectRatio) } } Loading Loading @@ -209,3 +225,8 @@ fun TaskInfo.hasPortraitTopActivity(): Boolean { else -> isFixedOrientationPortrait(configuration.orientation) } } private fun hasFullscreenOverride(taskInfo: RunningTaskInfo): Boolean { return taskInfo.appCompatTaskInfo.isUserFullscreenOverrideEnabled || taskInfo.appCompatTaskInfo.isSystemFullscreenOverrideEnabled } libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +55 −7 Original line number Diff line number Diff line Loading @@ -750,6 +750,50 @@ class DesktopTasksControllerTest : ShellTestCase() { .isEqualTo(DesktopTaskPosition.Center) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun addMoveToDesktopChanges_landscapeDevice_userFullscreenOverride_defaultPortraitBounds() { setUpLandscapeDisplay() val task = setUpFullscreenTask(enableUserFullscreenOverride = true) val wct = WindowContainerTransaction() controller.addMoveToDesktopChanges(wct, task) assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_LANDSCAPE_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun addMoveToDesktopChanges_landscapeDevice_systemFullscreenOverride_defaultPortraitBounds() { setUpLandscapeDisplay() val task = setUpFullscreenTask(enableSystemFullscreenOverride = true) val wct = WindowContainerTransaction() controller.addMoveToDesktopChanges(wct, task) assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_LANDSCAPE_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun addMoveToDesktopChanges_portraitDevice_userFullscreenOverride_defaultPortraitBounds() { setUpPortraitDisplay() val task = setUpFullscreenTask(enableUserFullscreenOverride = true) val wct = WindowContainerTransaction() controller.addMoveToDesktopChanges(wct, task) assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_PORTRAIT_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun addMoveToDesktopChanges_portraitDevice_systemFullscreenOverride_defaultPortraitBounds() { setUpPortraitDisplay() val task = setUpFullscreenTask(enableSystemFullscreenOverride = true) val wct = WindowContainerTransaction() controller.addMoveToDesktopChanges(wct, task) assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_PORTRAIT_BOUNDS) } @Test fun moveToDesktop_tdaFullscreen_windowingModeSetToFreeform() { val task = setUpFullscreenTask() Loading Loading @@ -2718,7 +2762,9 @@ class DesktopTasksControllerTest : ShellTestCase() { deviceOrientation: Int = ORIENTATION_LANDSCAPE, screenOrientation: Int = SCREEN_ORIENTATION_UNSPECIFIED, shouldLetterbox: Boolean = false, gravity: Int = Gravity.NO_GRAVITY gravity: Int = Gravity.NO_GRAVITY, enableUserFullscreenOverride: Boolean = false, enableSystemFullscreenOverride: Boolean = false ): RunningTaskInfo { val task = createFullscreenTask(displayId) val activityInfo = ActivityInfo() Loading @@ -2729,6 +2775,8 @@ class DesktopTasksControllerTest : ShellTestCase() { isResizeable = isResizable configuration.orientation = deviceOrientation configuration.windowConfiguration.windowingMode = windowingMode appCompatTaskInfo.isUserFullscreenOverrideEnabled = enableUserFullscreenOverride appCompatTaskInfo.isSystemFullscreenOverrideEnabled = enableSystemFullscreenOverride if (shouldLetterbox) { if (deviceOrientation == ORIENTATION_LANDSCAPE && Loading services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java +7 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,13 @@ public final class DesktopModeBoundsCalculator { if (!DesktopModeFlagsUtil.DYNAMIC_INITIAL_BOUNDS.isEnabled(activity.mWmService.mContext)) { return centerInScreen(idealSize, screenBounds); } if (activity.mAppCompatController.getAppCompatAspectRatioOverrides() .hasFullscreenOverride()) { // If the activity has a fullscreen override applied, it should be treated as // resizeable and match the device orientation. Thus the ideal size can be // applied. return centerInScreen(idealSize, screenBounds); } // TODO(b/353457301): Replace with app compat aspect ratio method when refactoring complete. float appAspectRatio = calculateAspectRatio(task, activity); final float tdaWidth = stableBounds.width(); Loading services/tests/wmtests/src/com/android/server/wm/DesktopModeLaunchParamsModifierTests.java +101 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import static android.content.res.Configuration.ORIENTATION_PORTRAIT; import static android.util.DisplayMetrics.DENSITY_DEFAULT; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; import static com.android.server.wm.DesktopModeBoundsCalculator.DESKTOP_MODE_INITIAL_BOUNDS_SCALE; import static com.android.server.wm.DesktopModeBoundsCalculator.DESKTOP_MODE_LANDSCAPE_APP_PADDING; import static com.android.server.wm.DesktopModeBoundsCalculator.calculateAspectRatio; Loading Loading @@ -230,6 +231,56 @@ public class DesktopModeLaunchParamsModifierTests extends assertEquals(desiredHeight, mResult.mBounds.height()); } @Test @EnableFlags({Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE, Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS}) public void testDefaultLandscapeBounds_landscapeDevice_userFullscreenOverride() { setupDesktopModeLaunchParamsModifier(); final TestDisplayContent display = createDisplayContent(ORIENTATION_LANDSCAPE, LANDSCAPE_DISPLAY_BOUNDS); final Task task = createTask(display, SCREEN_ORIENTATION_LANDSCAPE, true); spyOn(mActivity.mAppCompatController.getAppCompatAspectRatioOverrides()); doReturn(true).when( mActivity.mAppCompatController.getAppCompatAspectRatioOverrides()) .isUserFullscreenOverrideEnabled(); final int desiredWidth = (int) (LANDSCAPE_DISPLAY_BOUNDS.width() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE); final int desiredHeight = (int) (LANDSCAPE_DISPLAY_BOUNDS.height() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE); assertEquals(RESULT_CONTINUE, new CalculateRequestBuilder().setTask(task).calculate()); assertEquals(desiredWidth, mResult.mBounds.width()); assertEquals(desiredHeight, mResult.mBounds.height()); } @Test @EnableFlags({Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE, Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS}) public void testDefaultLandscapeBounds_landscapeDevice_systemFullscreenOverride() { setupDesktopModeLaunchParamsModifier(); final TestDisplayContent display = createDisplayContent(ORIENTATION_LANDSCAPE, LANDSCAPE_DISPLAY_BOUNDS); final Task task = createTask(display, SCREEN_ORIENTATION_LANDSCAPE, true); spyOn(mActivity.mAppCompatController.getAppCompatAspectRatioOverrides()); doReturn(true).when( mActivity.mAppCompatController.getAppCompatAspectRatioOverrides()) .isSystemOverrideToFullscreenEnabled(); final int desiredWidth = (int) (LANDSCAPE_DISPLAY_BOUNDS.width() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE); final int desiredHeight = (int) (LANDSCAPE_DISPLAY_BOUNDS.height() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE); assertEquals(RESULT_CONTINUE, new CalculateRequestBuilder().setTask(task).calculate()); assertEquals(desiredWidth, mResult.mBounds.width()); assertEquals(desiredHeight, mResult.mBounds.height()); } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) public void testResizablePortraitBounds_landscapeDevice_resizable_portraitOrientation() { Loading Loading @@ -331,6 +382,56 @@ public class DesktopModeLaunchParamsModifierTests extends assertEquals(desiredHeight, mResult.mBounds.height()); } @Test @EnableFlags({Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE, Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS}) public void testDefaultPortraitBounds_portraitDevice_userFullscreenOverride() { setupDesktopModeLaunchParamsModifier(); final TestDisplayContent display = createDisplayContent(ORIENTATION_PORTRAIT, PORTRAIT_DISPLAY_BOUNDS); final Task task = createTask(display, SCREEN_ORIENTATION_PORTRAIT, true); spyOn(mActivity.mAppCompatController.getAppCompatAspectRatioOverrides()); doReturn(true).when( mActivity.mAppCompatController.getAppCompatAspectRatioOverrides()) .isUserFullscreenOverrideEnabled(); final int desiredWidth = (int) (PORTRAIT_DISPLAY_BOUNDS.width() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE); final int desiredHeight = (int) (PORTRAIT_DISPLAY_BOUNDS.height() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE); assertEquals(RESULT_CONTINUE, new CalculateRequestBuilder().setTask(task).calculate()); assertEquals(desiredWidth, mResult.mBounds.width()); assertEquals(desiredHeight, mResult.mBounds.height()); } @Test @EnableFlags({Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE, Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS}) public void testDefaultPortraitBounds_portraitDevice_systemFullscreenOverride() { setupDesktopModeLaunchParamsModifier(); final TestDisplayContent display = createDisplayContent(ORIENTATION_PORTRAIT, PORTRAIT_DISPLAY_BOUNDS); final Task task = createTask(display, SCREEN_ORIENTATION_PORTRAIT, true); spyOn(mActivity.mAppCompatController.getAppCompatAspectRatioOverrides()); doReturn(true).when( mActivity.mAppCompatController.getAppCompatAspectRatioOverrides()) .isSystemOverrideToFullscreenEnabled(); final int desiredWidth = (int) (PORTRAIT_DISPLAY_BOUNDS.width() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE); final int desiredHeight = (int) (PORTRAIT_DISPLAY_BOUNDS.height() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE); assertEquals(RESULT_CONTINUE, new CalculateRequestBuilder().setTask(task).calculate()); assertEquals(desiredWidth, mResult.mBounds.width()); assertEquals(desiredHeight, mResult.mBounds.height()); } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) public void testResizableLandscapeBounds_portraitDevice_resizable_landscapeOrientation() { Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt +24 −3 Original line number Diff line number Diff line Loading @@ -54,6 +54,12 @@ fun calculateInitialBounds( // Instead default to the desired initial bounds. val stableBounds = Rect() displayLayout.getStableBoundsForDesktopMode(stableBounds) if (hasFullscreenOverride(taskInfo)) { // If the activity has a fullscreen override applied, it should be treated as // resizeable and match the device orientation. Thus the ideal size can be // applied. return positionInScreen(idealSize, stableBounds) } val topActivityInfo = taskInfo.topActivityInfo ?: return positionInScreen(idealSize, stableBounds) Loading @@ -62,13 +68,17 @@ fun calculateInitialBounds( ORIENTATION_LANDSCAPE -> { if (taskInfo.isResizeable) { if (isFixedOrientationPortrait(topActivityInfo.screenOrientation)) { // Respect apps fullscreen width // For portrait resizeable activities, respect apps fullscreen width but // apply ideal size height. Size(taskInfo.appCompatTaskInfo.topActivityLetterboxAppWidth, idealSize.height) } else { // For landscape resizeable activities, simply apply ideal size. idealSize } } else { // If activity is unresizeable, regardless of orientation, calculate maximum // size (within the ideal size) maintaining original aspect ratio. maximizeSizeGivenAspectRatio(taskInfo, idealSize, appAspectRatio) } } Loading @@ -77,23 +87,29 @@ fun calculateInitialBounds( screenBounds.width() - (DESKTOP_MODE_LANDSCAPE_APP_PADDING * 2) if (taskInfo.isResizeable) { if (isFixedOrientationLandscape(topActivityInfo.screenOrientation)) { // Respect apps fullscreen height and apply custom app width // For landscape resizeable activities, respect apps fullscreen height and // apply custom app width. Size( customPortraitWidthForLandscapeApp, taskInfo.appCompatTaskInfo.topActivityLetterboxAppHeight ) } else { // For portrait resizeable activities, simply apply ideal size. idealSize } } else { if (isFixedOrientationLandscape(topActivityInfo.screenOrientation)) { // Apply custom app width and calculate maximum size // For landscape unresizeable activities, apply custom app width to ideal // size and calculate maximum size with this area while maintaining original // aspect ratio. maximizeSizeGivenAspectRatio( taskInfo, Size(customPortraitWidthForLandscapeApp, idealSize.height), appAspectRatio ) } else { // For portrait unresizeable activities, calculate maximum size (within the // ideal size) maintaining original aspect ratio. maximizeSizeGivenAspectRatio(taskInfo, idealSize, appAspectRatio) } } Loading Loading @@ -209,3 +225,8 @@ fun TaskInfo.hasPortraitTopActivity(): Boolean { else -> isFixedOrientationPortrait(configuration.orientation) } } private fun hasFullscreenOverride(taskInfo: RunningTaskInfo): Boolean { return taskInfo.appCompatTaskInfo.isUserFullscreenOverrideEnabled || taskInfo.appCompatTaskInfo.isSystemFullscreenOverrideEnabled }
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +55 −7 Original line number Diff line number Diff line Loading @@ -750,6 +750,50 @@ class DesktopTasksControllerTest : ShellTestCase() { .isEqualTo(DesktopTaskPosition.Center) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun addMoveToDesktopChanges_landscapeDevice_userFullscreenOverride_defaultPortraitBounds() { setUpLandscapeDisplay() val task = setUpFullscreenTask(enableUserFullscreenOverride = true) val wct = WindowContainerTransaction() controller.addMoveToDesktopChanges(wct, task) assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_LANDSCAPE_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun addMoveToDesktopChanges_landscapeDevice_systemFullscreenOverride_defaultPortraitBounds() { setUpLandscapeDisplay() val task = setUpFullscreenTask(enableSystemFullscreenOverride = true) val wct = WindowContainerTransaction() controller.addMoveToDesktopChanges(wct, task) assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_LANDSCAPE_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun addMoveToDesktopChanges_portraitDevice_userFullscreenOverride_defaultPortraitBounds() { setUpPortraitDisplay() val task = setUpFullscreenTask(enableUserFullscreenOverride = true) val wct = WindowContainerTransaction() controller.addMoveToDesktopChanges(wct, task) assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_PORTRAIT_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun addMoveToDesktopChanges_portraitDevice_systemFullscreenOverride_defaultPortraitBounds() { setUpPortraitDisplay() val task = setUpFullscreenTask(enableSystemFullscreenOverride = true) val wct = WindowContainerTransaction() controller.addMoveToDesktopChanges(wct, task) assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_PORTRAIT_BOUNDS) } @Test fun moveToDesktop_tdaFullscreen_windowingModeSetToFreeform() { val task = setUpFullscreenTask() Loading Loading @@ -2718,7 +2762,9 @@ class DesktopTasksControllerTest : ShellTestCase() { deviceOrientation: Int = ORIENTATION_LANDSCAPE, screenOrientation: Int = SCREEN_ORIENTATION_UNSPECIFIED, shouldLetterbox: Boolean = false, gravity: Int = Gravity.NO_GRAVITY gravity: Int = Gravity.NO_GRAVITY, enableUserFullscreenOverride: Boolean = false, enableSystemFullscreenOverride: Boolean = false ): RunningTaskInfo { val task = createFullscreenTask(displayId) val activityInfo = ActivityInfo() Loading @@ -2729,6 +2775,8 @@ class DesktopTasksControllerTest : ShellTestCase() { isResizeable = isResizable configuration.orientation = deviceOrientation configuration.windowConfiguration.windowingMode = windowingMode appCompatTaskInfo.isUserFullscreenOverrideEnabled = enableUserFullscreenOverride appCompatTaskInfo.isSystemFullscreenOverrideEnabled = enableSystemFullscreenOverride if (shouldLetterbox) { if (deviceOrientation == ORIENTATION_LANDSCAPE && Loading
services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java +7 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,13 @@ public final class DesktopModeBoundsCalculator { if (!DesktopModeFlagsUtil.DYNAMIC_INITIAL_BOUNDS.isEnabled(activity.mWmService.mContext)) { return centerInScreen(idealSize, screenBounds); } if (activity.mAppCompatController.getAppCompatAspectRatioOverrides() .hasFullscreenOverride()) { // If the activity has a fullscreen override applied, it should be treated as // resizeable and match the device orientation. Thus the ideal size can be // applied. return centerInScreen(idealSize, screenBounds); } // TODO(b/353457301): Replace with app compat aspect ratio method when refactoring complete. float appAspectRatio = calculateAspectRatio(task, activity); final float tdaWidth = stableBounds.width(); Loading
services/tests/wmtests/src/com/android/server/wm/DesktopModeLaunchParamsModifierTests.java +101 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import static android.content.res.Configuration.ORIENTATION_PORTRAIT; import static android.util.DisplayMetrics.DENSITY_DEFAULT; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; import static com.android.server.wm.DesktopModeBoundsCalculator.DESKTOP_MODE_INITIAL_BOUNDS_SCALE; import static com.android.server.wm.DesktopModeBoundsCalculator.DESKTOP_MODE_LANDSCAPE_APP_PADDING; import static com.android.server.wm.DesktopModeBoundsCalculator.calculateAspectRatio; Loading Loading @@ -230,6 +231,56 @@ public class DesktopModeLaunchParamsModifierTests extends assertEquals(desiredHeight, mResult.mBounds.height()); } @Test @EnableFlags({Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE, Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS}) public void testDefaultLandscapeBounds_landscapeDevice_userFullscreenOverride() { setupDesktopModeLaunchParamsModifier(); final TestDisplayContent display = createDisplayContent(ORIENTATION_LANDSCAPE, LANDSCAPE_DISPLAY_BOUNDS); final Task task = createTask(display, SCREEN_ORIENTATION_LANDSCAPE, true); spyOn(mActivity.mAppCompatController.getAppCompatAspectRatioOverrides()); doReturn(true).when( mActivity.mAppCompatController.getAppCompatAspectRatioOverrides()) .isUserFullscreenOverrideEnabled(); final int desiredWidth = (int) (LANDSCAPE_DISPLAY_BOUNDS.width() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE); final int desiredHeight = (int) (LANDSCAPE_DISPLAY_BOUNDS.height() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE); assertEquals(RESULT_CONTINUE, new CalculateRequestBuilder().setTask(task).calculate()); assertEquals(desiredWidth, mResult.mBounds.width()); assertEquals(desiredHeight, mResult.mBounds.height()); } @Test @EnableFlags({Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE, Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS}) public void testDefaultLandscapeBounds_landscapeDevice_systemFullscreenOverride() { setupDesktopModeLaunchParamsModifier(); final TestDisplayContent display = createDisplayContent(ORIENTATION_LANDSCAPE, LANDSCAPE_DISPLAY_BOUNDS); final Task task = createTask(display, SCREEN_ORIENTATION_LANDSCAPE, true); spyOn(mActivity.mAppCompatController.getAppCompatAspectRatioOverrides()); doReturn(true).when( mActivity.mAppCompatController.getAppCompatAspectRatioOverrides()) .isSystemOverrideToFullscreenEnabled(); final int desiredWidth = (int) (LANDSCAPE_DISPLAY_BOUNDS.width() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE); final int desiredHeight = (int) (LANDSCAPE_DISPLAY_BOUNDS.height() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE); assertEquals(RESULT_CONTINUE, new CalculateRequestBuilder().setTask(task).calculate()); assertEquals(desiredWidth, mResult.mBounds.width()); assertEquals(desiredHeight, mResult.mBounds.height()); } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) public void testResizablePortraitBounds_landscapeDevice_resizable_portraitOrientation() { Loading Loading @@ -331,6 +382,56 @@ public class DesktopModeLaunchParamsModifierTests extends assertEquals(desiredHeight, mResult.mBounds.height()); } @Test @EnableFlags({Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE, Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS}) public void testDefaultPortraitBounds_portraitDevice_userFullscreenOverride() { setupDesktopModeLaunchParamsModifier(); final TestDisplayContent display = createDisplayContent(ORIENTATION_PORTRAIT, PORTRAIT_DISPLAY_BOUNDS); final Task task = createTask(display, SCREEN_ORIENTATION_PORTRAIT, true); spyOn(mActivity.mAppCompatController.getAppCompatAspectRatioOverrides()); doReturn(true).when( mActivity.mAppCompatController.getAppCompatAspectRatioOverrides()) .isUserFullscreenOverrideEnabled(); final int desiredWidth = (int) (PORTRAIT_DISPLAY_BOUNDS.width() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE); final int desiredHeight = (int) (PORTRAIT_DISPLAY_BOUNDS.height() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE); assertEquals(RESULT_CONTINUE, new CalculateRequestBuilder().setTask(task).calculate()); assertEquals(desiredWidth, mResult.mBounds.width()); assertEquals(desiredHeight, mResult.mBounds.height()); } @Test @EnableFlags({Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE, Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS}) public void testDefaultPortraitBounds_portraitDevice_systemFullscreenOverride() { setupDesktopModeLaunchParamsModifier(); final TestDisplayContent display = createDisplayContent(ORIENTATION_PORTRAIT, PORTRAIT_DISPLAY_BOUNDS); final Task task = createTask(display, SCREEN_ORIENTATION_PORTRAIT, true); spyOn(mActivity.mAppCompatController.getAppCompatAspectRatioOverrides()); doReturn(true).when( mActivity.mAppCompatController.getAppCompatAspectRatioOverrides()) .isSystemOverrideToFullscreenEnabled(); final int desiredWidth = (int) (PORTRAIT_DISPLAY_BOUNDS.width() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE); final int desiredHeight = (int) (PORTRAIT_DISPLAY_BOUNDS.height() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE); assertEquals(RESULT_CONTINUE, new CalculateRequestBuilder().setTask(task).calculate()); assertEquals(desiredWidth, mResult.mBounds.width()); assertEquals(desiredHeight, mResult.mBounds.height()); } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) public void testResizableLandscapeBounds_portraitDevice_resizable_landscapeOrientation() { Loading