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

Commit 39f818c7 authored by wilsonshih's avatar wilsonshih
Browse files

Allow bar to be transparent if letterbox contains bar

When top window request fullscreen and device contain a real cutout
and the layoutInDisplayCutout is default or never, a letterbox will
be created for this activity, which cause
BarController#isTransparentAllowed return false so the status bar
cannot be transparent, the bar will shows a black background
during hidding animation.
For a better animating effect, allow the bar to be transparent if
the letterbox is fully covered the bar.
Also modify the layout area of each letterbox surface, so it can be
more convenient to do geometric check when multiple cutout existing.

Bug: 152273579
Test: manualy verify no black background shows on status bar when
opening fullscreen app.
Test: atest DisplayPolicyTests LetterboxTest

Change-Id: I1f458394a8c6a2ac53a461b6819a026090d62898
parent 35c6b8f0
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -395,14 +395,6 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
            return false;
        }

        /**
         * Returns true if the window has a letterbox and any part of that letterbox overlaps with
         * the given {@code rect}.
         */
        default boolean isLetterboxedOverlappingWith(Rect rect) {
            return false;
        }

        /** @return the current windowing mode of this window. */
        int getWindowingMode();

+3 −4
Original line number Diff line number Diff line
@@ -1414,11 +1414,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }

    /**
     * @return {@code true} if there is a letterbox and any part of that letterbox overlaps with
     * the given {@code rect}.
     * @see Letterbox#notIntersectsOrFullyContains(Rect)
     */
    boolean isLetterboxOverlappingWith(Rect rect) {
        return mLetterbox != null && mLetterbox.isOverlappingWith(rect);
    boolean letterboxNotIntersectsOrFullyContains(Rect rect) {
        return mLetterbox == null || mLetterbox.notIntersectsOrFullyContains(rect);
    }

    static class Token extends IApplicationToken.Stub {
+1 −1
Original line number Diff line number Diff line
@@ -168,7 +168,7 @@ public class BarController {
    }

    boolean isTransparentAllowed(WindowState win) {
        return win == null || !win.isLetterboxedOverlappingWith(mContentFrame);
        return win == null || win.letterboxNotIntersectsOrFullyContains(mContentFrame);
    }

    boolean setBarShowingLw(final boolean show) {
+21 −20
Original line number Diff line number Diff line
@@ -77,10 +77,10 @@ public class Letterbox {
        mOuter.set(outer);
        mInner.set(inner);

        mTop.layout(outer.left, outer.top, inner.right, inner.top, surfaceOrigin);
        mLeft.layout(outer.left, inner.top, inner.left, outer.bottom, surfaceOrigin);
        mBottom.layout(inner.left, inner.bottom, outer.right, outer.bottom, surfaceOrigin);
        mRight.layout(inner.right, outer.top, outer.right, inner.bottom, surfaceOrigin);
        mTop.layout(outer.left, outer.top, outer.right, inner.top, surfaceOrigin);
        mLeft.layout(outer.left, outer.top, inner.left, outer.bottom, surfaceOrigin);
        mBottom.layout(outer.left, inner.bottom, outer.right, outer.bottom, surfaceOrigin);
        mRight.layout(inner.right, outer.top, outer.right, outer.bottom, surfaceOrigin);
    }


@@ -101,17 +101,29 @@ public class Letterbox {
    }

    /**
     * Returns true if any part of the letterbox overlaps with the given {@code rect}.
     * Returns {@code true} if the letterbox does not overlap with the bar, or the letterbox can
     * fully cover the window frame.
     *
     * @param rect The area of the window frame.
     */
    public boolean isOverlappingWith(Rect rect) {
    boolean notIntersectsOrFullyContains(Rect rect) {
        int emptyCount = 0;
        int noOverlappingCount = 0;
        for (LetterboxSurface surface : mSurfaces) {
            if (surface.isOverlappingWith(rect)) {
            final Rect surfaceRect = surface.mLayoutFrameGlobal;
            if (surfaceRect.isEmpty()) {
                // empty letterbox
                emptyCount++;
            } else if (!Rect.intersects(surfaceRect, rect)) {
                // no overlapping
                noOverlappingCount++;
            } else if (surfaceRect.contains(rect)) {
                // overlapping and covered
                return true;
            }
        }
        return false;
        return (emptyCount + noOverlappingCount) == mSurfaces.length;
    }

    /**
     * Hides the letterbox.
     *
@@ -282,17 +294,6 @@ public class Letterbox {
            return Math.max(0, mLayoutFrameGlobal.height());
        }

        /**
         * Returns if the given {@code rect} overlaps with this letterbox piece.
         * @param rect the area to check for overlap in global coordinates
         */
        public boolean isOverlappingWith(Rect rect) {
            if (mLayoutFrameGlobal.isEmpty()) {
                return false;
            }
            return Rect.intersects(rect, mLayoutFrameGlobal);
        }

        public void applySurfaceChanges(SurfaceControl.Transaction t) {
            if (mSurfaceFrameRelative.equals(mLayoutFrameRelative)) {
                // Nothing changed.
+6 −3
Original line number Diff line number Diff line
@@ -3660,9 +3660,12 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        return mActivityRecord.getBounds().equals(mTmpRect);
    }

    @Override
    public boolean isLetterboxedOverlappingWith(Rect rect) {
        return mActivityRecord != null && mActivityRecord.isLetterboxOverlappingWith(rect);
    /**
     * @see Letterbox#notIntersectsOrFullyContains(Rect)
     */
    boolean letterboxNotIntersectsOrFullyContains(Rect rect) {
        return mActivityRecord == null
                || mActivityRecord.letterboxNotIntersectsOrFullyContains(rect);
    }

    boolean isDragResizeChanged() {
Loading