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

Unverified Commit 48cfa12b authored by LuK1337's avatar LuK1337 Committed by Michael Bestas
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 c64f7f40
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -1212,6 +1212,12 @@ public class KeyEvent extends InputEvent implements Parcelable {
     */
     */
    public static final int FLAG_TRACKING = 0x200;
    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
     * Set when a key event has been synthesized to implement default behavior
     * for an event that the application did not handle.
     * for an event that the application did not handle.
+2 −2
Original line number Original line Diff line number Diff line
@@ -277,9 +277,9 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
                    // TODO(b/186519446): use a different method than isFalseTouch
                    // TODO(b/186519446): use a different method than isFalseTouch
                    mFalsingManager.isFalseTouch(BACK_GESTURE);
                    mFalsingManager.isFalseTouch(BACK_GESTURE);
                    boolean sendDown = sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK,
                    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,
                    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) {
                    if (DEBUG_MISSING_GESTURE) {
                        Log.d(DEBUG_MISSING_GESTURE_TAG, "Triggered back: down=" + sendDown
                        Log.d(DEBUG_MISSING_GESTURE_TAG, "Triggered back: down=" + sendDown
                                + ", up=" + sendUp);
                                + ", up=" + sendUp);
+1 −3
Original line number Original line Diff line number Diff line
@@ -689,8 +689,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    private PendingIntent mTorchOffPendingIntent;
    private PendingIntent mTorchOffPendingIntent;


    private boolean mLongSwipeDown;
    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 {
    private class PolicyHandler extends Handler {
        @Override
        @Override
@@ -4019,7 +4017,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        // Handle special keys.
        // Handle special keys.
        switch (keyCode) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_BACK: {
            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) {
                if (mLongSwipeDown && isLongSwipe && !down) {
                    // Trigger long swipe action
                    // Trigger long swipe action
                    performKeyAction(mEdgeLongSwipeAction, event);
                    performKeyAction(mEdgeLongSwipeAction, event);