From a59fd0c1d34cd392266a77a5ac3dc432885da964 Mon Sep 17 00:00:00 2001 From: Graciela Wissen Putri Date: Wed, 29 Jan 2025 17:59:10 +0000 Subject: [5/n] Fix top rounded corners in freeform If activity bounds match parent app bounds height, don't apply rounded corners. Freeform activities will not have visible letterboxing except if eligible for camera compat treatment. Pillarboxing for camera compat will not have rounded corners to ensure consistency between apps. Round up aspect ratio calculations in desktop mode to match activity aspect ratio calculations in core. Flag: com.android.window.flags.exclude_caption_from_app_bounds Bug: 388014743 Test: atest AppCompatLetterboxPolicyTest Change-Id: I5fbc8852c00771ffa228a5a635057eee201a4269 --- .../src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt | 9 +++++---- .../android/wm/shell/desktopmode/DesktopTasksControllerTest.kt | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'libs') diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt index 9b850de6fede..c5ee3137e5ba 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt @@ -33,6 +33,7 @@ import android.util.Size import com.android.wm.shell.R import com.android.wm.shell.common.DisplayController import com.android.wm.shell.common.DisplayLayout +import kotlin.math.ceil val DESKTOP_MODE_INITIAL_BOUNDS_SCALE: Float = SystemProperties.getInt("persist.wm.debug.desktop_mode_initial_bounds_scale", 75) / 100f @@ -190,22 +191,22 @@ fun maximizeSizeGivenAspectRatio( val finalWidth: Int // Get orientation either through top activity or task's orientation if (taskInfo.hasPortraitTopActivity()) { - val tempWidth = (targetHeight / aspectRatio).toInt() + val tempWidth = ceil(targetHeight / aspectRatio).toInt() if (tempWidth <= targetWidth) { finalHeight = targetHeight finalWidth = tempWidth } else { finalWidth = targetWidth - finalHeight = (finalWidth * aspectRatio).toInt() + finalHeight = ceil(finalWidth * aspectRatio).toInt() } } else { - val tempWidth = (targetHeight * aspectRatio).toInt() + val tempWidth = ceil(targetHeight * aspectRatio).toInt() if (tempWidth <= targetWidth) { finalHeight = targetHeight finalWidth = tempWidth } else { finalWidth = targetWidth - finalHeight = (finalWidth / aspectRatio).toInt() + finalHeight = ceil(finalWidth / aspectRatio).toInt() } } return Size(finalWidth, finalHeight + captionInsets) diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt index edb9b2d2fede..fbfdb79eaaec 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt @@ -279,7 +279,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() private val DEFAULT_PORTRAIT_BOUNDS = Rect(200, 165, 1400, 2085) private val RESIZABLE_LANDSCAPE_BOUNDS = Rect(25, 435, 1575, 1635) private val RESIZABLE_PORTRAIT_BOUNDS = Rect(680, 75, 1880, 1275) - private val UNRESIZABLE_LANDSCAPE_BOUNDS = Rect(25, 449, 1575, 1611) + private val UNRESIZABLE_LANDSCAPE_BOUNDS = Rect(25, 448, 1575, 1611) private val UNRESIZABLE_PORTRAIT_BOUNDS = Rect(830, 75, 1730, 1275) private val wallpaperToken = MockToken().token() -- cgit v1.2.3-59-g8ed1b