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

Commit 19c8c708 authored by Selim Cinek's avatar Selim Cinek
Browse files

Added anti-falsing logic to the keyguard.

Newly enforcing a threshold for the following cases:
Unlocking, Dismissing Notifications, Swiping Down Quick settings.
Also increased the affordance threshold slightly.

Bug: 15433087
Change-Id: I723346dedf9ae0e3f8b103182992ab572fc394b9
parent 473119fd
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -278,8 +278,14 @@
    <!-- The height of the speed bump view. -->
    <dimen name="speed_bump_height">16dp</dimen>

    <!-- Lockscreen affordance drag distance for camera and phone. -->
    <dimen name="affordance_drag_distance">100dp</dimen>
    <!-- Lockscreen unlocking falsing threshold. -->
    <dimen name="unlock_falsing_threshold">100dp</dimen>

    <!-- Lockscreen falsing threshold for quick settings. -->
    <dimen name="qs_falsing_threshold">60dp</dimen>

    <!-- Falsing threshold used when dismissing notifications from the lockscreen. -->
    <dimen name="swipe_helper_falsing_threshold">100dp</dimen>

    <dimen name="notifications_top_padding">8dp</dimen>
    
@@ -299,7 +305,7 @@
    <dimen name="heads_up_window_height">250dp</dimen>

    <!-- The minimum amount the user needs to swipe to go to the camera / phone. -->
    <dimen name="keyguard_min_swipe_amount">75dp</dimen>
    <dimen name="keyguard_min_swipe_amount">85dp</dimen>

    <!-- The minimum background radius when swiping to a side for the camera / phone affordances. -->
    <dimen name="keyguard_affordance_min_background_radius">30dp</dimen>
+16 −3
Original line number Diff line number Diff line
@@ -81,6 +81,8 @@ public class SwipeHelper implements Gefingerpoken {
    private long mLongPressTimeout;

    final private int[] mTmpPos = new int[2];
    private int mFalsingThreshold;
    private boolean mTouchAboveFalsingThreshold;

    public SwipeHelper(int swipeDirection, Callback callback, Context context) {
        mCallback = callback;
@@ -93,6 +95,8 @@ public class SwipeHelper implements Gefingerpoken {
        mLongPressTimeout = (long) (ViewConfiguration.getLongPressTimeout() * 1.5f); // extra long-press!
        mFastOutLinearInInterpolator = AnimationUtils.loadInterpolator(context,
                android.R.interpolator.fast_out_linear_in);
        mFalsingThreshold = context.getResources().getDimensionPixelSize(
                R.dimen.swipe_helper_falsing_threshold);
    }

    public void setLongPressListener(LongPressListener listener) {
@@ -222,6 +226,7 @@ public class SwipeHelper implements Gefingerpoken {

        switch (action) {
            case MotionEvent.ACTION_DOWN:
                mTouchAboveFalsingThreshold = false;
                mDragging = false;
                mLongPressSent = false;
                mCurrView = mCallback.getChildAtPosition(ev);
@@ -406,12 +411,16 @@ public class SwipeHelper implements Gefingerpoken {
            case MotionEvent.ACTION_MOVE:
                if (mCurrView != null) {
                    float delta = getPos(ev) - mInitialTouchPos;
                    float absDelta = Math.abs(delta);
                    if (absDelta >= mFalsingThreshold) {
                        mTouchAboveFalsingThreshold = true;
                    }
                    // don't let items that can't be dismissed be dragged more than
                    // maxScrollDistance
                    if (CONSTRAIN_SWIPE && !mCallback.canChildBeDismissed(mCurrView)) {
                        float size = getSize(mCurrAnimView);
                        float maxScrollDistance = 0.15f * size;
                        if (Math.abs(delta) >= size) {
                        if (absDelta >= size) {
                            delta = delta > 0 ? maxScrollDistance : -maxScrollDistance;
                        } else {
                            delta = maxScrollDistance * (float) Math.sin((delta/size)*(Math.PI/2));
@@ -437,9 +446,11 @@ public class SwipeHelper implements Gefingerpoken {
                    boolean childSwipedFastEnough = (Math.abs(velocity) > escapeVelocity) &&
                            (Math.abs(velocity) > Math.abs(perpendicularVelocity)) &&
                            (velocity > 0) == (getTranslation(mCurrAnimView) > 0);
                    boolean falsingDetected = mCallback.isAntiFalsingNeeded()
                            && !mTouchAboveFalsingThreshold;

                    boolean dismissChild = mCallback.canChildBeDismissed(mCurrView) &&
                            (childSwipedFastEnough || childSwipedFarEnough);
                    boolean dismissChild = mCallback.canChildBeDismissed(mCurrView)
                            && !falsingDetected && (childSwipedFastEnough || childSwipedFarEnough);

                    if (dismissChild) {
                        // flingadingy
@@ -462,6 +473,8 @@ public class SwipeHelper implements Gefingerpoken {

        boolean canChildBeDismissed(View v);

        boolean isAntiFalsingNeeded();

        void onBeginDrag(View v);

        void onChildDismissed(View v);
+5 −0
Original line number Diff line number Diff line
@@ -191,6 +191,11 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView
        return true;
    }

    @Override
    public boolean isAntiFalsingNeeded() {
        return false;
    }

    public void dismissChild(View v) {
        mSwipeHelper.dismissChild(v, 0);
    }
+5 −0
Original line number Diff line number Diff line
@@ -199,6 +199,11 @@ public class RecentsVerticalScrollView extends ScrollView
        return true;
    }

    @Override
    public boolean isAntiFalsingNeeded() {
        return false;
    }

    public void dismissChild(View v) {
        mSwipeHelper.dismissChild(v, 0);
    }
+11 −0
Original line number Diff line number Diff line
@@ -160,6 +160,8 @@ public class NotificationPanelView extends PanelView implements

    private boolean mQsScrimEnabled = true;
    private boolean mLastAnnouncementWasQuickSettings;
    private boolean mQsTouchAboveFalsingThreshold;
    private int mQsFalsingThreshold;

    public NotificationPanelView(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -230,6 +232,8 @@ public class NotificationPanelView extends PanelView implements
        mClockPositionAlgorithm.loadDimens(getResources());
        mNotificationScrimWaitDistance =
                getResources().getDimensionPixelSize(R.dimen.notification_scrim_wait_distance);
        mQsFalsingThreshold = getResources().getDimensionPixelSize(
                R.dimen.qs_falsing_threshold);
    }

    public void updateResources() {
@@ -526,6 +530,7 @@ public class NotificationPanelView extends PanelView implements
    private void resetDownStates(MotionEvent event) {
        if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
            mOnlyAffordanceInThisMotion = false;
            mQsTouchAboveFalsingThreshold = mQsFullyExpanded;
        }
    }

@@ -546,6 +551,9 @@ public class NotificationPanelView extends PanelView implements
    }

    private boolean flingExpandsQs(float vel) {
        if (!mQsTouchAboveFalsingThreshold && mStatusBarState == StatusBarState.KEYGUARD) {
            return false;
        }
        if (Math.abs(vel) < mFlingAnimationUtils.getMinVelocityPxPerSecond()) {
            return getQsExpansionFraction() > 0.5f;
        } else {
@@ -690,6 +698,9 @@ public class NotificationPanelView extends PanelView implements
            case MotionEvent.ACTION_MOVE:
                final float h = y - mInitialTouchY;
                setQsExpansion(h + mInitialHeightOnTouch);
                if (h >= mQsFalsingThreshold) {
                    mQsTouchAboveFalsingThreshold = true;
                }
                trackMovement(event);
                break;

Loading