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

Commit 636678a3 authored by ryanlwlin's avatar ryanlwlin
Browse files

Fix hard dragging from the edge of the screen

When the mirror window is at the edge of the screen,
it is hard to drag it from the side closed to the edge
because the motion events will be cancelled due to edge-back
gesture detection.

To fix it, we inovke setSystemGestureExclusionRects when the
window layout is changed.

Bug: 189936169
Test: atest WindowMagnificationControllerTest
      manually test
Change-Id: I775ce8d6d69aeb3fe1d4433c4e1667bd478b26b3
parent d377bbc2
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ import com.android.systemui.shared.system.WindowManagerWrapper;

import java.io.PrintWriter;
import java.text.NumberFormat;
import java.util.Collections;
import java.util.Locale;

/**
@@ -178,7 +179,13 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
        // Initialize listeners.
        mMirrorViewRunnable = () -> {
            if (mMirrorView != null) {
                final Rect oldViewBounds = new Rect(mMirrorViewBounds);
                mMirrorView.getBoundsOnScreen(mMirrorViewBounds);
                if (oldViewBounds.width() != mMirrorViewBounds.width()
                        || oldViewBounds.height() != mMirrorViewBounds.height()) {
                    mMirrorView.setSystemGestureExclusionRects(Collections.singletonList(
                            new Rect(0, 0, mMirrorViewBounds.width(), mMirrorViewBounds.height())));
                }
                updateSystemUIStateIfNeeded();
                mWindowMagnifierCallback.onWindowMagnifierBoundsChanged(
                        mDisplayId, mMirrorViewBounds);
@@ -269,6 +276,7 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
        if (mMirrorWindowControl != null) {
            mMirrorWindowControl.destroyControl();
        }
        mMirrorViewBounds.setEmpty();
        updateSystemUIStateIfNeeded();
    }

+15 −0
Original line number Diff line number Diff line
@@ -77,6 +77,8 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;

import java.util.List;

@LargeTest
@RunWith(AndroidTestingRunner.class)
public class WindowMagnificationControllerTest extends SysuiTestCase {
@@ -151,6 +153,19 @@ public class WindowMagnificationControllerTest extends SysuiTestCase {
                eq(mContext.getDisplayId()), any(Rect.class));
    }

    @Test
    public void enableWindowMagnification_systemGestureExclusionRectsIsSet() {
        mInstrumentation.runOnMainSync(() -> {
            mWindowMagnificationController.enableWindowMagnification(Float.NaN, Float.NaN,
                    Float.NaN);
        });
        // Wait for Rects updated.
        waitForIdleSync();

        List<Rect> rects = mWindowManager.getAttachedView().getSystemGestureExclusionRects();
        assertFalse(rects.isEmpty());
    }

    @Test
    public void deleteWindowMagnification_destroyControl() {
        mInstrumentation.runOnMainSync(() -> {