Loading core/java/android/app/AppCompatTaskInfo.java +21 −2 Original line number Diff line number Diff line Loading @@ -95,6 +95,8 @@ public class AppCompatTaskInfo implements Parcelable { private static final int FLAG_FULLSCREEN_OVERRIDE_SYSTEM = FLAG_BASE << 7; /** Top activity flag for whether has activity has been overridden to fullscreen by user. */ private static final int FLAG_FULLSCREEN_OVERRIDE_USER = FLAG_BASE << 8; /** Top activity flag for whether min aspect ratio of the activity has been overridden.*/ public static final int FLAG_HAS_MIN_ASPECT_RATIO_OVERRIDE = FLAG_BASE << 9; @Retention(RetentionPolicy.SOURCE) @IntDef(flag = true, value = { Loading @@ -108,7 +110,8 @@ public class AppCompatTaskInfo implements Parcelable { FLAG_IS_FROM_LETTERBOX_DOUBLE_TAP, FLAG_ELIGIBLE_FOR_USER_ASPECT_RATIO_BUTTON, FLAG_FULLSCREEN_OVERRIDE_SYSTEM, FLAG_FULLSCREEN_OVERRIDE_USER FLAG_FULLSCREEN_OVERRIDE_USER, FLAG_HAS_MIN_ASPECT_RATIO_OVERRIDE }) public @interface TopActivityFlag {} Loading @@ -118,7 +121,7 @@ public class AppCompatTaskInfo implements Parcelable { @TopActivityFlag private static final int FLAGS_ORGANIZER_INTERESTED = FLAG_IS_FROM_LETTERBOX_DOUBLE_TAP | FLAG_ELIGIBLE_FOR_USER_ASPECT_RATIO_BUTTON | FLAG_FULLSCREEN_OVERRIDE_SYSTEM | FLAG_FULLSCREEN_OVERRIDE_USER; | FLAG_FULLSCREEN_OVERRIDE_USER | FLAG_HAS_MIN_ASPECT_RATIO_OVERRIDE; @TopActivityFlag private static final int FLAGS_COMPAT_UI_INTERESTED = FLAGS_ORGANIZER_INTERESTED Loading Loading @@ -301,6 +304,21 @@ public class AppCompatTaskInfo implements Parcelable { setTopActivityFlag(FLAG_LETTERBOXED, enable); } /** * @return {@code true} if the top activity's min aspect ratio has been overridden. */ public boolean hasMinAspectRatioOverride() { return isTopActivityFlagEnabled(FLAG_HAS_MIN_ASPECT_RATIO_OVERRIDE); } /** * Sets the top activity flag for whether the min aspect ratio of the activity has been * overridden. */ public void setHasMinAspectRatioOverride(boolean enable) { setTopActivityFlag(FLAG_HAS_MIN_ASPECT_RATIO_OVERRIDE, enable); } /** Clear all top activity flags and set to false. */ public void clearTopActivityFlags() { mTopActivityFlags = FLAG_UNDEFINED; Loading Loading @@ -392,6 +410,7 @@ public class AppCompatTaskInfo implements Parcelable { + " topActivityLetterboxAppHeight=" + topActivityLetterboxAppHeight + " isUserFullscreenOverrideEnabled=" + isUserFullscreenOverrideEnabled() + " isSystemFullscreenOverrideEnabled=" + isSystemFullscreenOverrideEnabled() + " hasMinAspectRatioOverride=" + hasMinAspectRatioOverride() + " cameraCompatTaskInfo=" + cameraCompatTaskInfo.toString() + "}"; } Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt +10 −3 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ fun calculateInitialBounds( val initialSize: Size = when (taskInfo.configuration.orientation) { ORIENTATION_LANDSCAPE -> { if (taskInfo.isResizeable) { if (taskInfo.canChangeAspectRatio) { if (isFixedOrientationPortrait(topActivityInfo.screenOrientation)) { // For portrait resizeable activities, respect apps fullscreen width but // apply ideal size height. Loading @@ -85,7 +85,7 @@ fun calculateInitialBounds( ORIENTATION_PORTRAIT -> { val customPortraitWidthForLandscapeApp = screenBounds.width() - (DESKTOP_MODE_LANDSCAPE_APP_PADDING * 2) if (taskInfo.isResizeable) { if (taskInfo.canChangeAspectRatio) { if (isFixedOrientationLandscape(topActivityInfo.screenOrientation)) { // For landscape resizeable activities, respect apps fullscreen height and // apply custom app width. Loading Loading @@ -188,6 +188,13 @@ private fun positionInScreen(desiredSize: Size, stableBounds: Rect): Rect = offsetTo(offset.x, offset.y) } /** * Whether the activity's aspect ratio can be changed or if it should be maintained as if it was * unresizeable. */ private val TaskInfo.canChangeAspectRatio: Boolean get() = isResizeable && !appCompatTaskInfo.hasMinAspectRatioOverride() /** * Adjusts bounds to be positioned in the middle of the area provided, not necessarily the * entire screen, as area can be offset by left and top start. Loading @@ -204,7 +211,7 @@ fun centerInArea(desiredSize: Size, areaBounds: Rect, leftStart: Int, topStart: return Rect(newLeft, newTop, newRight, newBottom) } fun TaskInfo.hasPortraitTopActivity(): Boolean { private fun TaskInfo.hasPortraitTopActivity(): Boolean { val topActivityScreenOrientation = topActivityInfo?.screenOrientation ?: SCREEN_ORIENTATION_UNSPECIFIED val appBounds = configuration.windowConfiguration.appBounds Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +28 −1 Original line number Diff line number Diff line Loading @@ -865,6 +865,18 @@ class DesktopTasksControllerTest : ShellTestCase() { assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_LANDSCAPE_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun addMoveToDesktopChanges_landscapeDevice_portraitResizableApp_aspectRatioOverridden() { setUpLandscapeDisplay() val task = setUpFullscreenTask(screenOrientation = SCREEN_ORIENTATION_PORTRAIT, shouldLetterbox = true, aspectRatioOverrideApplied = true) val wct = WindowContainerTransaction() controller.addMoveToDesktopChanges(wct, task) assertThat(findBoundsChange(wct, task)).isEqualTo(UNRESIZABLE_PORTRAIT_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun addMoveToDesktopChanges_portraitDevice_userFullscreenOverride_defaultPortraitBounds() { Loading @@ -887,6 +899,19 @@ class DesktopTasksControllerTest : ShellTestCase() { assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_PORTRAIT_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun addMoveToDesktopChanges_portraitDevice_landscapeResizableApp_aspectRatioOverridden() { setUpPortraitDisplay() val task = setUpFullscreenTask(screenOrientation = SCREEN_ORIENTATION_LANDSCAPE, deviceOrientation = ORIENTATION_PORTRAIT, shouldLetterbox = true, aspectRatioOverrideApplied = true) val wct = WindowContainerTransaction() controller.addMoveToDesktopChanges(wct, task) assertThat(findBoundsChange(wct, task)).isEqualTo(UNRESIZABLE_LANDSCAPE_BOUNDS) } @Test fun moveToDesktop_tdaFullscreen_windowingModeSetToFreeform() { val task = setUpFullscreenTask() Loading Loading @@ -2896,7 +2921,8 @@ class DesktopTasksControllerTest : ShellTestCase() { shouldLetterbox: Boolean = false, gravity: Int = Gravity.NO_GRAVITY, enableUserFullscreenOverride: Boolean = false, enableSystemFullscreenOverride: Boolean = false enableSystemFullscreenOverride: Boolean = false, aspectRatioOverrideApplied: Boolean = false ): RunningTaskInfo { val task = createFullscreenTask(displayId) val activityInfo = ActivityInfo() Loading @@ -2911,6 +2937,7 @@ class DesktopTasksControllerTest : ShellTestCase() { appCompatTaskInfo.isSystemFullscreenOverrideEnabled = enableSystemFullscreenOverride if (shouldLetterbox) { appCompatTaskInfo.setHasMinAspectRatioOverride(aspectRatioOverrideApplied) if (deviceOrientation == ORIENTATION_LANDSCAPE && screenOrientation == SCREEN_ORIENTATION_PORTRAIT) { // Letterbox to portrait size Loading services/core/java/com/android/server/wm/AppCompatAspectRatioOverrides.java +2 −2 Original line number Diff line number Diff line Loading @@ -233,7 +233,8 @@ class AppCompatAspectRatioOverrides { return mAppCompatConfiguration.getIsSplitScreenAspectRatioForUnresizableAppsEnabled(); } private float getDisplaySizeMinAspectRatio() { @VisibleForTesting float getDisplaySizeMinAspectRatio() { final DisplayArea displayArea = mActivityRecord.getDisplayArea(); if (displayArea == null) { return mActivityRecord.info.getMinAspectRatio(); Loading Loading @@ -270,7 +271,6 @@ class AppCompatAspectRatioOverrides { return !mAllowUserAspectRatioOverrideOptProp.isFalse(); } @VisibleForTesting int getUserMinAspectRatioOverrideCode() { try { return mActivityRecord.mAtmService.getPackageManager() Loading services/core/java/com/android/server/wm/AppCompatUtils.java +2 −0 Original line number Diff line number Diff line Loading @@ -187,6 +187,8 @@ final class AppCompatUtils { appCompatTaskInfo.setTopActivityLetterboxed(top.areBoundsLetterboxed()); appCompatTaskInfo.cameraCompatTaskInfo.freeformCameraCompatMode = top.mAppCompatController .getAppCompatCameraOverrides().getFreeformCameraCompatMode(); appCompatTaskInfo.setHasMinAspectRatioOverride(top.mAppCompatController .getDesktopAppCompatAspectRatioPolicy().hasMinAspectRatioOverride(task)); } /** Loading Loading
core/java/android/app/AppCompatTaskInfo.java +21 −2 Original line number Diff line number Diff line Loading @@ -95,6 +95,8 @@ public class AppCompatTaskInfo implements Parcelable { private static final int FLAG_FULLSCREEN_OVERRIDE_SYSTEM = FLAG_BASE << 7; /** Top activity flag for whether has activity has been overridden to fullscreen by user. */ private static final int FLAG_FULLSCREEN_OVERRIDE_USER = FLAG_BASE << 8; /** Top activity flag for whether min aspect ratio of the activity has been overridden.*/ public static final int FLAG_HAS_MIN_ASPECT_RATIO_OVERRIDE = FLAG_BASE << 9; @Retention(RetentionPolicy.SOURCE) @IntDef(flag = true, value = { Loading @@ -108,7 +110,8 @@ public class AppCompatTaskInfo implements Parcelable { FLAG_IS_FROM_LETTERBOX_DOUBLE_TAP, FLAG_ELIGIBLE_FOR_USER_ASPECT_RATIO_BUTTON, FLAG_FULLSCREEN_OVERRIDE_SYSTEM, FLAG_FULLSCREEN_OVERRIDE_USER FLAG_FULLSCREEN_OVERRIDE_USER, FLAG_HAS_MIN_ASPECT_RATIO_OVERRIDE }) public @interface TopActivityFlag {} Loading @@ -118,7 +121,7 @@ public class AppCompatTaskInfo implements Parcelable { @TopActivityFlag private static final int FLAGS_ORGANIZER_INTERESTED = FLAG_IS_FROM_LETTERBOX_DOUBLE_TAP | FLAG_ELIGIBLE_FOR_USER_ASPECT_RATIO_BUTTON | FLAG_FULLSCREEN_OVERRIDE_SYSTEM | FLAG_FULLSCREEN_OVERRIDE_USER; | FLAG_FULLSCREEN_OVERRIDE_USER | FLAG_HAS_MIN_ASPECT_RATIO_OVERRIDE; @TopActivityFlag private static final int FLAGS_COMPAT_UI_INTERESTED = FLAGS_ORGANIZER_INTERESTED Loading Loading @@ -301,6 +304,21 @@ public class AppCompatTaskInfo implements Parcelable { setTopActivityFlag(FLAG_LETTERBOXED, enable); } /** * @return {@code true} if the top activity's min aspect ratio has been overridden. */ public boolean hasMinAspectRatioOverride() { return isTopActivityFlagEnabled(FLAG_HAS_MIN_ASPECT_RATIO_OVERRIDE); } /** * Sets the top activity flag for whether the min aspect ratio of the activity has been * overridden. */ public void setHasMinAspectRatioOverride(boolean enable) { setTopActivityFlag(FLAG_HAS_MIN_ASPECT_RATIO_OVERRIDE, enable); } /** Clear all top activity flags and set to false. */ public void clearTopActivityFlags() { mTopActivityFlags = FLAG_UNDEFINED; Loading Loading @@ -392,6 +410,7 @@ public class AppCompatTaskInfo implements Parcelable { + " topActivityLetterboxAppHeight=" + topActivityLetterboxAppHeight + " isUserFullscreenOverrideEnabled=" + isUserFullscreenOverrideEnabled() + " isSystemFullscreenOverrideEnabled=" + isSystemFullscreenOverrideEnabled() + " hasMinAspectRatioOverride=" + hasMinAspectRatioOverride() + " cameraCompatTaskInfo=" + cameraCompatTaskInfo.toString() + "}"; } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt +10 −3 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ fun calculateInitialBounds( val initialSize: Size = when (taskInfo.configuration.orientation) { ORIENTATION_LANDSCAPE -> { if (taskInfo.isResizeable) { if (taskInfo.canChangeAspectRatio) { if (isFixedOrientationPortrait(topActivityInfo.screenOrientation)) { // For portrait resizeable activities, respect apps fullscreen width but // apply ideal size height. Loading @@ -85,7 +85,7 @@ fun calculateInitialBounds( ORIENTATION_PORTRAIT -> { val customPortraitWidthForLandscapeApp = screenBounds.width() - (DESKTOP_MODE_LANDSCAPE_APP_PADDING * 2) if (taskInfo.isResizeable) { if (taskInfo.canChangeAspectRatio) { if (isFixedOrientationLandscape(topActivityInfo.screenOrientation)) { // For landscape resizeable activities, respect apps fullscreen height and // apply custom app width. Loading Loading @@ -188,6 +188,13 @@ private fun positionInScreen(desiredSize: Size, stableBounds: Rect): Rect = offsetTo(offset.x, offset.y) } /** * Whether the activity's aspect ratio can be changed or if it should be maintained as if it was * unresizeable. */ private val TaskInfo.canChangeAspectRatio: Boolean get() = isResizeable && !appCompatTaskInfo.hasMinAspectRatioOverride() /** * Adjusts bounds to be positioned in the middle of the area provided, not necessarily the * entire screen, as area can be offset by left and top start. Loading @@ -204,7 +211,7 @@ fun centerInArea(desiredSize: Size, areaBounds: Rect, leftStart: Int, topStart: return Rect(newLeft, newTop, newRight, newBottom) } fun TaskInfo.hasPortraitTopActivity(): Boolean { private fun TaskInfo.hasPortraitTopActivity(): Boolean { val topActivityScreenOrientation = topActivityInfo?.screenOrientation ?: SCREEN_ORIENTATION_UNSPECIFIED val appBounds = configuration.windowConfiguration.appBounds Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +28 −1 Original line number Diff line number Diff line Loading @@ -865,6 +865,18 @@ class DesktopTasksControllerTest : ShellTestCase() { assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_LANDSCAPE_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun addMoveToDesktopChanges_landscapeDevice_portraitResizableApp_aspectRatioOverridden() { setUpLandscapeDisplay() val task = setUpFullscreenTask(screenOrientation = SCREEN_ORIENTATION_PORTRAIT, shouldLetterbox = true, aspectRatioOverrideApplied = true) val wct = WindowContainerTransaction() controller.addMoveToDesktopChanges(wct, task) assertThat(findBoundsChange(wct, task)).isEqualTo(UNRESIZABLE_PORTRAIT_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun addMoveToDesktopChanges_portraitDevice_userFullscreenOverride_defaultPortraitBounds() { Loading @@ -887,6 +899,19 @@ class DesktopTasksControllerTest : ShellTestCase() { assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_PORTRAIT_BOUNDS) } @Test @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS) fun addMoveToDesktopChanges_portraitDevice_landscapeResizableApp_aspectRatioOverridden() { setUpPortraitDisplay() val task = setUpFullscreenTask(screenOrientation = SCREEN_ORIENTATION_LANDSCAPE, deviceOrientation = ORIENTATION_PORTRAIT, shouldLetterbox = true, aspectRatioOverrideApplied = true) val wct = WindowContainerTransaction() controller.addMoveToDesktopChanges(wct, task) assertThat(findBoundsChange(wct, task)).isEqualTo(UNRESIZABLE_LANDSCAPE_BOUNDS) } @Test fun moveToDesktop_tdaFullscreen_windowingModeSetToFreeform() { val task = setUpFullscreenTask() Loading Loading @@ -2896,7 +2921,8 @@ class DesktopTasksControllerTest : ShellTestCase() { shouldLetterbox: Boolean = false, gravity: Int = Gravity.NO_GRAVITY, enableUserFullscreenOverride: Boolean = false, enableSystemFullscreenOverride: Boolean = false enableSystemFullscreenOverride: Boolean = false, aspectRatioOverrideApplied: Boolean = false ): RunningTaskInfo { val task = createFullscreenTask(displayId) val activityInfo = ActivityInfo() Loading @@ -2911,6 +2937,7 @@ class DesktopTasksControllerTest : ShellTestCase() { appCompatTaskInfo.isSystemFullscreenOverrideEnabled = enableSystemFullscreenOverride if (shouldLetterbox) { appCompatTaskInfo.setHasMinAspectRatioOverride(aspectRatioOverrideApplied) if (deviceOrientation == ORIENTATION_LANDSCAPE && screenOrientation == SCREEN_ORIENTATION_PORTRAIT) { // Letterbox to portrait size Loading
services/core/java/com/android/server/wm/AppCompatAspectRatioOverrides.java +2 −2 Original line number Diff line number Diff line Loading @@ -233,7 +233,8 @@ class AppCompatAspectRatioOverrides { return mAppCompatConfiguration.getIsSplitScreenAspectRatioForUnresizableAppsEnabled(); } private float getDisplaySizeMinAspectRatio() { @VisibleForTesting float getDisplaySizeMinAspectRatio() { final DisplayArea displayArea = mActivityRecord.getDisplayArea(); if (displayArea == null) { return mActivityRecord.info.getMinAspectRatio(); Loading Loading @@ -270,7 +271,6 @@ class AppCompatAspectRatioOverrides { return !mAllowUserAspectRatioOverrideOptProp.isFalse(); } @VisibleForTesting int getUserMinAspectRatioOverrideCode() { try { return mActivityRecord.mAtmService.getPackageManager() Loading
services/core/java/com/android/server/wm/AppCompatUtils.java +2 −0 Original line number Diff line number Diff line Loading @@ -187,6 +187,8 @@ final class AppCompatUtils { appCompatTaskInfo.setTopActivityLetterboxed(top.areBoundsLetterboxed()); appCompatTaskInfo.cameraCompatTaskInfo.freeformCameraCompatMode = top.mAppCompatController .getAppCompatCameraOverrides().getFreeformCameraCompatMode(); appCompatTaskInfo.setHasMinAspectRatioOverride(top.mAppCompatController .getDesktopAppCompatAspectRatioPolicy().hasMinAspectRatioOverride(task)); } /** Loading