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

Commit 8e56fe39 authored by Tracy Zhou's avatar Tracy Zhou
Browse files

Allow trackpad to tune RAPID_DECELERATION_FACTOR for gesture nav

- RAPID_DECELERATION_FACTOR determines whether swipe up from app takes the user to overview vs. home

Bug: 355457714
Test: adb shell setprop trackpad_in_app_swipe_up_deceleration_factor 0.6f
Flag: EXEMPT bugfix

Change-Id: I205e72c82dc08b9e542420ca1adc8f7c0eb0953d
parent f93199cb
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch
    private ObjectAnimator mNormalToHintOverviewScrimAnimator;

    private final QuickstepLauncher mLauncher;
    private boolean mIsTrackpadSwipe;

    /**
     * @param cancelSplitRunnable Called when split placeholder view needs to be cancelled.
@@ -106,9 +107,9 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch

    @Override
    protected boolean canInterceptTouch(MotionEvent ev) {
        boolean isTrackpadEvent = isTrackpadMotionEvent(ev);
        mLauncher.setCanShowAllAppsEducationView(!isTrackpadEvent);
        if (!isTrackpadEvent && DisplayController.getNavigationMode(mLauncher)
        mIsTrackpadSwipe = isTrackpadMotionEvent(ev);
        mLauncher.setCanShowAllAppsEducationView(!mIsTrackpadSwipe);
        if (!mIsTrackpadSwipe && DisplayController.getNavigationMode(mLauncher)
                == THREE_BUTTONS) {
            return false;
        }
@@ -152,6 +153,7 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch
        super.onDragStart(start, startDisplacement);

        mMotionPauseDetector.clear();
        mMotionPauseDetector.setIsTrackpadGesture(mIsTrackpadSwipe);

        if (handlingOverviewAnim()) {
            InteractionJankMonitorWrapper.begin(mRecentsView, Cuj.CUJ_LAUNCHER_APP_SWIPE_TO_RECENTS,
@@ -195,6 +197,7 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch
        }

        mMotionPauseDetector.clear();
        mIsTrackpadSwipe = false;
        mNormalToHintOverviewScrimAnimator = null;
        if (mLauncher.isInState(OVERVIEW)) {
            // Normally we would cleanup the state based on mCurrentAnimation, but since we stop
+4 −1
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ public class NoButtonQuickSwitchTouchController implements TouchController,
    private AnimatorPlaybackController mNonOverviewAnim;
    private AnimatorPlaybackController mXOverviewAnim;
    private AnimatedFloat mYOverviewAnim;
    private boolean mIsTrackpadSwipe;

    public NoButtonQuickSwitchTouchController(QuickstepLauncher launcher) {
        mLauncher = launcher;
@@ -177,7 +178,8 @@ public class NoButtonQuickSwitchTouchController implements TouchController,
            return false;
        }
        if (isTrackpadMultiFingerSwipe(ev)) {
            return isTrackpadFourFingerSwipe(ev);
            mIsTrackpadSwipe = isTrackpadFourFingerSwipe(ev);
            return mIsTrackpadSwipe;
        }
        return true;
    }
@@ -185,6 +187,7 @@ public class NoButtonQuickSwitchTouchController implements TouchController,
    @Override
    public void onDragStart(boolean start) {
        mMotionPauseDetector.clear();
        mMotionPauseDetector.setIsTrackpadGesture(mIsTrackpadSwipe);
        if (start) {
            InteractionJankMonitorWrapper.begin(mRecentsView, Cuj.CUJ_LAUNCHER_QUICK_SWITCH);
            InteractionJankMonitorWrapper.begin(mRecentsView, Cuj.CUJ_LAUNCHER_APP_SWIPE_TO_RECENTS,
+1 −0
Original line number Diff line number Diff line
@@ -409,6 +409,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
        mInteractionHandler = mHandlerFactory.newHandler(mGestureState, touchTimeMs);
        mInteractionHandler.setGestureEndCallback(this::onInteractionGestureFinished);
        mMotionPauseDetector.setOnMotionPauseListener(mInteractionHandler.getMotionPauseListener());
        mMotionPauseDetector.setIsTrackpadGesture(mGestureState.isTrackpadGesture());
        mInteractionHandler.initWhenReady(
                "OtherActivityInputConsumer.startTouchTrackingForWindowAnimation");

+14 −1
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ public class MotionPauseDetector {
    private Float mPreviousVelocity = null;

    private OnMotionPauseListener mOnMotionPauseListener;
    private boolean mIsTrackpadGesture;
    private boolean mIsPaused;
    // Bias more for the first pause to make it feel extra responsive.
    private boolean mHasEverBeenPaused;
@@ -115,6 +116,10 @@ public class MotionPauseDetector {
        mOnMotionPauseListener = listener;
    }

    public void setIsTrackpadGesture(boolean isTrackpadGesture) {
        mIsTrackpadGesture = isTrackpadGesture;
    }

    /**
     * @param disallowPause If true, we will not detect any pauses until this is set to false again.
     */
@@ -179,7 +184,8 @@ public class MotionPauseDetector {
                    // We want to be more aggressive about detecting the first pause to ensure it
                    // feels as responsive as possible; getting two very slow speeds back to back
                    // takes too long, so also check for a rapid deceleration.
                    boolean isRapidDeceleration = speed < previousSpeed * RAPID_DECELERATION_FACTOR;
                    boolean isRapidDeceleration =
                            speed < previousSpeed * getRapidDecelerationFactor();
                    isPaused = isRapidDeceleration && speed < mSpeedSomewhatFast;
                    isPausedReason = new ActiveGestureLog.CompoundString(
                            "Didn't have back to back slow speeds, checking for rapid ")
@@ -253,6 +259,7 @@ public class MotionPauseDetector {
        mVelocityProvider.clear();
        mPreviousVelocity = null;
        setOnMotionPauseListener(null);
        mIsTrackpadGesture = false;
        mIsPaused = mHasEverBeenPaused = false;
        mSlowStartTime = 0;
        mForcePauseTimeout.cancelAlarm();
@@ -262,6 +269,12 @@ public class MotionPauseDetector {
        return mIsPaused;
    }

    private float getRapidDecelerationFactor() {
        return mIsTrackpadGesture ? Float.parseFloat(
                Utilities.getSystemProperty("trackpad_in_app_swipe_up_deceleration_factor",
                        String.valueOf(RAPID_DECELERATION_FACTOR))) : RAPID_DECELERATION_FACTOR;
    }

    public interface OnMotionPauseListener {
        /** Called only the first time motion pause is detected. */
        void onMotionPauseDetected();