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

Commit e50b121c authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed an issue where the insets of the cutout weren't respected

Both the sampled region as well as the detection if it's in the
swipeable region did not factor in the cutout insets and
would calculate the wrong thing.

Bug: 132394665
Test: atest SystemUITests
Change-Id: I9d84f7c76bd987587546b69de6c2875dc5cb303b
parent a1d04536
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -152,6 +152,8 @@ public class EdgeBackGestureHandler implements DisplayListener {
    private WindowManager.LayoutParams mEdgePanelLp;
    private final Rect mSamplingRect = new Rect();
    private RegionSamplingHelper mRegionSamplingHelper;
    private int mLeftInset;
    private int mRightInset;

    public EdgeBackGestureHandler(Context context, OverviewProxyService overviewProxyService) {
        final Resources res = context.getResources();
@@ -299,7 +301,7 @@ public class EdgeBackGestureHandler implements DisplayListener {
            return false;
        }

        if (x > mEdgeWidth && x < (mDisplaySize.x - mEdgeWidth)) {
        if (x > mEdgeWidth + mLeftInset && x < (mDisplaySize.x - mEdgeWidth - mRightInset)) {
            return false;
        }
        boolean isInExcludedRegion = mExcludeRegion.contains(x, y);
@@ -325,7 +327,7 @@ public class EdgeBackGestureHandler implements DisplayListener {
            // Verify if this is in within the touch region and we aren't in immersive mode, and
            // either the bouncer is showing or the notification panel is hidden
            int stateFlags = mOverviewProxyService.getSystemUiStateFlags();
            mIsOnLeftEdge = ev.getX() <= mEdgeWidth;
            mIsOnLeftEdge = ev.getX() <= mEdgeWidth + mLeftInset;
            mAllowGesture = !QuickStepContract.isBackGestureDisabled(stateFlags)
                    && isWithinTouchRegion((int) ev.getX(), (int) ev.getY());
            if (mAllowGesture) {
@@ -400,7 +402,7 @@ public class EdgeBackGestureHandler implements DisplayListener {

    private void updateSamplingRect() {
        int top = mEdgePanelLp.y;
        int left = mIsOnLeftEdge ? 0 : mDisplaySize.x - mEdgePanelLp.width;
        int left = mIsOnLeftEdge ? mLeftInset : mDisplaySize.x - mRightInset - mEdgePanelLp.width;
        int right = left + mEdgePanelLp.width;
        int bottom = top + mEdgePanelLp.height;
        mSamplingRect.set(left, top, right, bottom);
@@ -442,6 +444,11 @@ public class EdgeBackGestureHandler implements DisplayListener {
        InputManager.getInstance().injectInputEvent(ev, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
    }

    public void setInsets(int leftInset, int rightInset) {
        mLeftInset = leftInset;
        mRightInset = rightInset;
    }

    class SysUiInputEventReceiver extends InputEventReceiver {
        SysUiInputEventReceiver(InputChannel channel, Looper looper) {
            super(channel, looper);
+7 −2
Original line number Diff line number Diff line
@@ -1095,8 +1095,13 @@ public class NavigationBarView extends FrameLayout implements

    @Override
    public WindowInsets onApplyWindowInsets(WindowInsets insets) {
        setPadding(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
                insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
        int leftInset = insets.getSystemWindowInsetLeft();
        int rightInset = insets.getSystemWindowInsetRight();
        setPadding(leftInset, insets.getSystemWindowInsetTop(), rightInset,
                insets.getSystemWindowInsetBottom());
        // we're passing the insets onto the gesture handler since the back arrow is only
        // conditionally added and doesn't always get all the insets.
        mEdgeBackGestureHandler.setInsets(leftInset, rightInset);
        return super.onApplyWindowInsets(insets);
    }