Loading core/java/android/app/AppCompatTaskInfo.java +10 −19 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.os.Parcelable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.Objects; /** * Stores App Compat information about a particular Task. Loading Loading @@ -58,16 +59,11 @@ public class AppCompatTaskInfo implements Parcelable { public int topActivityLetterboxHeight = PROPERTY_VALUE_UNSET; /** * Contains the current app height of the letterboxed activity if available or * {@link TaskInfo#PROPERTY_VALUE_UNSET} otherwise. * Contains the app bounds of the top activity or size compat mode * bounds when in size compat mode. If null, contains bounds. */ public int topActivityLetterboxAppHeight = PROPERTY_VALUE_UNSET; /** * Contains the current app width of the letterboxed activity if available or * {@link TaskInfo#PROPERTY_VALUE_UNSET} otherwise. */ public int topActivityLetterboxAppWidth = PROPERTY_VALUE_UNSET; @NonNull public final Rect topActivityAppBounds = new Rect(); /** * Contains the top activity bounds when the activity is letterboxed. Loading Loading @@ -350,8 +346,7 @@ public class AppCompatTaskInfo implements Parcelable { && topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition && topActivityLetterboxWidth == that.topActivityLetterboxWidth && topActivityLetterboxHeight == that.topActivityLetterboxHeight && topActivityLetterboxAppWidth == that.topActivityLetterboxAppWidth && topActivityLetterboxAppHeight == that.topActivityLetterboxAppHeight && topActivityAppBounds.equals(that.topActivityAppBounds) && topActivityLetterboxHorizontalPosition == that.topActivityLetterboxHorizontalPosition && cameraCompatTaskInfo.equalsForTaskOrganizer(that.cameraCompatTaskInfo); Loading @@ -371,8 +366,7 @@ public class AppCompatTaskInfo implements Parcelable { == that.topActivityLetterboxHorizontalPosition && topActivityLetterboxWidth == that.topActivityLetterboxWidth && topActivityLetterboxHeight == that.topActivityLetterboxHeight && topActivityLetterboxAppWidth == that.topActivityLetterboxAppWidth && topActivityLetterboxAppHeight == that.topActivityLetterboxAppHeight && topActivityAppBounds.equals(that.topActivityAppBounds) && cameraCompatTaskInfo.equalsForCompatUi(that.cameraCompatTaskInfo); } Loading @@ -385,8 +379,7 @@ public class AppCompatTaskInfo implements Parcelable { topActivityLetterboxHorizontalPosition = source.readInt(); topActivityLetterboxWidth = source.readInt(); topActivityLetterboxHeight = source.readInt(); topActivityLetterboxAppWidth = source.readInt(); topActivityLetterboxAppHeight = source.readInt(); topActivityAppBounds.set(Objects.requireNonNull(source.readTypedObject(Rect.CREATOR))); topActivityLetterboxBounds = source.readTypedObject(Rect.CREATOR); cameraCompatTaskInfo = source.readTypedObject(CameraCompatTaskInfo.CREATOR); } Loading @@ -401,8 +394,7 @@ public class AppCompatTaskInfo implements Parcelable { dest.writeInt(topActivityLetterboxHorizontalPosition); dest.writeInt(topActivityLetterboxWidth); dest.writeInt(topActivityLetterboxHeight); dest.writeInt(topActivityLetterboxAppWidth); dest.writeInt(topActivityLetterboxAppHeight); dest.writeTypedObject(topActivityAppBounds, flags); dest.writeTypedObject(topActivityLetterboxBounds, flags); dest.writeTypedObject(cameraCompatTaskInfo, flags); } Loading @@ -421,8 +413,7 @@ public class AppCompatTaskInfo implements Parcelable { + topActivityLetterboxHorizontalPosition + " topActivityLetterboxWidth=" + topActivityLetterboxWidth + " topActivityLetterboxHeight=" + topActivityLetterboxHeight + " topActivityLetterboxAppWidth=" + topActivityLetterboxAppWidth + " topActivityLetterboxAppHeight=" + topActivityLetterboxAppHeight + " topActivityAppBounds=" + topActivityAppBounds + " isUserFullscreenOverrideEnabled=" + isUserFullscreenOverrideEnabled() + " isSystemFullscreenOverrideEnabled=" + isSystemFullscreenOverrideEnabled() + " hasMinAspectRatioOverride=" + hasMinAspectRatioOverride() Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt +4 −9 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ fun calculateInitialBounds( // For portrait resizeable activities, respect apps fullscreen width but // apply ideal size height. Size( taskInfo.appCompatTaskInfo.topActivityLetterboxAppWidth, taskInfo.appCompatTaskInfo.topActivityAppBounds.width(), idealSize.height, ) } else { Loading @@ -104,7 +104,7 @@ fun calculateInitialBounds( // apply custom app width. Size( customPortraitWidthForLandscapeApp, taskInfo.appCompatTaskInfo.topActivityLetterboxAppHeight, taskInfo.appCompatTaskInfo.topActivityAppBounds.height(), ) } else { // For portrait resizeable activities, simply apply ideal size. Loading Loading @@ -196,13 +196,8 @@ fun maximizeSizeGivenAspectRatio( /** Calculates the aspect ratio of an activity from its fullscreen bounds. */ fun calculateAspectRatio(taskInfo: RunningTaskInfo): Float { val appLetterboxWidth = taskInfo.appCompatTaskInfo.topActivityLetterboxAppWidth val appLetterboxHeight = taskInfo.appCompatTaskInfo.topActivityLetterboxAppHeight if (taskInfo.appCompatTaskInfo.isTopActivityLetterboxed || !taskInfo.canChangeAspectRatio) { return maxOf(appLetterboxWidth, appLetterboxHeight) / minOf(appLetterboxWidth, appLetterboxHeight).toFloat() } val appBounds = taskInfo.configuration.windowConfiguration.appBounds ?: return 1f if (taskInfo.appCompatTaskInfo.topActivityAppBounds.isEmpty) return 1f val appBounds = taskInfo.appCompatTaskInfo.topActivityAppBounds return maxOf(appBounds.height(), appBounds.width()) / minOf(appBounds.height(), appBounds.width()).toFloat() } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +17 −16 Original line number Diff line number Diff line Loading @@ -4160,8 +4160,7 @@ class DesktopTasksControllerTest : ShellTestCase() { screenOrientation = SCREEN_ORIENTATION_LANDSCAPE configuration.windowConfiguration.appBounds = bounds } appCompatTaskInfo.topActivityLetterboxAppWidth = bounds.width() appCompatTaskInfo.topActivityLetterboxAppHeight = bounds.height() appCompatTaskInfo.topActivityAppBounds.set(0, 0, bounds.width(), bounds.height()) isResizeable = false } Loading Loading @@ -4879,15 +4878,19 @@ class DesktopTasksControllerTest : ShellTestCase() { appCompatTaskInfo.isSystemFullscreenOverrideEnabled = enableSystemFullscreenOverride if (deviceOrientation == ORIENTATION_LANDSCAPE) { configuration.windowConfiguration.appBounds = Rect(0, 0, DISPLAY_DIMENSION_LONG, DISPLAY_DIMENSION_SHORT) appCompatTaskInfo.topActivityLetterboxAppWidth = DISPLAY_DIMENSION_LONG appCompatTaskInfo.topActivityLetterboxAppHeight = DISPLAY_DIMENSION_SHORT appCompatTaskInfo.topActivityAppBounds.set( 0, 0, DISPLAY_DIMENSION_LONG, DISPLAY_DIMENSION_SHORT, ) } else { configuration.windowConfiguration.appBounds = Rect(0, 0, DISPLAY_DIMENSION_SHORT, DISPLAY_DIMENSION_LONG) appCompatTaskInfo.topActivityLetterboxAppWidth = DISPLAY_DIMENSION_SHORT appCompatTaskInfo.topActivityLetterboxAppHeight = DISPLAY_DIMENSION_LONG appCompatTaskInfo.topActivityAppBounds.set( 0, 0, DISPLAY_DIMENSION_SHORT, DISPLAY_DIMENSION_LONG, ) } if (shouldLetterbox) { Loading @@ -4897,17 +4900,15 @@ class DesktopTasksControllerTest : ShellTestCase() { screenOrientation == SCREEN_ORIENTATION_PORTRAIT ) { // Letterbox to portrait size appCompatTaskInfo.setTopActivityLetterboxed(true) appCompatTaskInfo.topActivityLetterboxAppWidth = 1200 appCompatTaskInfo.topActivityLetterboxAppHeight = 1600 appCompatTaskInfo.isTopActivityLetterboxed = true appCompatTaskInfo.topActivityAppBounds.set(0, 0, 1200, 1600) } else if ( deviceOrientation == ORIENTATION_PORTRAIT && screenOrientation == SCREEN_ORIENTATION_LANDSCAPE ) { // Letterbox to landscape size appCompatTaskInfo.setTopActivityLetterboxed(true) appCompatTaskInfo.topActivityLetterboxAppWidth = 1600 appCompatTaskInfo.topActivityLetterboxAppHeight = 1200 appCompatTaskInfo.isTopActivityLetterboxed = true appCompatTaskInfo.topActivityAppBounds.set(0, 0, 1600, 1200) } } } Loading services/core/java/com/android/server/wm/AppCompatUtils.java +2 −5 Original line number Diff line number Diff line Loading @@ -164,15 +164,13 @@ final class AppCompatUtils { appCompatTaskInfo.setIsFromLetterboxDoubleTap(reachabilityOverrides.isFromDoubleTap()); appCompatTaskInfo.topActivityAppBounds.set(getAppBounds(top)); final boolean isTopActivityLetterboxed = top.areBoundsLetterboxed(); appCompatTaskInfo.setTopActivityLetterboxed(isTopActivityLetterboxed); if (isTopActivityLetterboxed) { final Rect bounds = top.getBounds(); final Rect appBounds = getAppBounds(top); appCompatTaskInfo.topActivityLetterboxWidth = bounds.width(); appCompatTaskInfo.topActivityLetterboxHeight = bounds.height(); appCompatTaskInfo.topActivityLetterboxAppWidth = appBounds.width(); appCompatTaskInfo.topActivityLetterboxAppHeight = appBounds.height(); // TODO(b/379824541) Remove duplicate information. appCompatTaskInfo.topActivityLetterboxBounds = bounds; // We need to consider if letterboxed or pillarboxed. Loading Loading @@ -281,8 +279,7 @@ final class AppCompatUtils { info.topActivityLetterboxHorizontalPosition = TaskInfo.PROPERTY_VALUE_UNSET; info.topActivityLetterboxWidth = TaskInfo.PROPERTY_VALUE_UNSET; info.topActivityLetterboxHeight = TaskInfo.PROPERTY_VALUE_UNSET; info.topActivityLetterboxAppHeight = TaskInfo.PROPERTY_VALUE_UNSET; info.topActivityLetterboxAppWidth = TaskInfo.PROPERTY_VALUE_UNSET; info.topActivityAppBounds.setEmpty(); info.topActivityLetterboxBounds = null; info.cameraCompatTaskInfo.freeformCameraCompatMode = CameraCompatTaskInfo.CAMERA_COMPAT_FREEFORM_UNSPECIFIED; Loading Loading
core/java/android/app/AppCompatTaskInfo.java +10 −19 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.os.Parcelable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.Objects; /** * Stores App Compat information about a particular Task. Loading Loading @@ -58,16 +59,11 @@ public class AppCompatTaskInfo implements Parcelable { public int topActivityLetterboxHeight = PROPERTY_VALUE_UNSET; /** * Contains the current app height of the letterboxed activity if available or * {@link TaskInfo#PROPERTY_VALUE_UNSET} otherwise. * Contains the app bounds of the top activity or size compat mode * bounds when in size compat mode. If null, contains bounds. */ public int topActivityLetterboxAppHeight = PROPERTY_VALUE_UNSET; /** * Contains the current app width of the letterboxed activity if available or * {@link TaskInfo#PROPERTY_VALUE_UNSET} otherwise. */ public int topActivityLetterboxAppWidth = PROPERTY_VALUE_UNSET; @NonNull public final Rect topActivityAppBounds = new Rect(); /** * Contains the top activity bounds when the activity is letterboxed. Loading Loading @@ -350,8 +346,7 @@ public class AppCompatTaskInfo implements Parcelable { && topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition && topActivityLetterboxWidth == that.topActivityLetterboxWidth && topActivityLetterboxHeight == that.topActivityLetterboxHeight && topActivityLetterboxAppWidth == that.topActivityLetterboxAppWidth && topActivityLetterboxAppHeight == that.topActivityLetterboxAppHeight && topActivityAppBounds.equals(that.topActivityAppBounds) && topActivityLetterboxHorizontalPosition == that.topActivityLetterboxHorizontalPosition && cameraCompatTaskInfo.equalsForTaskOrganizer(that.cameraCompatTaskInfo); Loading @@ -371,8 +366,7 @@ public class AppCompatTaskInfo implements Parcelable { == that.topActivityLetterboxHorizontalPosition && topActivityLetterboxWidth == that.topActivityLetterboxWidth && topActivityLetterboxHeight == that.topActivityLetterboxHeight && topActivityLetterboxAppWidth == that.topActivityLetterboxAppWidth && topActivityLetterboxAppHeight == that.topActivityLetterboxAppHeight && topActivityAppBounds.equals(that.topActivityAppBounds) && cameraCompatTaskInfo.equalsForCompatUi(that.cameraCompatTaskInfo); } Loading @@ -385,8 +379,7 @@ public class AppCompatTaskInfo implements Parcelable { topActivityLetterboxHorizontalPosition = source.readInt(); topActivityLetterboxWidth = source.readInt(); topActivityLetterboxHeight = source.readInt(); topActivityLetterboxAppWidth = source.readInt(); topActivityLetterboxAppHeight = source.readInt(); topActivityAppBounds.set(Objects.requireNonNull(source.readTypedObject(Rect.CREATOR))); topActivityLetterboxBounds = source.readTypedObject(Rect.CREATOR); cameraCompatTaskInfo = source.readTypedObject(CameraCompatTaskInfo.CREATOR); } Loading @@ -401,8 +394,7 @@ public class AppCompatTaskInfo implements Parcelable { dest.writeInt(topActivityLetterboxHorizontalPosition); dest.writeInt(topActivityLetterboxWidth); dest.writeInt(topActivityLetterboxHeight); dest.writeInt(topActivityLetterboxAppWidth); dest.writeInt(topActivityLetterboxAppHeight); dest.writeTypedObject(topActivityAppBounds, flags); dest.writeTypedObject(topActivityLetterboxBounds, flags); dest.writeTypedObject(cameraCompatTaskInfo, flags); } Loading @@ -421,8 +413,7 @@ public class AppCompatTaskInfo implements Parcelable { + topActivityLetterboxHorizontalPosition + " topActivityLetterboxWidth=" + topActivityLetterboxWidth + " topActivityLetterboxHeight=" + topActivityLetterboxHeight + " topActivityLetterboxAppWidth=" + topActivityLetterboxAppWidth + " topActivityLetterboxAppHeight=" + topActivityLetterboxAppHeight + " topActivityAppBounds=" + topActivityAppBounds + " isUserFullscreenOverrideEnabled=" + isUserFullscreenOverrideEnabled() + " isSystemFullscreenOverrideEnabled=" + isSystemFullscreenOverrideEnabled() + " hasMinAspectRatioOverride=" + hasMinAspectRatioOverride() Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt +4 −9 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ fun calculateInitialBounds( // For portrait resizeable activities, respect apps fullscreen width but // apply ideal size height. Size( taskInfo.appCompatTaskInfo.topActivityLetterboxAppWidth, taskInfo.appCompatTaskInfo.topActivityAppBounds.width(), idealSize.height, ) } else { Loading @@ -104,7 +104,7 @@ fun calculateInitialBounds( // apply custom app width. Size( customPortraitWidthForLandscapeApp, taskInfo.appCompatTaskInfo.topActivityLetterboxAppHeight, taskInfo.appCompatTaskInfo.topActivityAppBounds.height(), ) } else { // For portrait resizeable activities, simply apply ideal size. Loading Loading @@ -196,13 +196,8 @@ fun maximizeSizeGivenAspectRatio( /** Calculates the aspect ratio of an activity from its fullscreen bounds. */ fun calculateAspectRatio(taskInfo: RunningTaskInfo): Float { val appLetterboxWidth = taskInfo.appCompatTaskInfo.topActivityLetterboxAppWidth val appLetterboxHeight = taskInfo.appCompatTaskInfo.topActivityLetterboxAppHeight if (taskInfo.appCompatTaskInfo.isTopActivityLetterboxed || !taskInfo.canChangeAspectRatio) { return maxOf(appLetterboxWidth, appLetterboxHeight) / minOf(appLetterboxWidth, appLetterboxHeight).toFloat() } val appBounds = taskInfo.configuration.windowConfiguration.appBounds ?: return 1f if (taskInfo.appCompatTaskInfo.topActivityAppBounds.isEmpty) return 1f val appBounds = taskInfo.appCompatTaskInfo.topActivityAppBounds return maxOf(appBounds.height(), appBounds.width()) / minOf(appBounds.height(), appBounds.width()).toFloat() } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +17 −16 Original line number Diff line number Diff line Loading @@ -4160,8 +4160,7 @@ class DesktopTasksControllerTest : ShellTestCase() { screenOrientation = SCREEN_ORIENTATION_LANDSCAPE configuration.windowConfiguration.appBounds = bounds } appCompatTaskInfo.topActivityLetterboxAppWidth = bounds.width() appCompatTaskInfo.topActivityLetterboxAppHeight = bounds.height() appCompatTaskInfo.topActivityAppBounds.set(0, 0, bounds.width(), bounds.height()) isResizeable = false } Loading Loading @@ -4879,15 +4878,19 @@ class DesktopTasksControllerTest : ShellTestCase() { appCompatTaskInfo.isSystemFullscreenOverrideEnabled = enableSystemFullscreenOverride if (deviceOrientation == ORIENTATION_LANDSCAPE) { configuration.windowConfiguration.appBounds = Rect(0, 0, DISPLAY_DIMENSION_LONG, DISPLAY_DIMENSION_SHORT) appCompatTaskInfo.topActivityLetterboxAppWidth = DISPLAY_DIMENSION_LONG appCompatTaskInfo.topActivityLetterboxAppHeight = DISPLAY_DIMENSION_SHORT appCompatTaskInfo.topActivityAppBounds.set( 0, 0, DISPLAY_DIMENSION_LONG, DISPLAY_DIMENSION_SHORT, ) } else { configuration.windowConfiguration.appBounds = Rect(0, 0, DISPLAY_DIMENSION_SHORT, DISPLAY_DIMENSION_LONG) appCompatTaskInfo.topActivityLetterboxAppWidth = DISPLAY_DIMENSION_SHORT appCompatTaskInfo.topActivityLetterboxAppHeight = DISPLAY_DIMENSION_LONG appCompatTaskInfo.topActivityAppBounds.set( 0, 0, DISPLAY_DIMENSION_SHORT, DISPLAY_DIMENSION_LONG, ) } if (shouldLetterbox) { Loading @@ -4897,17 +4900,15 @@ class DesktopTasksControllerTest : ShellTestCase() { screenOrientation == SCREEN_ORIENTATION_PORTRAIT ) { // Letterbox to portrait size appCompatTaskInfo.setTopActivityLetterboxed(true) appCompatTaskInfo.topActivityLetterboxAppWidth = 1200 appCompatTaskInfo.topActivityLetterboxAppHeight = 1600 appCompatTaskInfo.isTopActivityLetterboxed = true appCompatTaskInfo.topActivityAppBounds.set(0, 0, 1200, 1600) } else if ( deviceOrientation == ORIENTATION_PORTRAIT && screenOrientation == SCREEN_ORIENTATION_LANDSCAPE ) { // Letterbox to landscape size appCompatTaskInfo.setTopActivityLetterboxed(true) appCompatTaskInfo.topActivityLetterboxAppWidth = 1600 appCompatTaskInfo.topActivityLetterboxAppHeight = 1200 appCompatTaskInfo.isTopActivityLetterboxed = true appCompatTaskInfo.topActivityAppBounds.set(0, 0, 1600, 1200) } } } Loading
services/core/java/com/android/server/wm/AppCompatUtils.java +2 −5 Original line number Diff line number Diff line Loading @@ -164,15 +164,13 @@ final class AppCompatUtils { appCompatTaskInfo.setIsFromLetterboxDoubleTap(reachabilityOverrides.isFromDoubleTap()); appCompatTaskInfo.topActivityAppBounds.set(getAppBounds(top)); final boolean isTopActivityLetterboxed = top.areBoundsLetterboxed(); appCompatTaskInfo.setTopActivityLetterboxed(isTopActivityLetterboxed); if (isTopActivityLetterboxed) { final Rect bounds = top.getBounds(); final Rect appBounds = getAppBounds(top); appCompatTaskInfo.topActivityLetterboxWidth = bounds.width(); appCompatTaskInfo.topActivityLetterboxHeight = bounds.height(); appCompatTaskInfo.topActivityLetterboxAppWidth = appBounds.width(); appCompatTaskInfo.topActivityLetterboxAppHeight = appBounds.height(); // TODO(b/379824541) Remove duplicate information. appCompatTaskInfo.topActivityLetterboxBounds = bounds; // We need to consider if letterboxed or pillarboxed. Loading Loading @@ -281,8 +279,7 @@ final class AppCompatUtils { info.topActivityLetterboxHorizontalPosition = TaskInfo.PROPERTY_VALUE_UNSET; info.topActivityLetterboxWidth = TaskInfo.PROPERTY_VALUE_UNSET; info.topActivityLetterboxHeight = TaskInfo.PROPERTY_VALUE_UNSET; info.topActivityLetterboxAppHeight = TaskInfo.PROPERTY_VALUE_UNSET; info.topActivityLetterboxAppWidth = TaskInfo.PROPERTY_VALUE_UNSET; info.topActivityAppBounds.setEmpty(); info.topActivityLetterboxBounds = null; info.cameraCompatTaskInfo.freeformCameraCompatMode = CameraCompatTaskInfo.CAMERA_COMPAT_FREEFORM_UNSPECIFIED; Loading