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

Commit eb9c2875 authored by Chun-Ku Lin's avatar Chun-Ku Lin Committed by Android (Google) Code Review
Browse files

Merge "autoclick: Reset click type to left click if necessary when exiting scroll mode" into main

parents 5575f8f2 d7ebdd50
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -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) {
@@ -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();
            }
        }
+32 −0
Original line number Diff line number Diff line
@@ -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() {