Loading services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java +24 −9 Original line number Diff line number Diff line Loading @@ -525,13 +525,17 @@ public class AutoclickController extends BaseEventStreamTransformation implement */ private boolean isPaused() { return Flags.enableAutoclickIndicator() && mAutoclickTypePanel.isPaused() && !isPanelHovered(); && !isClickTypePanelHovered(); } private boolean isPanelHovered() { private boolean isClickTypePanelHovered() { return Flags.enableAutoclickIndicator() && mAutoclickTypePanel.isHovered(); } private boolean isScrollPanelHovered() { return Flags.enableAutoclickIndicator() && mAutoclickScrollPanel.isHovered(); } private void cancelPendingClick() { if (mClickScheduler != null) { mClickScheduler.cancel(); Loading Loading @@ -1005,6 +1009,12 @@ public class AutoclickController extends BaseEventStreamTransformation implement */ private static final double DEFAULT_MOVEMENT_SLOP = 20f; /** * A reduced minimal distance to make the closely spaced buttons easier to click. Used when * the pointer is hovering either the click type panel or the scroll panel. */ private static final double PANEL_HOVERED_SLOP = 5f; private double mMovementSlop = DEFAULT_MOVEMENT_SLOP; /** Whether the minor cursor movement should be ignored. */ Loading Loading @@ -1258,7 +1268,7 @@ public class AutoclickController extends BaseEventStreamTransformation implement } mLastMotionEvent = MotionEvent.obtain(event); mEventPolicyFlags = policyFlags; mHoveredState = isPanelHovered(); mHoveredState = isClickTypePanelHovered(); if (useAsAnchor) { final int pointerIndex = mLastMotionEvent.getActionIndex(); Loading Loading @@ -1300,12 +1310,17 @@ public class AutoclickController extends BaseEventStreamTransformation implement 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() && !isPanelHovered()) ? mMovementSlop : DEFAULT_MOVEMENT_SLOP); // If a panel is hovered, use the special slop to make clicking the panel buttons // easier. double slop; if (!Flags.enableAutoclickIndicator()) { slop = DEFAULT_MOVEMENT_SLOP; } else if (isClickTypePanelHovered() || isScrollPanelHovered()) { slop = PANEL_HOVERED_SLOP; } else { slop = mMovementSlop; } return delta > slop; } Loading services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickScrollPanel.java +4 −5 Original line number Diff line number Diff line Loading @@ -341,6 +341,10 @@ public class AutoclickScrollPanel { }); } public boolean isHovered() { return mContentView.isHovered(); } /** * Retrieves the layout params for AutoclickScrollPanel, used when it's added to the Window * Manager. Loading Loading @@ -368,11 +372,6 @@ public class AutoclickScrollPanel { return mInScrollMode; } @VisibleForTesting public boolean isHovered() { return mContentView.isHovered(); } @VisibleForTesting public AutoclickLinearLayout getContentViewForTesting() { return mContentView; Loading services/tests/servicestests/src/com/android/server/accessibility/integration/AutoclickClickTypeTests.kt +8 −6 Original line number Diff line number Diff line Loading @@ -201,14 +201,16 @@ class AutoclickClickTypeTests { changeClickType(uiDevice, desktopMouseTestRule, SCROLL_BUTTON_LAYOUT_ID) moveMouseToView(testClickButton) moveMouseToScrollButton(SCROLL_UP_BUTTON_LAYOUT_ID) // Scroll to each button in this order to prevent the exit button from being inadvertently // hovered. moveMouseToScrollButton(SCROLL_RIGHT_BUTTON_LAYOUT_ID) waitAndAssert { testClickButton.text == SCROLL_UP_TEXT testClickButton.text == SCROLL_RIGHT_TEXT } moveMouseToScrollButton(SCROLL_DOWN_BUTTON_LAYOUT_ID) moveMouseToScrollButton(SCROLL_UP_BUTTON_LAYOUT_ID) waitAndAssert { testClickButton.text == SCROLL_DOWN_TEXT testClickButton.text == SCROLL_UP_TEXT } moveMouseToScrollButton(SCROLL_LEFT_BUTTON_LAYOUT_ID) Loading @@ -216,9 +218,9 @@ class AutoclickClickTypeTests { testClickButton.text == SCROLL_LEFT_TEXT } moveMouseToScrollButton(SCROLL_RIGHT_BUTTON_LAYOUT_ID) moveMouseToScrollButton(SCROLL_DOWN_BUTTON_LAYOUT_ID) waitAndAssert { testClickButton.text == SCROLL_RIGHT_TEXT testClickButton.text == SCROLL_DOWN_TEXT } // Close the scroll panel. Loading Loading
services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java +24 −9 Original line number Diff line number Diff line Loading @@ -525,13 +525,17 @@ public class AutoclickController extends BaseEventStreamTransformation implement */ private boolean isPaused() { return Flags.enableAutoclickIndicator() && mAutoclickTypePanel.isPaused() && !isPanelHovered(); && !isClickTypePanelHovered(); } private boolean isPanelHovered() { private boolean isClickTypePanelHovered() { return Flags.enableAutoclickIndicator() && mAutoclickTypePanel.isHovered(); } private boolean isScrollPanelHovered() { return Flags.enableAutoclickIndicator() && mAutoclickScrollPanel.isHovered(); } private void cancelPendingClick() { if (mClickScheduler != null) { mClickScheduler.cancel(); Loading Loading @@ -1005,6 +1009,12 @@ public class AutoclickController extends BaseEventStreamTransformation implement */ private static final double DEFAULT_MOVEMENT_SLOP = 20f; /** * A reduced minimal distance to make the closely spaced buttons easier to click. Used when * the pointer is hovering either the click type panel or the scroll panel. */ private static final double PANEL_HOVERED_SLOP = 5f; private double mMovementSlop = DEFAULT_MOVEMENT_SLOP; /** Whether the minor cursor movement should be ignored. */ Loading Loading @@ -1258,7 +1268,7 @@ public class AutoclickController extends BaseEventStreamTransformation implement } mLastMotionEvent = MotionEvent.obtain(event); mEventPolicyFlags = policyFlags; mHoveredState = isPanelHovered(); mHoveredState = isClickTypePanelHovered(); if (useAsAnchor) { final int pointerIndex = mLastMotionEvent.getActionIndex(); Loading Loading @@ -1300,12 +1310,17 @@ public class AutoclickController extends BaseEventStreamTransformation implement 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() && !isPanelHovered()) ? mMovementSlop : DEFAULT_MOVEMENT_SLOP); // If a panel is hovered, use the special slop to make clicking the panel buttons // easier. double slop; if (!Flags.enableAutoclickIndicator()) { slop = DEFAULT_MOVEMENT_SLOP; } else if (isClickTypePanelHovered() || isScrollPanelHovered()) { slop = PANEL_HOVERED_SLOP; } else { slop = mMovementSlop; } return delta > slop; } Loading
services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickScrollPanel.java +4 −5 Original line number Diff line number Diff line Loading @@ -341,6 +341,10 @@ public class AutoclickScrollPanel { }); } public boolean isHovered() { return mContentView.isHovered(); } /** * Retrieves the layout params for AutoclickScrollPanel, used when it's added to the Window * Manager. Loading Loading @@ -368,11 +372,6 @@ public class AutoclickScrollPanel { return mInScrollMode; } @VisibleForTesting public boolean isHovered() { return mContentView.isHovered(); } @VisibleForTesting public AutoclickLinearLayout getContentViewForTesting() { return mContentView; Loading
services/tests/servicestests/src/com/android/server/accessibility/integration/AutoclickClickTypeTests.kt +8 −6 Original line number Diff line number Diff line Loading @@ -201,14 +201,16 @@ class AutoclickClickTypeTests { changeClickType(uiDevice, desktopMouseTestRule, SCROLL_BUTTON_LAYOUT_ID) moveMouseToView(testClickButton) moveMouseToScrollButton(SCROLL_UP_BUTTON_LAYOUT_ID) // Scroll to each button in this order to prevent the exit button from being inadvertently // hovered. moveMouseToScrollButton(SCROLL_RIGHT_BUTTON_LAYOUT_ID) waitAndAssert { testClickButton.text == SCROLL_UP_TEXT testClickButton.text == SCROLL_RIGHT_TEXT } moveMouseToScrollButton(SCROLL_DOWN_BUTTON_LAYOUT_ID) moveMouseToScrollButton(SCROLL_UP_BUTTON_LAYOUT_ID) waitAndAssert { testClickButton.text == SCROLL_DOWN_TEXT testClickButton.text == SCROLL_UP_TEXT } moveMouseToScrollButton(SCROLL_LEFT_BUTTON_LAYOUT_ID) Loading @@ -216,9 +218,9 @@ class AutoclickClickTypeTests { testClickButton.text == SCROLL_LEFT_TEXT } moveMouseToScrollButton(SCROLL_RIGHT_BUTTON_LAYOUT_ID) moveMouseToScrollButton(SCROLL_DOWN_BUTTON_LAYOUT_ID) waitAndAssert { testClickButton.text == SCROLL_RIGHT_TEXT testClickButton.text == SCROLL_DOWN_TEXT } // Close the scroll panel. Loading