Loading services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java +7 −4 Original line number Diff line number Diff line Loading @@ -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(); } Loading Loading @@ -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(); Loading Loading @@ -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; Loading services/tests/servicestests/src/com/android/server/accessibility/autoclick/AutoclickControllerTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -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() { Loading Loading
services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java +7 −4 Original line number Diff line number Diff line Loading @@ -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(); } Loading Loading @@ -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(); Loading Loading @@ -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; Loading
services/tests/servicestests/src/com/android/server/accessibility/autoclick/AutoclickControllerTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -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() { Loading