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

Commit db704ca8 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Fix cutout with temp inset bounds" into pi-dev

parents 9aa2a33c bae2b15c
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -1088,6 +1088,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                            :  Math.max(mFrame.bottom - mStableFrame.bottom, 0));
        }

        mDisplayCutout = displayCutout.calculateRelativeTo(mFrame);

        // Offset the actual frame by the amount layout frame is off.
        mFrame.offset(-layoutXDiff, -layoutYDiff);
        mCompatFrame.offset(-layoutXDiff, -layoutYDiff);
@@ -1095,10 +1097,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        mVisibleFrame.offset(-layoutXDiff, -layoutYDiff);
        mStableFrame.offset(-layoutXDiff, -layoutYDiff);

        // TODO(roosa): Figure out what frame exactly this needs to be calculated with.
        mDisplayCutout = displayCutout.calculateRelativeTo(mFrame);


        mCompatFrame.set(mFrame);
        if (mEnforceSizeCompat) {
            // If there is a size compatibility scale being applied to the
+22 −0
Original line number Diff line number Diff line
@@ -441,6 +441,28 @@ public class WindowFrameTests extends WindowTestsBase {
        assertEquals(w.mDisplayCutout.getDisplayCutout().getSafeInsetRight(), 0);
    }

    @Test
    public void testDisplayCutout_tempInsetBounds() {
        // Regular fullscreen task and window
        TaskWithBounds task = new TaskWithBounds(new Rect(0, -500, 1000, 1500));
        task.mFullscreenForTest = false;
        task.mInsetBounds.set(0, 0, 1000, 2000);
        WindowState w = createWindow(task, FILL_PARENT, FILL_PARENT);
        w.mAttrs.gravity = Gravity.LEFT | Gravity.TOP;

        final Rect pf = new Rect(0, -500, 1000, 1500);
        // Create a display cutout of size 50x50, aligned top-center
        final WmDisplayCutout cutout = WmDisplayCutout.computeSafeInsets(
                fromBoundingRect(500, 0, 550, 50), pf.width(), pf.height());

        w.computeFrameLw(pf, pf, pf, pf, pf, pf, pf, pf, cutout, false);

        assertEquals(w.mDisplayCutout.getDisplayCutout().getSafeInsetTop(), 50);
        assertEquals(w.mDisplayCutout.getDisplayCutout().getSafeInsetBottom(), 0);
        assertEquals(w.mDisplayCutout.getDisplayCutout().getSafeInsetLeft(), 0);
        assertEquals(w.mDisplayCutout.getDisplayCutout().getSafeInsetRight(), 0);
    }

    private WindowStateWithTask createWindow(Task task, int width, int height) {
        final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(TYPE_APPLICATION);
        attrs.width = width;