am 73375a57: Added anti-falsing logic to the keyguard.

* commit '73375a57cb9f3b89a3222ab1eca4796158ad5ea6':
  Added anti-falsing logic to the keyguard.
This commit is contained in:
Selim Cinek
2014-08-27 12:52:02 +00:00
committed by Android Git Automerger
9 changed files with 80 additions and 6 deletions

View File

@@ -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>

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -68,6 +68,8 @@ public abstract class PanelView extends FrameLayout {
protected boolean mHintAnimationRunning;
private boolean mOverExpandedBeforeFling;
private float mOriginalIndicationY;
private boolean mTouchAboveFalsingThreshold;
private int mUnlockFalsingThreshold;
private ValueAnimator mHeightAnimator;
private ObjectAnimator mPeekAnimator;
@@ -183,6 +185,7 @@ public abstract class PanelView extends FrameLayout {
mTouchSlop = configuration.getScaledTouchSlop();
mHintDistance = res.getDimension(R.dimen.hint_move_distance);
mEdgeTapAreaWidth = res.getDimensionPixelSize(R.dimen.edge_tap_area_width);
mUnlockFalsingThreshold = res.getDimensionPixelSize(R.dimen.unlock_falsing_threshold);
}
private void trackMovement(MotionEvent event) {
@@ -234,6 +237,7 @@ public abstract class PanelView extends FrameLayout {
mHasLayoutedSinceDown = false;
mUpdateFlingOnLayout = false;
mPeekTouching = mPanelClosedOnDown;
mTouchAboveFalsingThreshold = false;
if (mVelocityTracker == null) {
initVelocityTracker();
}
@@ -298,6 +302,9 @@ public abstract class PanelView extends FrameLayout {
}
mJustPeeked = false;
}
if (-h >= mUnlockFalsingThreshold) {
mTouchAboveFalsingThreshold = true;
}
if (!mJustPeeked && (!waitForTouchSlop || mTracking) && !isTrackingBlocked()) {
setExpandedHeightInternal(newHeight);
}
@@ -399,6 +406,7 @@ public abstract class PanelView extends FrameLayout {
mPanelClosedOnDown = mExpandedHeight == 0.0f;
mHasLayoutedSinceDown = false;
mUpdateFlingOnLayout = false;
mTouchAboveFalsingThreshold = false;
initVelocityTracker();
trackMovement(event);
break;
@@ -471,6 +479,9 @@ public abstract class PanelView extends FrameLayout {
* @return whether a fling should expands the panel; contracts otherwise
*/
protected boolean flingExpands(float vel, float vectorVel) {
if (!mTouchAboveFalsingThreshold && mStatusBar.isFalsingThresholdNeeded()) {
return true;
}
if (Math.abs(vectorVel) < mFlingAnimationUtils.getMinVelocityPxPerSecond()) {
return getExpandedFraction() > 0.5f;
} else {

View File

@@ -686,6 +686,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
mStackScroller = (NotificationStackScrollLayout) mStatusBarWindow.findViewById(
R.id.notification_stack_scroller);
mStackScroller.setLongPressListener(getNotificationLongClicker());
mStackScroller.setPhoneStatusBar(this);
mKeyguardIconOverflowContainer =
(NotificationOverflowContainer) LayoutInflater.from(mContext).inflate(
@@ -2053,6 +2054,12 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
return mNotificationPanel.isQsExpanded();
}
public boolean isFalsingThresholdNeeded() {
boolean onKeyguard = getBarState() == StatusBarState.KEYGUARD;
boolean isMethodInSecure = mUnlockMethodCache.isMethodInsecure();
return onKeyguard && isMethodInSecure;
}
@Override // NotificationData.Environment
public String getCurrentMediaNotificationKey() {
return mMediaNotificationKey;

View File

@@ -300,6 +300,11 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper.
return true;
}
@Override
public boolean isAntiFalsingNeeded() {
return false;
}
@Override
public void onChildDismissed(View v) {
Log.v(TAG, "User swiped heads up to dismiss");

View File

@@ -40,6 +40,7 @@ import com.android.systemui.statusbar.EmptyShadeView;
import com.android.systemui.statusbar.ExpandableNotificationRow;
import com.android.systemui.statusbar.ExpandableView;
import com.android.systemui.statusbar.SpeedBumpView;
import com.android.systemui.statusbar.phone.PhoneStatusBar;
import com.android.systemui.statusbar.policy.ScrollAdapter;
import com.android.systemui.statusbar.stack.StackScrollState.ViewState;
@@ -195,6 +196,7 @@ public class NotificationStackScrollLayout extends ViewGroup
return true;
}
};
private PhoneStatusBar mPhoneStatusBar;
public NotificationStackScrollLayout(Context context) {
this(context, null);
@@ -640,6 +642,11 @@ public class NotificationStackScrollLayout extends ViewGroup
return (veto != null && veto.getVisibility() != View.GONE);
}
@Override
public boolean isAntiFalsingNeeded() {
return mPhoneStatusBar.isFalsingThresholdNeeded();
}
private void setSwipingInProgress(boolean isSwiped) {
mSwipingInProgress = isSwiped;
if(isSwiped) {
@@ -2185,6 +2192,10 @@ public class NotificationStackScrollLayout extends ViewGroup
mStackScrollAlgorithm.updateIsSmallScreen(mMaxLayoutHeight - qsMinHeight);
}
public void setPhoneStatusBar(PhoneStatusBar phoneStatusBar) {
this.mPhoneStatusBar = phoneStatusBar;
}
/**
* A listener that is notified when some child locations might have changed.
*/