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

Commit e228e74e authored by LuK1337's avatar LuK1337 Committed by Bruno Martins
Browse files

Use custom flag for edge long swipe gesture

Previously we were using same flags that'd be used for regular back key
long press thus being unable to determine whether the event was sent
from EdgeBackGestureHandle or not.

Fixes: https://gitlab.com/LineageOS/issues/android/-/issues/4194
Change-Id: I5c4fd455f581ac5c9c5e3a146095be33e82e8d6e
parent 4d8a4e34
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1212,6 +1212,12 @@ public class KeyEvent extends InputEvent implements Parcelable {
     */
    public static final int FLAG_TRACKING = 0x200;

    /**
     * Private flag that indicates that event was sent from EdgeBackGestureHandler.
     * @hide
     */
    public static final int FLAG_LONG_SWIPE = 0x800;

    /**
     * Set when a key event has been synthesized to implement default behavior
     * for an event that the application did not handle.
+2 −2
Original line number Diff line number Diff line
@@ -276,9 +276,9 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
                    // TODO(b/186519446): use a different method than isFalseTouch
                    mFalsingManager.isFalseTouch(BACK_GESTURE);
                    boolean sendDown = sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK,
                            isLongPress ? KeyEvent.FLAG_LONG_PRESS : 0);
                            isLongPress ? KeyEvent.FLAG_LONG_SWIPE : 0);
                    boolean sendUp = sendEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK,
                            isLongPress ? KeyEvent.FLAG_LONG_PRESS : 0);
                            isLongPress ? KeyEvent.FLAG_LONG_SWIPE : 0);
                    if (DEBUG_MISSING_GESTURE) {
                        Log.d(DEBUG_MISSING_GESTURE_TAG, "Triggered back: down=" + sendDown
                                + ", up=" + sendUp);
+1 −3
Original line number Diff line number Diff line
@@ -692,8 +692,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    private PendingIntent mTorchOffPendingIntent;

    private boolean mLongSwipeDown;
    private static final int LONG_SWIPE_FLAGS = KeyEvent.FLAG_LONG_PRESS
            | KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY;

    private class PolicyHandler extends Handler {
        @Override
@@ -4025,7 +4023,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        // Handle special keys.
        switch (keyCode) {
            case KeyEvent.KEYCODE_BACK: {
                boolean isLongSwipe = (event.getFlags() & LONG_SWIPE_FLAGS) == LONG_SWIPE_FLAGS;
                boolean isLongSwipe = (event.getFlags() & KeyEvent.FLAG_LONG_SWIPE) != 0;
                if (mLongSwipeDown && isLongSwipe && !down) {
                    // Trigger long swipe action
                    performKeyAction(mEdgeLongSwipeAction, event);