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

Commit 29dd6d71 authored by shawnlin's avatar shawnlin Committed by Shawn Lin
Browse files

Fix WindowInsetsBehaviorTests failure

The system provides extra swipe start threshold when swiping
down from top in devices with a cutout at top.

We should include this extra area when reporting the system gesture
insets.

Bug: 196001869
Test: atest WindowInsetsBehaviorTests
Change-Id: I83a97be6cd7f2d13318d75aa26b9bf1ef3c1c428
parent 9fd02e1b
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -355,6 +355,8 @@ public class DisplayPolicy {

    private PointerLocationView mPointerLocationView;

    private int mDisplayCutoutTouchableRegionSize;

    /**
     * The area covered by system windows which belong to another display. Forwarded insets is set
     * in case this is a virtual display, this is displayed on another display that has insets, and
@@ -1081,8 +1083,21 @@ public class DisplayPolicy {
                        (displayFrames, windowState, rect) -> {
                            rect.bottom = rect.top + getStatusBarHeight(displayFrames);
                        };
                final TriConsumer<DisplayFrames, WindowState, Rect> gestureFrameProvider =
                        (displayFrames, windowState, rect) -> {
                            rect.bottom = rect.top + getStatusBarHeight(displayFrames);
                            final DisplayCutout cutout =
                                    displayFrames.mInsetsState.getDisplayCutout();
                            if (cutout != null) {
                                final Rect top = cutout.getBoundingRectTop();
                                if (!top.isEmpty()) {
                                    rect.bottom = rect.bottom + mDisplayCutoutTouchableRegionSize;
                                }
                            }
                        };
                mDisplayContent.setInsetProvider(ITYPE_STATUS_BAR, win, frameProvider);
                mDisplayContent.setInsetProvider(ITYPE_TOP_MANDATORY_GESTURES, win, frameProvider);
                mDisplayContent.setInsetProvider(
                        ITYPE_TOP_MANDATORY_GESTURES, win, gestureFrameProvider);
                mDisplayContent.setInsetProvider(ITYPE_TOP_TAPPABLE_ELEMENT, win, frameProvider);
                break;
            case TYPE_NAVIGATION_BAR:
@@ -1993,11 +2008,14 @@ public class DisplayPolicy {
            mStatusBarHeightForRotation[landscapeRotation] =
                    mStatusBarHeightForRotation[seascapeRotation] =
                            res.getDimensionPixelSize(R.dimen.status_bar_height_landscape);
            mDisplayCutoutTouchableRegionSize = res.getDimensionPixelSize(
                    R.dimen.display_cutout_touchable_region_size);
        } else {
            mStatusBarHeightForRotation[portraitRotation] =
                    mStatusBarHeightForRotation[upsideDownRotation] =
                            mStatusBarHeightForRotation[landscapeRotation] =
                                    mStatusBarHeightForRotation[seascapeRotation] = 0;
            mDisplayCutoutTouchableRegionSize = 0;
        }

        // Height of the navigation bar when presented horizontally at bottom