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

Commit 0024f732 authored by Sally's avatar Sally Committed by Sally Yuen
Browse files

Align autoclick click with standard clicks

Add PRESS and RELEASE events, which are found in standard clicks.
Chrome uses these to route clicks

Stream of events: https://paste.googleplex.com/5555561329328128#

Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1173686
Test: Manual. Chrome auto-click works. Firefox and Samsung Browser remain working.
Change-Id: I8c42ea744d46f8783f148b5239b55bda4efa0115
parent 719079be
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -433,13 +433,28 @@ public class AutoclickController extends BaseEventStreamTransformation {
                    MotionEvent.BUTTON_PRIMARY, 1.0f, 1.0f, mLastMotionEvent.getDeviceId(), 0,
                    mLastMotionEvent.getSource(), mLastMotionEvent.getFlags());

            // The only real difference between these two events is the action flag.
            MotionEvent pressEvent = MotionEvent.obtain(downEvent);
            pressEvent.setAction(MotionEvent.ACTION_BUTTON_PRESS);
            pressEvent.setActionButton(MotionEvent.BUTTON_PRIMARY);

            MotionEvent releaseEvent = MotionEvent.obtain(downEvent);
            releaseEvent.setAction(MotionEvent.ACTION_BUTTON_RELEASE);
            releaseEvent.setActionButton(MotionEvent.BUTTON_PRIMARY);
            releaseEvent.setButtonState(0);

            MotionEvent upEvent = MotionEvent.obtain(downEvent);
            upEvent.setAction(MotionEvent.ACTION_UP);
            upEvent.setButtonState(0);

            AutoclickController.super.onMotionEvent(downEvent, downEvent, mEventPolicyFlags);
            downEvent.recycle();

            AutoclickController.super.onMotionEvent(pressEvent, pressEvent, mEventPolicyFlags);
            pressEvent.recycle();

            AutoclickController.super.onMotionEvent(releaseEvent, releaseEvent, mEventPolicyFlags);
            releaseEvent.recycle();

            AutoclickController.super.onMotionEvent(upEvent, upEvent, mEventPolicyFlags);
            upEvent.recycle();
        }