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

Commit 2243b671 authored by arthurhung's avatar arthurhung
Browse files

Prevent accidentally click on RecyclerView

Currently, inputflinger would send an ACTION_POINTER_UP event with
AKEY_EVENT_FLAG_CANCELED when we have at least 2 pointers down and
one becomes the accidental touch.

In ViewGroup, if we have FLAG_SPLIT_MOTION_EVENTS, it may split a
multi touch event into some single touch events to the target childs,
so we should also check the cancel flag in order to prevent it trigger
the accidental click on the child view.

Bug: 161655782
Test: enable twoshay, test accidental touch on RecyclerView
Change-Id: Iba864361ca3361e4a720dbe0eb0b39d42a6dc5b2
parent 42991d36
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -476,6 +476,14 @@ public final class MotionEvent extends InputEvent implements Parcelable {
     */
    public static final int FLAG_IS_GENERATED_GESTURE = 0x8;

    /**
     * This flag associated with {@link #ACTION_POINTER_UP}, this indicates that the pointer
     * has been canceled. Typically this is used for palm event when the user has accidental
     * touches.
     * @hide
     */
    public static final int FLAG_CANCELED = 0x20;

    /**
     * Private flag that indicates when the system has detected that this motion event
     * may be inconsistent with respect to the sequence of previously delivered motion events,
@@ -3477,7 +3485,8 @@ public final class MotionEvent extends InputEvent implements Parcelable {
                } else if (newPointerCount == 1) {
                    // The first/last pointer went down/up.
                    newAction = oldActionMasked == ACTION_POINTER_DOWN
                            ? ACTION_DOWN : ACTION_UP;
                            ? ACTION_DOWN
                            : (getFlags() & FLAG_CANCELED) == 0 ? ACTION_UP : ACTION_CANCEL;
                } else {
                    // A secondary pointer went down/up.
                    newAction = oldActionMasked