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

Commit e6b43c86 authored by Andy Wickham's avatar Andy Wickham Committed by Android (Google) Code Review
Browse files

Merge "Invert the 2 stage LPNH logic to lower false positive triggers." into main

parents 45b5acef 17533ace
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -64,11 +64,19 @@ class DeviceConfigWrapper private constructor(propReader: PropReader) {
            "Enable two stage for LPNH duration and touch slop"
        )

    val twoStageMultiplier =
    val twoStageDurationPercentage =
        propReader.get(
            "TWO_STAGE_MULTIPLIER",
            2,
            "Extends the duration and touch slop if the initial slop is passed"
            "TWO_STAGE_DURATION_PERCENTAGE",
            200,
            "Extends the duration to trigger a long press after a fraction of the gesture " +
                "slop is passed, expressed as a percentage (i.e. 200 = 2x)."
        )

    val twoStageSlopPercentage =
        propReader.get(
            "TWO_STAGE_SLOP_PERCENTAGE",
            50,
            "Percentage of gesture slop region to trigger the extended long press duration."
        )

    val animateLpnh = propReader.get("ANIMATE_LPNH", false, "Animates navbar when long pressing")
+20 −5
Original line number Diff line number Diff line
@@ -73,17 +73,32 @@ public class NavHandleLongPressInputConsumer extends DelegateInputConsumer {
        super(delegate, inputMonitor);
        mScreenWidth = DisplayController.INSTANCE.get(context).getInfo().currentSize.x;
        mDeepPressEnabled = DeviceConfigWrapper.get().getEnableLpnhDeepPress();
        int twoStageMultiplier = DeviceConfigWrapper.get().getTwoStageMultiplier();
        AssistStateManager assistStateManager = AssistStateManager.INSTANCE.get(context);
        if (assistStateManager.getLPNHDurationMillis().isPresent()) {
            mLongPressTimeout = assistStateManager.getLPNHDurationMillis().get().intValue();
        } else {
            mLongPressTimeout = ViewConfiguration.getLongPressTimeout();
        }
        mOuterLongPressTimeout = mLongPressTimeout * twoStageMultiplier;
        mTouchSlopSquaredOriginal = deviceState.getSquaredTouchSlop();
        mTouchSlopSquared = mTouchSlopSquaredOriginal;
        mOuterTouchSlopSquared = mTouchSlopSquared * (twoStageMultiplier * twoStageMultiplier);
        float twoStageDurationMultiplier =
                (DeviceConfigWrapper.get().getTwoStageDurationPercentage() / 100f);
        mOuterLongPressTimeout = (int) (mLongPressTimeout * twoStageDurationMultiplier);

        float gestureNavTouchSlopSquared = deviceState.getSquaredTouchSlop();
        float twoStageSlopMultiplier =
                (DeviceConfigWrapper.get().getTwoStageSlopPercentage() / 100f);
        float twoStageSlopMultiplierSquared = twoStageSlopMultiplier * twoStageSlopMultiplier;
        if (DeviceConfigWrapper.get().getEnableLpnhTwoStages()) {
            // For 2 stages, the outer touch slop should match gesture nav.
            mTouchSlopSquared = gestureNavTouchSlopSquared * twoStageSlopMultiplierSquared;
            mOuterTouchSlopSquared = gestureNavTouchSlopSquared;
        } else {
            // For single stage, the touch slop should match gesture nav.
            mTouchSlopSquared = gestureNavTouchSlopSquared;
            // Note: This outer slop is not actually used for single-stage (flag disabled).
            mOuterTouchSlopSquared = gestureNavTouchSlopSquared;
        }
        mTouchSlopSquaredOriginal = mTouchSlopSquared;

        mGestureState = gestureState;
        mGestureState.setIsInExtendedSlopRegion(false);
        if (DEBUG_NAV_HANDLE) {