Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt +4 −4 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ fun calculateInitialBounds( idealSize } } else { maximumSizeMaintainingAspectRatio(taskInfo, idealSize, appAspectRatio) maximizeSizeGivenAspectRatio(taskInfo, idealSize, appAspectRatio) } } ORIENTATION_PORTRAIT -> { Loading @@ -85,13 +85,13 @@ fun calculateInitialBounds( } else { if (isFixedOrientationLandscape(topActivityInfo.screenOrientation)) { // Apply custom app width and calculate maximum size maximumSizeMaintainingAspectRatio( maximizeSizeGivenAspectRatio( taskInfo, Size(customPortraitWidthForLandscapeApp, idealSize.height), appAspectRatio ) } else { maximumSizeMaintainingAspectRatio(taskInfo, idealSize, appAspectRatio) maximizeSizeGivenAspectRatio(taskInfo, idealSize, appAspectRatio) } } } Loading @@ -107,7 +107,7 @@ fun calculateInitialBounds( * Calculates the largest size that can fit in a given area while maintaining a specific aspect * ratio. */ fun maximumSizeMaintainingAspectRatio( fun maximizeSizeGivenAspectRatio( taskInfo: RunningTaskInfo, targetArea: Size, aspectRatio: Float Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +1 −5 Original line number Diff line number Diff line Loading @@ -671,7 +671,7 @@ class DesktopTasksController( } else { // if non-resizable then calculate max bounds according to aspect ratio val activityAspectRatio = calculateAspectRatio(taskInfo) val newSize = maximumSizeMaintainingAspectRatio(taskInfo, val newSize = maximizeSizeGivenAspectRatio(taskInfo, Size(stableBounds.width(), stableBounds.height()), activityAspectRatio) val newBounds = centerInArea( newSize, stableBounds, stableBounds.left, stableBounds.top) Loading Loading @@ -1079,7 +1079,6 @@ class DesktopTasksController( wct: WindowContainerTransaction, taskInfo: RunningTaskInfo ) { val displayLayout = displayController.getDisplayLayout(taskInfo.displayId) ?: return val tdaInfo = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(taskInfo.displayId)!! val tdaWindowingMode = tdaInfo.configuration.windowConfiguration.windowingMode val targetWindowingMode = Loading @@ -1089,9 +1088,6 @@ class DesktopTasksController( } else { WINDOWING_MODE_FREEFORM } if (Flags.enableWindowingDynamicInitialBounds()) { wct.setBounds(taskInfo.token, calculateInitialBounds(displayLayout, taskInfo)) } wct.setWindowingMode(taskInfo.token, targetWindowingMode) wct.reorder(taskInfo.token, true /* onTop */) if (useDesktopOverrideDensity()) { Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +0 −132 Original line number Diff line number Diff line Loading @@ -579,138 +579,6 @@ class DesktopTasksControllerTest : ShellTestCase() { assertThat(controller.visibleTaskCount(SECOND_DISPLAY)).isEqualTo(1) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun moveToDesktop_landscapeDevice_resizable_undefinedOrientation_defaultLandscapeBounds() { val task = setUpFullscreenTask() setUpLandscapeDisplay() controller.moveToDesktop(task, transitionSource = UNKNOWN) val wct = getLatestEnterDesktopWct() assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_LANDSCAPE_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun moveToDesktop_landscapeDevice_resizable_landscapeOrientation_defaultLandscapeBounds() { val task = setUpFullscreenTask(screenOrientation = SCREEN_ORIENTATION_LANDSCAPE) setUpLandscapeDisplay() controller.moveToDesktop(task, transitionSource = UNKNOWN) val wct = getLatestEnterDesktopWct() assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_LANDSCAPE_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun moveToDesktop_landscapeDevice_resizable_portraitOrientation_resizablePortraitBounds() { val task = setUpFullscreenTask(screenOrientation = SCREEN_ORIENTATION_PORTRAIT, shouldLetterbox = true) setUpLandscapeDisplay() controller.moveToDesktop(task, transitionSource = UNKNOWN) val wct = getLatestEnterDesktopWct() assertThat(findBoundsChange(wct, task)).isEqualTo(RESIZABLE_PORTRAIT_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun moveToDesktop_landscapeDevice_unResizable_landscapeOrientation_defaultLandscapeBounds() { val task = setUpFullscreenTask(isResizable = false, screenOrientation = SCREEN_ORIENTATION_LANDSCAPE) setUpLandscapeDisplay() controller.moveToDesktop(task, transitionSource = UNKNOWN) val wct = getLatestEnterDesktopWct() assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_LANDSCAPE_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun moveToDesktop_landscapeDevice_unResizable_portraitOrientation_unResizablePortraitBounds() { val task = setUpFullscreenTask( isResizable = false, screenOrientation = SCREEN_ORIENTATION_PORTRAIT, shouldLetterbox = true) setUpLandscapeDisplay() controller.moveToDesktop(task, transitionSource = UNKNOWN) val wct = getLatestEnterDesktopWct() assertThat(findBoundsChange(wct, task)).isEqualTo(UNRESIZABLE_PORTRAIT_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun moveToDesktop_portraitDevice_resizable_undefinedOrientation_defaultPortraitBounds() { val task = setUpFullscreenTask(deviceOrientation = ORIENTATION_PORTRAIT) setUpPortraitDisplay() controller.moveToDesktop(task, transitionSource = UNKNOWN) val wct = getLatestEnterDesktopWct() assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_PORTRAIT_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun moveToDesktop_portraitDevice_resizable_portraitOrientation_defaultPortraitBounds() { val task = setUpFullscreenTask( deviceOrientation = ORIENTATION_PORTRAIT, screenOrientation = SCREEN_ORIENTATION_PORTRAIT) setUpPortraitDisplay() controller.moveToDesktop(task, transitionSource = UNKNOWN) val wct = getLatestEnterDesktopWct() assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_PORTRAIT_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun moveToDesktop_portraitDevice_resizable_landscapeOrientation_resizableLandscapeBounds() { val task = setUpFullscreenTask( deviceOrientation = ORIENTATION_PORTRAIT, screenOrientation = SCREEN_ORIENTATION_LANDSCAPE, shouldLetterbox = true) setUpPortraitDisplay() controller.moveToDesktop(task, transitionSource = UNKNOWN) val wct = getLatestEnterDesktopWct() assertThat(findBoundsChange(wct, task)).isEqualTo(RESIZABLE_LANDSCAPE_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun moveToDesktop_portraitDevice_unResizable_portraitOrientation_defaultPortraitBounds() { val task = setUpFullscreenTask( isResizable = false, deviceOrientation = ORIENTATION_PORTRAIT, screenOrientation = SCREEN_ORIENTATION_PORTRAIT) setUpPortraitDisplay() controller.moveToDesktop(task, transitionSource = UNKNOWN) val wct = getLatestEnterDesktopWct() assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_PORTRAIT_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun moveToDesktop_portraitDevice_unResizable_landscapeOrientation_unResizableLandscapeBounds() { val task = setUpFullscreenTask( isResizable = false, deviceOrientation = ORIENTATION_PORTRAIT, screenOrientation = SCREEN_ORIENTATION_LANDSCAPE, shouldLetterbox = true) setUpPortraitDisplay() controller.moveToDesktop(task, transitionSource = UNKNOWN) val wct = getLatestEnterDesktopWct() assertThat(findBoundsChange(wct, task)).isEqualTo(UNRESIZABLE_LANDSCAPE_BOUNDS) } @Test fun moveToDesktop_tdaFullscreen_windowingModeSetToFreeform() { val task = setUpFullscreenTask() Loading services/core/java/com/android/server/wm/AppCompatAspectRatioOverrides.java +9 −1 Original line number Diff line number Diff line Loading @@ -226,6 +226,14 @@ class AppCompatAspectRatioOverrides { : getDefaultMinAspectRatio(); } float getDefaultMinAspectRatioForUnresizableAppsFromConfig() { return mAppCompatConfiguration.getDefaultMinAspectRatioForUnresizableApps(); } boolean isSplitScreenAspectRatioForUnresizableAppsEnabled() { return mAppCompatConfiguration.getIsSplitScreenAspectRatioForUnresizableAppsEnabled(); } private float getDisplaySizeMinAspectRatio() { final DisplayArea displayArea = mActivityRecord.getDisplayArea(); if (displayArea == null) { Loading Loading @@ -278,7 +286,7 @@ class AppCompatAspectRatioOverrides { return getSplitScreenAspectRatio(); } private float getDefaultMinAspectRatio() { float getDefaultMinAspectRatio() { if (mActivityRecord.getDisplayArea() == null || !mAppCompatConfiguration .getIsDisplayAspectRatioEnabledForFixedOrientationLetterbox()) { Loading services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java +279 −21 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt +4 −4 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ fun calculateInitialBounds( idealSize } } else { maximumSizeMaintainingAspectRatio(taskInfo, idealSize, appAspectRatio) maximizeSizeGivenAspectRatio(taskInfo, idealSize, appAspectRatio) } } ORIENTATION_PORTRAIT -> { Loading @@ -85,13 +85,13 @@ fun calculateInitialBounds( } else { if (isFixedOrientationLandscape(topActivityInfo.screenOrientation)) { // Apply custom app width and calculate maximum size maximumSizeMaintainingAspectRatio( maximizeSizeGivenAspectRatio( taskInfo, Size(customPortraitWidthForLandscapeApp, idealSize.height), appAspectRatio ) } else { maximumSizeMaintainingAspectRatio(taskInfo, idealSize, appAspectRatio) maximizeSizeGivenAspectRatio(taskInfo, idealSize, appAspectRatio) } } } Loading @@ -107,7 +107,7 @@ fun calculateInitialBounds( * Calculates the largest size that can fit in a given area while maintaining a specific aspect * ratio. */ fun maximumSizeMaintainingAspectRatio( fun maximizeSizeGivenAspectRatio( taskInfo: RunningTaskInfo, targetArea: Size, aspectRatio: Float Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +1 −5 Original line number Diff line number Diff line Loading @@ -671,7 +671,7 @@ class DesktopTasksController( } else { // if non-resizable then calculate max bounds according to aspect ratio val activityAspectRatio = calculateAspectRatio(taskInfo) val newSize = maximumSizeMaintainingAspectRatio(taskInfo, val newSize = maximizeSizeGivenAspectRatio(taskInfo, Size(stableBounds.width(), stableBounds.height()), activityAspectRatio) val newBounds = centerInArea( newSize, stableBounds, stableBounds.left, stableBounds.top) Loading Loading @@ -1079,7 +1079,6 @@ class DesktopTasksController( wct: WindowContainerTransaction, taskInfo: RunningTaskInfo ) { val displayLayout = displayController.getDisplayLayout(taskInfo.displayId) ?: return val tdaInfo = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(taskInfo.displayId)!! val tdaWindowingMode = tdaInfo.configuration.windowConfiguration.windowingMode val targetWindowingMode = Loading @@ -1089,9 +1088,6 @@ class DesktopTasksController( } else { WINDOWING_MODE_FREEFORM } if (Flags.enableWindowingDynamicInitialBounds()) { wct.setBounds(taskInfo.token, calculateInitialBounds(displayLayout, taskInfo)) } wct.setWindowingMode(taskInfo.token, targetWindowingMode) wct.reorder(taskInfo.token, true /* onTop */) if (useDesktopOverrideDensity()) { Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +0 −132 Original line number Diff line number Diff line Loading @@ -579,138 +579,6 @@ class DesktopTasksControllerTest : ShellTestCase() { assertThat(controller.visibleTaskCount(SECOND_DISPLAY)).isEqualTo(1) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun moveToDesktop_landscapeDevice_resizable_undefinedOrientation_defaultLandscapeBounds() { val task = setUpFullscreenTask() setUpLandscapeDisplay() controller.moveToDesktop(task, transitionSource = UNKNOWN) val wct = getLatestEnterDesktopWct() assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_LANDSCAPE_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun moveToDesktop_landscapeDevice_resizable_landscapeOrientation_defaultLandscapeBounds() { val task = setUpFullscreenTask(screenOrientation = SCREEN_ORIENTATION_LANDSCAPE) setUpLandscapeDisplay() controller.moveToDesktop(task, transitionSource = UNKNOWN) val wct = getLatestEnterDesktopWct() assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_LANDSCAPE_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun moveToDesktop_landscapeDevice_resizable_portraitOrientation_resizablePortraitBounds() { val task = setUpFullscreenTask(screenOrientation = SCREEN_ORIENTATION_PORTRAIT, shouldLetterbox = true) setUpLandscapeDisplay() controller.moveToDesktop(task, transitionSource = UNKNOWN) val wct = getLatestEnterDesktopWct() assertThat(findBoundsChange(wct, task)).isEqualTo(RESIZABLE_PORTRAIT_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun moveToDesktop_landscapeDevice_unResizable_landscapeOrientation_defaultLandscapeBounds() { val task = setUpFullscreenTask(isResizable = false, screenOrientation = SCREEN_ORIENTATION_LANDSCAPE) setUpLandscapeDisplay() controller.moveToDesktop(task, transitionSource = UNKNOWN) val wct = getLatestEnterDesktopWct() assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_LANDSCAPE_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun moveToDesktop_landscapeDevice_unResizable_portraitOrientation_unResizablePortraitBounds() { val task = setUpFullscreenTask( isResizable = false, screenOrientation = SCREEN_ORIENTATION_PORTRAIT, shouldLetterbox = true) setUpLandscapeDisplay() controller.moveToDesktop(task, transitionSource = UNKNOWN) val wct = getLatestEnterDesktopWct() assertThat(findBoundsChange(wct, task)).isEqualTo(UNRESIZABLE_PORTRAIT_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun moveToDesktop_portraitDevice_resizable_undefinedOrientation_defaultPortraitBounds() { val task = setUpFullscreenTask(deviceOrientation = ORIENTATION_PORTRAIT) setUpPortraitDisplay() controller.moveToDesktop(task, transitionSource = UNKNOWN) val wct = getLatestEnterDesktopWct() assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_PORTRAIT_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun moveToDesktop_portraitDevice_resizable_portraitOrientation_defaultPortraitBounds() { val task = setUpFullscreenTask( deviceOrientation = ORIENTATION_PORTRAIT, screenOrientation = SCREEN_ORIENTATION_PORTRAIT) setUpPortraitDisplay() controller.moveToDesktop(task, transitionSource = UNKNOWN) val wct = getLatestEnterDesktopWct() assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_PORTRAIT_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun moveToDesktop_portraitDevice_resizable_landscapeOrientation_resizableLandscapeBounds() { val task = setUpFullscreenTask( deviceOrientation = ORIENTATION_PORTRAIT, screenOrientation = SCREEN_ORIENTATION_LANDSCAPE, shouldLetterbox = true) setUpPortraitDisplay() controller.moveToDesktop(task, transitionSource = UNKNOWN) val wct = getLatestEnterDesktopWct() assertThat(findBoundsChange(wct, task)).isEqualTo(RESIZABLE_LANDSCAPE_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun moveToDesktop_portraitDevice_unResizable_portraitOrientation_defaultPortraitBounds() { val task = setUpFullscreenTask( isResizable = false, deviceOrientation = ORIENTATION_PORTRAIT, screenOrientation = SCREEN_ORIENTATION_PORTRAIT) setUpPortraitDisplay() controller.moveToDesktop(task, transitionSource = UNKNOWN) val wct = getLatestEnterDesktopWct() assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_PORTRAIT_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun moveToDesktop_portraitDevice_unResizable_landscapeOrientation_unResizableLandscapeBounds() { val task = setUpFullscreenTask( isResizable = false, deviceOrientation = ORIENTATION_PORTRAIT, screenOrientation = SCREEN_ORIENTATION_LANDSCAPE, shouldLetterbox = true) setUpPortraitDisplay() controller.moveToDesktop(task, transitionSource = UNKNOWN) val wct = getLatestEnterDesktopWct() assertThat(findBoundsChange(wct, task)).isEqualTo(UNRESIZABLE_LANDSCAPE_BOUNDS) } @Test fun moveToDesktop_tdaFullscreen_windowingModeSetToFreeform() { val task = setUpFullscreenTask() Loading
services/core/java/com/android/server/wm/AppCompatAspectRatioOverrides.java +9 −1 Original line number Diff line number Diff line Loading @@ -226,6 +226,14 @@ class AppCompatAspectRatioOverrides { : getDefaultMinAspectRatio(); } float getDefaultMinAspectRatioForUnresizableAppsFromConfig() { return mAppCompatConfiguration.getDefaultMinAspectRatioForUnresizableApps(); } boolean isSplitScreenAspectRatioForUnresizableAppsEnabled() { return mAppCompatConfiguration.getIsSplitScreenAspectRatioForUnresizableAppsEnabled(); } private float getDisplaySizeMinAspectRatio() { final DisplayArea displayArea = mActivityRecord.getDisplayArea(); if (displayArea == null) { Loading Loading @@ -278,7 +286,7 @@ class AppCompatAspectRatioOverrides { return getSplitScreenAspectRatio(); } private float getDefaultMinAspectRatio() { float getDefaultMinAspectRatio() { if (mActivityRecord.getDisplayArea() == null || !mAppCompatConfiguration .getIsDisplayAspectRatioEnabledForFixedOrientationLetterbox()) { Loading
services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java +279 −21 File changed.Preview size limit exceeded, changes collapsed. Show changes