Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit be1514e7 authored by Eghosa Ewansiha-Vlachavas's avatar Eghosa Ewansiha-Vlachavas
Browse files

Use display specific context for caption inset calculation

They height of the caption inset is specific to each display, so use the
context of display the task is targeting to retrieve caption height
value that corresponds to that display.

Flag: com.android.window.flags.exclude_caption_from_app_bounds
Test: atest DesktopModeLaunchParamsModifierTests,
      atest WMShellUnitTests:DesktopTasksControllerTest
      & manual testing
Bug: 416336612
Change-Id: I16c62ae8d4d6c5bc6ead13922c09aab73311f046
parent ee700ffe
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -3427,9 +3427,11 @@ class DesktopTasksController(
                // If caption insets should be excluded from app bounds, ensure caption insets
                // are excluded from the ideal initial bounds when scaling non-resizeable apps.
                // Caption insets stay fixed and don't scale with bounds.
                val displayId = taskRepository.getDisplayForDesk(deskId)
                val displayContext = displayController.getDisplayContext(displayId) ?: context
                val captionInsets =
                    if (desktopModeCompatPolicy.shouldExcludeCaptionFromAppBounds(taskInfo)) {
                        getDesktopViewAppHeaderHeightPx(context)
                        getDesktopViewAppHeaderHeightPx(displayContext)
                    } else {
                        0
                    }
+6 −2
Original line number Diff line number Diff line
@@ -1582,7 +1582,9 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        controller.addMoveToDeskTaskChanges(wct, task, deskId = 0)

        val finalBounds = findBoundsChange(wct, task)
        val captionInsets = getDesktopViewAppHeaderHeightPx(context)
        val displayId = taskRepository.getDisplayForDesk(deskId = 0)
        val displayContext = displayController.getDisplayContext(displayId) ?: context
        val captionInsets = getDesktopViewAppHeaderHeightPx(displayContext)
        finalBounds!!.top += captionInsets
        val finalAspectRatio =
            maxOf(finalBounds.height(), finalBounds.width()) /
@@ -1604,7 +1606,9 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        controller.addMoveToDeskTaskChanges(wct, task, deskId = 0)

        val finalBounds = findBoundsChange(wct, task)
        val captionInsets = getDesktopViewAppHeaderHeightPx(context)
        val displayId = taskRepository.getDisplayForDesk(deskId = 0)
        val displayContext = displayController.getDisplayContext(displayId) ?: context
        val captionInsets = getDesktopViewAppHeaderHeightPx(displayContext)
        finalBounds!!.top += captionInsets
        val finalAspectRatio =
            maxOf(finalBounds.height(), finalBounds.width()) /
+6 −1
Original line number Diff line number Diff line
@@ -32,11 +32,13 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityOptions;
import android.app.WindowConfiguration;
import android.content.Context;
import android.content.pm.ActivityInfo.WindowLayout;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.SystemProperties;
import android.util.Size;
import android.view.Display;
import android.view.Gravity;
import android.window.DesktopModeFlags;

@@ -83,9 +85,12 @@ public final class DesktopModeBoundsCalculator {
        // during the size update.
        final boolean shouldRespectOptionPosition =
                updateOptionBoundsSize && DesktopModeFlags.ENABLE_CASCADING_WINDOWS.isTrue();
        // Calculate caption height for target display if needed.
        final Display targetDisplay = task.getDisplayArea().mDisplayContent.getDisplay();
        final Context displayContext = task.mWmService.mContext.createDisplayContext(targetDisplay);
        final int captionHeight = activity != null && shouldExcludeCaptionFromAppBounds(
                activity.info, task.isResizeable(), activity.mOptOutEdgeToEdge)
                        ? getDesktopViewAppHeaderHeightPx(activity.mWmService.mContext) : 0;
                        ? getDesktopViewAppHeaderHeightPx(displayContext) : 0;

        if (options != null && options.getLaunchBounds() != null
                && !updateOptionBoundsSize) {