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

Commit ae9c959e authored by Gavin Williams's avatar Gavin Williams Committed by Android (Google) Code Review
Browse files

Merge "a11y: Reland ignore cursor area size when hovering panel" into main

parents 25faa39d ca709f40
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -334,10 +334,10 @@ public class AutoclickController extends BaseEventStreamTransformation {

    private boolean isPaused() {
        return Flags.enableAutoclickIndicator() && mAutoclickTypePanel.isPaused()
                && !isHovered();
                && !isPanelHovered();
    }

    private boolean isHovered() {
    private boolean isPanelHovered() {
        return Flags.enableAutoclickIndicator() && mAutoclickTypePanel.isHovered();
    }

@@ -873,7 +873,7 @@ public class AutoclickController extends BaseEventStreamTransformation {
            }
            mLastMotionEvent = MotionEvent.obtain(event);
            mEventPolicyFlags = policyFlags;
            mHoveredState = isHovered();
            mHoveredState = isPanelHovered();

            if (useAsAnchor) {
                final int pointerIndex = mLastMotionEvent.getActionIndex();
@@ -913,8 +913,11 @@ public class AutoclickController extends BaseEventStreamTransformation {
            float deltaX = mAnchorCoords.x - event.getX(pointerIndex);
            float deltaY = mAnchorCoords.y - event.getY(pointerIndex);
            double delta = Math.hypot(deltaX, deltaY);
            // If the panel is hovered, always use the default slop so it's easier to click the
            // closely spaced buttons.
            double slop =
                    ((Flags.enableAutoclickIndicator() && mIgnoreMinorCursorMovement)
                    ((Flags.enableAutoclickIndicator() && mIgnoreMinorCursorMovement
                            && !isPanelHovered())
                            ? mMovementSlop
                            : DEFAULT_MOVEMENT_SLOP);
            return delta > slop;
+32 −0
Original line number Diff line number Diff line
@@ -831,6 +831,38 @@ public class AutoclickControllerTest {
        assertThat(mController.mAutoclickScrollPanel.isVisible()).isFalse();
    }

    @Test
    @EnableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_AUTOCLICK_INDICATOR)
    public void hoverOnAutoclickPanel_useDefaultCursorArea() {
        initializeAutoclick();

        // Set an extra large cursor area size and enable ignore minor cursor movement.
        int customSize = 250;
        Settings.Secure.putIntForUser(mTestableContext.getContentResolver(),
                Settings.Secure.ACCESSIBILITY_AUTOCLICK_CURSOR_AREA_SIZE,
                customSize,
                mTestableContext.getUserId());
        mController.onChangeForTesting(/* selfChange= */ true,
                Settings.Secure.getUriFor(
                        Settings.Secure.ACCESSIBILITY_AUTOCLICK_CURSOR_AREA_SIZE));
        enableIgnoreMinorCursorMovement();

        // Set mouse to hover panel.
        AutoclickTypePanel mockAutoclickTypePanel = mock(AutoclickTypePanel.class);
        when(mockAutoclickTypePanel.isHovered()).thenReturn(true);
        mController.mAutoclickTypePanel = mockAutoclickTypePanel;

        // Send a hover move event that's within than the cursor area size. Normally because
        // ignoreMinorCursorMovement is enabled this wouldn't trigger a click. But since the panel
        // is hovered a click is expected.
        injectFakeMouseMoveEvent(/* x= */ 30f, /* y= */ 0, MotionEvent.ACTION_HOVER_MOVE);
        mTestableLooper.processAllMessages();

        // Verify the expected left click.
        assertThat(mMotionEventCaptor.eventCount).isEqualTo(
                getNumEventsExpectedFromClick(/* numClicks= */ 1));
    }

    @Test
    @EnableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_AUTOCLICK_INDICATOR)
    public void sendClick_updateLastCursorAndScrollAtThatLocation() {