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

Commit 0251a892 authored by Yunfan Chen's avatar Yunfan Chen Committed by Android (Google) Code Review
Browse files

Merge "Make sure to extend insets frame when the bar layout with cutout" into tm-qpr-dev

parents 0b670f20 2a4fc3c9
Loading
Loading
Loading
Loading
+17 −12
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package android.view;

import static android.view.Gravity.DISPLAY_CLIP_HORIZONTAL;
import static android.view.Gravity.DISPLAY_CLIP_VERTICAL;
import static android.view.InsetsState.ITYPE_IME;
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
import static android.view.InsetsState.ITYPE_STATUS_BAR;
@@ -275,17 +273,9 @@ public class WindowLayout {
            Gravity.applyDisplay(attrs.gravity, outDisplayFrame, outFrame);
        }

        if (extendedByCutout && !displayCutoutSafe.contains(outFrame)) {
            mTempRect.set(outFrame);

            // Move the frame into displayCutoutSafe.
            final int clipFlags = DISPLAY_CLIP_VERTICAL | DISPLAY_CLIP_HORIZONTAL;
            Gravity.applyDisplay(attrs.gravity & ~clipFlags, displayCutoutSafe,
        if (extendedByCutout) {
            extendFrameByCutout(attrs.gravity, displayCutoutSafe, outDisplayFrame, outFrame,
                    mTempRect);

            if (mTempRect.intersect(outDisplayFrame)) {
                outFrame.union(mTempRect);
            }
        }

        if (DEBUG) Log.d(TAG, "computeFrames " + attrs.getTitle()
@@ -301,6 +291,21 @@ public class WindowLayout {
                + " requestedVisibilities=" + requestedVisibilities);
    }

    public static void extendFrameByCutout(int gravity, Rect displayCutoutSafe,
            Rect displayFrame, Rect inOutFrame, Rect tempRect) {
        if (displayCutoutSafe.contains(inOutFrame)) {
            return;
        }
        tempRect.set(inOutFrame);

        // Move the frame into displayCutoutSafe.
        Gravity.applyDisplay(0 /* gravity */, displayCutoutSafe, tempRect);

        if (tempRect.intersect(displayFrame)) {
            inOutFrame.union(tempRect);
        }
    }

    public static void computeSurfaceSize(WindowManager.LayoutParams attrs, Rect maxBounds,
            int requestedWidth, int requestedHeight, Rect winFrame, boolean dragResizing,
            Point outSurfaceSize) {
+23 −8
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_INTERCEPT_GLOBAL_DRAG_AND_DROP;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR;
@@ -1166,7 +1167,8 @@ public class DisplayPolicy {
                                            continue;
                                        }
                                        calculateInsetsFrame(displayFrames, win, inOutFrame,
                                                provider.source, provider.insetsSize
                                                provider.source, provider.insetsSize,
                                                lp.privateFlags, lp.gravity
                                        );
                                    }
                                }
@@ -1241,21 +1243,25 @@ public class DisplayPolicy {
                                provider.insetsSize != null
                                        ? (displayFrames, windowContainer, inOutFrame) -> {
                                            inOutFrame.inset(win.mGivenContentInsets);
                                            final LayoutParams lp =
                                                    win.mAttrs.forRotation(displayFrames.mRotation);
                                            final InsetsFrameProvider ifp =
                                                    win.mAttrs.forRotation(displayFrames.mRotation)
                                                            .providedInsets[index];
                                                    lp.providedInsets[index];
                                            calculateInsetsFrame(displayFrames, windowContainer,
                                                    inOutFrame, ifp.source, ifp.insetsSize);
                                                    inOutFrame, ifp.source, ifp.insetsSize,
                                                    lp.privateFlags, lp.gravity);
                                        } : null;
                        final TriConsumer<DisplayFrames, WindowContainer, Rect> imeFrameProvider =
                                provider.imeInsetsSize != null
                                        ? (displayFrames, windowContainer, inOutFrame) -> {
                                            inOutFrame.inset(win.mGivenContentInsets);
                                            final LayoutParams lp =
                                                    win.mAttrs.forRotation(displayFrames.mRotation);
                                            final InsetsFrameProvider ifp =
                                                    win.mAttrs.forRotation(displayFrames.mRotation)
                                                            .providedInsets[index];
                                                    lp.providedInsets[index];
                                            calculateInsetsFrame(displayFrames, windowContainer,
                                                    inOutFrame, ifp.source, ifp.imeInsetsSize);
                                                    inOutFrame, ifp.source, ifp.imeInsetsSize,
                                                    lp.privateFlags, lp.gravity);
                                        } : null;
                        mDisplayContent.setInsetProvider(provider.type, win, frameProvider,
                                imeFrameProvider);
@@ -1267,11 +1273,15 @@ public class DisplayPolicy {
    }

    private void calculateInsetsFrame(DisplayFrames df, WindowContainer container, Rect inOutFrame,
            int source, Insets insetsSize) {
            int source, Insets insetsSize, @LayoutParams.PrivateFlags int privateFlags,
            int windowGravity) {
        boolean extendByCutout = false;
        if (source == InsetsFrameProvider.SOURCE_DISPLAY) {
            inOutFrame.set(df.mUnrestricted);
        } else if (source == InsetsFrameProvider.SOURCE_CONTAINER_BOUNDS) {
            inOutFrame.set(container.getBounds());
        } else {
            extendByCutout = (privateFlags & PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT) != 0;
        }
        if (insetsSize == null) {
            return;
@@ -1289,6 +1299,11 @@ public class DisplayPolicy {
        } else {
            inOutFrame.setEmpty();
        }

        if (extendByCutout) {
            WindowLayout.extendFrameByCutout(windowGravity, df.mDisplayCutoutSafe,
                    df.mUnrestricted, inOutFrame, sTmpRect);
        }
    }

    @WindowManagerPolicy.AltBarPosition