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

Commit 69533eef authored by Gavin Williams's avatar Gavin Williams
Browse files

Autoclick: Fix autoclick dragging

The ACTION_BUTTON_RELEASE and ACTION_UP event had incorrect button
settings so releasing the drag would fail.

Bug: 439772505
Test: AutoclickControllerTest
Flag: com.android.server.accessibility.enable_autoclick_indicator
Change-Id: I7feb65686ff353d8a579e884f824b9b384263770
parent 65388286
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -1629,15 +1629,15 @@ public class AutoclickController extends BaseEventStreamTransformation implement
                            mTempPointerProperties,
                            mTempPointerProperties,
                            mTempPointerCoords,
                            mTempPointerCoords,
                            mMetaState,
                            mMetaState,
                            BUTTON_PRIMARY,
                            /* buttonState= */ 0,
                            /* xPrecision= */ 1.0f,
                            /* xPrecision= */ 1.0f,
                            /* yPrecision= */ 1.0f,
                            /* yPrecision= */ 1.0f,
                            mLastMotionEvent.getDeviceId(),
                            mLastMotionEvent.getDeviceId(),
                            /* edgeFlags= */ 0,
                            /* edgeFlags= */ 0,
                            mLastMotionEvent.getSource(),
                            mLastMotionEvent.getSource(),
                            mLastMotionEvent.getFlags());
                            mLastMotionEvent.getFlags());
            releaseEvent.setActionButton(BUTTON_PRIMARY);
            MotionEvent upEvent = MotionEvent.obtain(releaseEvent);
            MotionEvent upEvent = MotionEvent.obtain(releaseEvent);
            releaseEvent.setActionButton(BUTTON_PRIMARY);
            upEvent.setAction(MotionEvent.ACTION_UP);
            upEvent.setAction(MotionEvent.ACTION_UP);
            AutoclickController.super.onMotionEvent(releaseEvent, releaseEvent,
            AutoclickController.super.onMotionEvent(releaseEvent, releaseEvent,
                    mEventPolicyFlags);
                    mEventPolicyFlags);
+7 −0
Original line number Original line Diff line number Diff line
@@ -1235,6 +1235,13 @@ public class AutoclickControllerTest {
        assertThat(mMotionEventCaptor.upEvent).isNotNull();
        assertThat(mMotionEventCaptor.upEvent).isNotNull();
        assertThat(mMotionEventCaptor.upEvent.getDownTime()).isEqualTo(
        assertThat(mMotionEventCaptor.upEvent.getDownTime()).isEqualTo(
                mMotionEventCaptor.downEvent.getDownTime());
                mMotionEventCaptor.downEvent.getDownTime());

        // Verify the button release & up event have the correct click parameters.
        assertThat(mMotionEventCaptor.buttonReleaseEvent.getActionButton()).isEqualTo(
                MotionEvent.BUTTON_PRIMARY);
        assertThat(mMotionEventCaptor.buttonReleaseEvent.getButtonState()).isEqualTo(0);
        assertThat(mMotionEventCaptor.upEvent.getActionButton()).isEqualTo(0);
        assertThat(mMotionEventCaptor.upEvent.getButtonState()).isEqualTo(0);
    }
    }