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

Commit b3aaef9f authored by Hiroki Sato's avatar Hiroki Sato
Browse files

Use Region#op instead of #quickReject for intersection check

quickReject only checks the minimum bounding box of the regions, which
may give us false negative as suggested in Region's javadoc.

This leads a bug where a window is still added to the exposed list even
if it is fully covered by other windows.

This is an updated version of the reverted CL [1] behind a
computeWindowChangesOnA11y flag. Previously [1] was reverted due to CTS
failure, but now that with [2] the CTS won't fail.

[1] I7fc226e2288c2433e427d1e8ef173a3a21a20edc
[2] Id4b24284db40feaa744c9a5598d0067566fa3963

Bug: 240885392
Bug: 254581919
Test: android.autofillservice.cts.servicebehavior.SettingsIntentTest
Test: android.autofillservice.cts.inline.InlineTooltipTest
Test: CtsAccessibilityServiceTestCases CtsAccessibilityTestCases AccessibilityWindowManagerWithAccessibilityWindowTest
Change-Id: Ie2d1714c91a0f1d8f73f837505365899c314c038
parent 317827fe
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",