Loading services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java +10 −2 Original line number Diff line number Diff line Loading @@ -478,6 +478,11 @@ public class AutoclickController extends BaseEventStreamTransformation { mAutoclickScrollPanel.hide(); } stopContinuousScroll(); // Reset click type to left click if necessary. if (mClickScheduler != null) { mClickScheduler.resetSelectedClickTypeIfNecessary(); } } private void startContinuousScroll(@AutoclickScrollPanel.ScrollDirection int direction) { Loading Loading @@ -846,10 +851,13 @@ public class AutoclickController extends BaseEventStreamTransformation { sendClick(); resetInternalState(); // If the user is currently dragging, do not reset their click type. boolean stillDragging = mActiveClickType == AUTOCLICK_TYPE_DRAG && mDragModeIsDragging; if (!stillDragging) { boolean inScrollMode = mActiveClickType == AUTOCLICK_TYPE_SCROLL && mAutoclickScrollPanel != null && mAutoclickScrollPanel.isVisible(); // Only reset if the user is not dragging and is not in scroll mode. if (!stillDragging && !inScrollMode) { resetSelectedClickTypeIfNecessary(); } } Loading services/tests/servicestests/src/com/android/server/accessibility/autoclick/AutoclickControllerTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -1208,6 +1208,38 @@ public class AutoclickControllerTest { verify(mockAutoclickTypePanel, Mockito.never()).resetSelectedClickType(); } @Test @EnableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_AUTOCLICK_INDICATOR) public void exitScrollMode_revertToLeftClickEnabled_resetsClickType() { initializeAutoclick(); // Set ACCESSIBILITY_AUTOCLICK_REVERT_TO_LEFT_CLICK to true. Settings.Secure.putIntForUser(mTestableContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_AUTOCLICK_REVERT_TO_LEFT_CLICK, AccessibilityUtils.State.ON, mTestableContext.getUserId()); mController.onChangeForTesting(/* selfChange= */ true, Settings.Secure.getUriFor( Settings.Secure.ACCESSIBILITY_AUTOCLICK_REVERT_TO_LEFT_CLICK)); // Set click type to scroll. AutoclickTypePanel mockAutoclickTypePanel = mock(AutoclickTypePanel.class); mController.mAutoclickTypePanel = mockAutoclickTypePanel; mController.clickPanelController.handleAutoclickTypeChange( AutoclickTypePanel.AUTOCLICK_TYPE_SCROLL); // Show the scroll panel. AutoclickScrollPanel mockScrollPanel = mock(AutoclickScrollPanel.class); when(mockScrollPanel.isVisible()).thenReturn(true); mController.mAutoclickScrollPanel = mockScrollPanel; // Exit scroll mode. mController.exitScrollMode(); // Verify click type is reset when exiting scroll mode. verify(mockAutoclickTypePanel).resetSelectedClickType(); } @Test @EnableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_AUTOCLICK_INDICATOR) public void sendClick_clickType_longPress_triggerPressAndHold() { Loading Loading
services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickController.java +10 −2 Original line number Diff line number Diff line Loading @@ -478,6 +478,11 @@ public class AutoclickController extends BaseEventStreamTransformation { mAutoclickScrollPanel.hide(); } stopContinuousScroll(); // Reset click type to left click if necessary. if (mClickScheduler != null) { mClickScheduler.resetSelectedClickTypeIfNecessary(); } } private void startContinuousScroll(@AutoclickScrollPanel.ScrollDirection int direction) { Loading Loading @@ -846,10 +851,13 @@ public class AutoclickController extends BaseEventStreamTransformation { sendClick(); resetInternalState(); // If the user is currently dragging, do not reset their click type. boolean stillDragging = mActiveClickType == AUTOCLICK_TYPE_DRAG && mDragModeIsDragging; if (!stillDragging) { boolean inScrollMode = mActiveClickType == AUTOCLICK_TYPE_SCROLL && mAutoclickScrollPanel != null && mAutoclickScrollPanel.isVisible(); // Only reset if the user is not dragging and is not in scroll mode. if (!stillDragging && !inScrollMode) { resetSelectedClickTypeIfNecessary(); } } Loading
services/tests/servicestests/src/com/android/server/accessibility/autoclick/AutoclickControllerTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -1208,6 +1208,38 @@ public class AutoclickControllerTest { verify(mockAutoclickTypePanel, Mockito.never()).resetSelectedClickType(); } @Test @EnableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_AUTOCLICK_INDICATOR) public void exitScrollMode_revertToLeftClickEnabled_resetsClickType() { initializeAutoclick(); // Set ACCESSIBILITY_AUTOCLICK_REVERT_TO_LEFT_CLICK to true. Settings.Secure.putIntForUser(mTestableContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_AUTOCLICK_REVERT_TO_LEFT_CLICK, AccessibilityUtils.State.ON, mTestableContext.getUserId()); mController.onChangeForTesting(/* selfChange= */ true, Settings.Secure.getUriFor( Settings.Secure.ACCESSIBILITY_AUTOCLICK_REVERT_TO_LEFT_CLICK)); // Set click type to scroll. AutoclickTypePanel mockAutoclickTypePanel = mock(AutoclickTypePanel.class); mController.mAutoclickTypePanel = mockAutoclickTypePanel; mController.clickPanelController.handleAutoclickTypeChange( AutoclickTypePanel.AUTOCLICK_TYPE_SCROLL); // Show the scroll panel. AutoclickScrollPanel mockScrollPanel = mock(AutoclickScrollPanel.class); when(mockScrollPanel.isVisible()).thenReturn(true); mController.mAutoclickScrollPanel = mockScrollPanel; // Exit scroll mode. mController.exitScrollMode(); // Verify click type is reset when exiting scroll mode. verify(mockAutoclickTypePanel).resetSelectedClickType(); } @Test @EnableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_AUTOCLICK_INDICATOR) public void sendClick_clickType_longPress_triggerPressAndHold() { Loading