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

Commit 14749db6 authored by LuK1337's avatar LuK1337
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 ab34bda4
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1216,6 +1216,12 @@ public class KeyEvent extends InputEvent implements Parcelable {
     */
    public static final int FLAG_FALLBACK = 0x400;

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

    /**
     * Signifies that the key is being predispatched.
     * @hide
+2 −2
Original line number Diff line number Diff line
@@ -235,9 +235,9 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa
                @Override
                public void triggerBack(boolean isLongPress) {
                    sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK,
                            isLongPress ? KeyEvent.FLAG_LONG_PRESS : 0);
                            isLongPress ? KeyEvent.FLAG_LONG_SWIPE : 0);
                    sendEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK,
                            isLongPress ? KeyEvent.FLAG_LONG_PRESS : 0);
                            isLongPress ? KeyEvent.FLAG_LONG_SWIPE : 0);

                    mOverviewProxyService.notifyBackAction(true, (int) mDownPoint.x,
                            (int) mDownPoint.y, false /* isButton */, !mIsOnLeftEdge);
+1 −3
Original line number Diff line number Diff line
@@ -719,8 +719,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 LineageHardwareManager mLineageHardware;

@@ -4263,7 +4261,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);