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

Commit b6b7bf6f authored by Eghosa Ewansiha-Vlachavas's avatar Eghosa Ewansiha-Vlachavas Committed by Android (Google) Code Review
Browse files

Merge "Use display specific context for caption inset calculation" into main

parents a371be12 be1514e7
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) {