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

Commit 599d6368 authored by Hiroki Sato's avatar Hiroki Sato Committed by Android (Google) Code Review
Browse files

Merge "Use Region#op instead of #quickReject for intersection check" into main

parents 261ad46b b3aaef9f
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -79,6 +79,8 @@ public class AccessibilityWindowManager {

    private static int sNextWindowId;

    private final Region mTmpRegion = new Region();

    private final Object mLock;
    private final Handler mHandler;
    private final WindowManagerInternal mWindowManagerInternal;
@@ -613,7 +615,7 @@ public class AccessibilityWindowManager {
            }

            // If the window is completely covered by other windows - ignore.
            if (unaccountedSpace.quickReject(regionInScreen)) {
            if (!mTmpRegion.op(unaccountedSpace, regionInScreen, Region.Op.INTERSECT)) {
                return false;
            }

+21 −0
Original line number Diff line number Diff line
@@ -469,6 +469,27 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest {
        assertEquals(bounds, embeddingBounds);
    }

    @Test
    public void onWindowsChanged_shouldNotReportfullyOccludedWindow() {
        final AccessibilityWindow frontWindow = mWindows.get(Display.DEFAULT_DISPLAY).get(0);
        setRegionForMockAccessibilityWindow(frontWindow, new Region(100, 100, 300, 300));
        final int frontWindowId = mA11yWindowManager.findWindowIdLocked(
                USER_SYSTEM_ID, frontWindow.getWindowInfo().token);

        // index 1 is focused. Let's use the next one for this test.
        final AccessibilityWindow occludedWindow = mWindows.get(Display.DEFAULT_DISPLAY).get(2);
        setRegionForMockAccessibilityWindow(occludedWindow, new Region(150, 150, 250, 250));
        final int occludedWindowId = mA11yWindowManager.findWindowIdLocked(
                USER_SYSTEM_ID, occludedWindow.getWindowInfo().token);

        onAccessibilityWindowsChanged(Display.DEFAULT_DISPLAY, SEND_ON_WINDOW_CHANGES);

        final List<AccessibilityWindowInfo> a11yWindows =
                mA11yWindowManager.getWindowListLocked(Display.DEFAULT_DISPLAY);
        assertThat(a11yWindows, hasItem(windowId(frontWindowId)));
        assertThat(a11yWindows, not(hasItem(windowId(occludedWindowId))));
    }

    @Test
    public void onWindowsChangedAndForceSend_shouldUpdateWindows() {
        assertNotEquals("new title",