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

Commit fc269493 authored by Hongwei Wang's avatar Hongwei Wang Committed by Android (Google) Code Review
Browse files

Merge "Populate the insets to TaskInfo conditionally" into main

parents d9227e90 4524f978
Loading
Loading
Loading
Loading
+22 −10
Original line number Diff line number Diff line
@@ -47,8 +47,6 @@ import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.SurfaceControl.METADATA_TASK_ID;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
import static android.view.WindowManager.TRANSIT_CHANGE;
@@ -3586,15 +3584,29 @@ class Task extends TaskFragment {
                ? null : new PictureInPictureParams(top.pictureInPictureArgs);
    }

    Rect getDisplayCutoutInsets() {
        if (mDisplayContent == null || getDisplayInfo().displayCutout == null) return null;
    /** @return The display cutout insets where the main window is not allowed to extend to. */
    @NonNull Rect getDisplayCutoutInsets() {
        final Rect displayCutoutInsets = new Rect();
        if (mDisplayContent == null || getDisplayInfo().displayCutout == null) {
            return displayCutoutInsets;
        }
        final WindowState w = getTopVisibleAppMainWindow();
        final int displayCutoutMode = w == null
                ? WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT
                : w.getAttrs().layoutInDisplayCutoutMode;
        return (displayCutoutMode == LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
                || displayCutoutMode == LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES)
                ? null : getDisplayInfo().displayCutout.getSafeInsets();
        final Rect displayFrame;
        if (w != null && w.mHaveFrame) {
            displayFrame = w.getDisplayFrame();
        } else {
            displayFrame = mDisplayContent.getBounds();
            displayFrame.inset(getDisplayInfo().displayCutout.getSafeInsets());
        }
        final Rect taskBounds = getBounds();
        if (displayCutoutInsets.setIntersect(taskBounds, displayFrame)) {
            displayCutoutInsets.set(
                    displayCutoutInsets.left - taskBounds.left,
                    displayCutoutInsets.top - taskBounds.top,
                    taskBounds.right - displayCutoutInsets.right,
                    taskBounds.bottom - displayCutoutInsets.bottom);
        }
        return displayCutoutInsets;
    }

    /**