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

Commit ed520466 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou Committed by Android (Google) Code Review
Browse files

Merge "Add FLAG_CANCELED to synthesized MotionEvents" into main

parents f128fe77 6cc94de8
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -2197,6 +2197,9 @@ public final class MotionEvent extends InputEvent implements Parcelable {
            float xOffset, float yOffset, float xPrecision, float yPrecision,
            long downTimeNanos, long eventTimeNanos,
            int pointerCount, PointerProperties[] pointerIds, PointerCoords[] pointerCoords) {
        if (action == ACTION_CANCEL) {
            flags |= FLAG_CANCELED;
        }
        mNativePtr = nativeInitialize(mNativePtr, deviceId, source, displayId, action, flags,
                edgeFlags, metaState, buttonState, classification, xOffset, yOffset,
                xPrecision, yPrecision, downTimeNanos, eventTimeNanos, pointerCount, pointerIds,
@@ -2387,6 +2390,11 @@ public final class MotionEvent extends InputEvent implements Parcelable {
        nativeSetFlags(mNativePtr, tainted ? flags | FLAG_TAINTED : flags & ~FLAG_TAINTED);
    }

    private void setCanceled(boolean canceled) {
        final int flags = getFlags();
        nativeSetFlags(mNativePtr, canceled ? flags | FLAG_CANCELED : flags & ~FLAG_CANCELED);
    }

    /** @hide */
    public  boolean isTargetAccessibilityFocus() {
        final int flags = getFlags();
@@ -3510,6 +3518,14 @@ public final class MotionEvent extends InputEvent implements Parcelable {
     * Sets this event's action.
     */
    public final void setAction(int action) {
        final int actionMasked = action & ACTION_MASK;
        if (actionMasked == ACTION_CANCEL) {
            setCanceled(true);
        } else if (actionMasked == ACTION_POINTER_UP) {
            // Do nothing - we don't know what the real intent here is
        } else {
            setCanceled(false);
        }
        nativeSetAction(mNativePtr, action);
    }

@@ -4157,6 +4173,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
    /** @hide */
    @Override
    public final void cancel() {
        setCanceled(true);
        setAction(ACTION_CANCEL);
    }