Merge "Integration into other unlock mechanisms"
This commit is contained in:
committed by
Android (Google) Code Review
commit
c8433b60a7
@@ -34,6 +34,8 @@ import android.view.animation.AnimationUtils;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
|
||||
import com.android.systemui.classifier.FalsingManager;
|
||||
|
||||
public class SwipeHelper implements Gefingerpoken {
|
||||
static final String TAG = "com.android.systemui.SwipeHelper";
|
||||
private static final boolean DEBUG = false;
|
||||
@@ -67,6 +69,7 @@ public class SwipeHelper implements Gefingerpoken {
|
||||
private Handler mHandler;
|
||||
private int mSwipeDirection;
|
||||
private VelocityTracker mVelocityTracker;
|
||||
private FalsingManager mFalsingManager;
|
||||
|
||||
private float mInitialTouchPos;
|
||||
private boolean mDragging;
|
||||
@@ -97,6 +100,7 @@ public class SwipeHelper implements Gefingerpoken {
|
||||
android.R.interpolator.fast_out_linear_in);
|
||||
mFalsingThreshold = context.getResources().getDimensionPixelSize(
|
||||
R.dimen.swipe_helper_falsing_threshold);
|
||||
mFalsingManager = FalsingManager.getInstance(context);
|
||||
}
|
||||
|
||||
public void setLongPressListener(LongPressListener listener) {
|
||||
@@ -449,8 +453,13 @@ 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 falsingDetected = mCallback.isAntiFalsingNeeded();
|
||||
|
||||
if (mFalsingManager.isClassiferEnabled()) {
|
||||
falsingDetected = falsingDetected && mFalsingManager.isFalseTouch();
|
||||
} else {
|
||||
falsingDetected = falsingDetected && !mTouchAboveFalsingThreshold;
|
||||
}
|
||||
|
||||
boolean dismissChild = mCallback.canChildBeDismissed(mCurrView)
|
||||
&& !falsingDetected && (childSwipedFastEnough || childSwipedFarEnough)
|
||||
|
||||
@@ -39,7 +39,11 @@ import com.android.systemui.statusbar.StatusBarState;
|
||||
public class FalsingManager implements SensorEventListener {
|
||||
private static final String ENFORCE_BOUNCER = "falsing_manager_enforce_bouncer";
|
||||
|
||||
private static final int[] SENSORS = new int[] {
|
||||
private static final int[] CLASSIFIER_SENSORS = new int[] {
|
||||
Sensor.TYPE_PROXIMITY,
|
||||
};
|
||||
|
||||
private static final int[] COLLECTOR_SENSORS = new int[] {
|
||||
Sensor.TYPE_ACCELEROMETER,
|
||||
Sensor.TYPE_GYROSCOPE,
|
||||
Sensor.TYPE_PROXIMITY,
|
||||
@@ -113,7 +117,17 @@ public class FalsingManager implements SensorEventListener {
|
||||
private void onSessionStart() {
|
||||
mBouncerOn = false;
|
||||
mSessionActive = true;
|
||||
for (int sensorType : SENSORS) {
|
||||
|
||||
if (mHumanInteractionClassifier.isEnabled()) {
|
||||
registerSensors(CLASSIFIER_SENSORS);
|
||||
}
|
||||
if (mDataCollector.isEnabled()) {
|
||||
registerSensors(COLLECTOR_SENSORS);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerSensors(int [] sensors) {
|
||||
for (int sensorType : sensors) {
|
||||
Sensor s = mSensorManager.getDefaultSensor(sensorType);
|
||||
if (s != null) {
|
||||
mSensorManager.registerListener(this, s, SensorManager.SENSOR_DELAY_GAME);
|
||||
@@ -121,6 +135,10 @@ public class FalsingManager implements SensorEventListener {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isClassiferEnabled() {
|
||||
return mHumanInteractionClassifier.isEnabled();
|
||||
}
|
||||
|
||||
private boolean isEnabled() {
|
||||
return mHumanInteractionClassifier.isEnabled() || mDataCollector.isEnabled();
|
||||
}
|
||||
|
||||
@@ -149,7 +149,10 @@ public class HumanInteractionClassifier extends Classifier {
|
||||
}
|
||||
|
||||
public boolean isFalseTouch() {
|
||||
return mHistoryEvaluator.getEvaluation() >= 5.0f;
|
||||
if (mEnableClassifier) {
|
||||
return mHistoryEvaluator.getEvaluation() >= 5.0f;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
|
||||
@@ -130,7 +130,7 @@ public class DragDownHelper implements Gefingerpoken {
|
||||
}
|
||||
return true;
|
||||
case MotionEvent.ACTION_UP:
|
||||
if (mDraggedFarEnough && mDragDownCallback.onDraggedDown(mStartingChild,
|
||||
if (!isFalseTouch() && mDragDownCallback.onDraggedDown(mStartingChild,
|
||||
(int) (y - mInitialTouchY))) {
|
||||
if (mStartingChild == null) {
|
||||
mDragDownCallback.setEmptyDragAmount(0f);
|
||||
@@ -148,6 +148,13 @@ public class DragDownHelper implements Gefingerpoken {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isFalseTouch() {
|
||||
if (mFalsingManager.isClassiferEnabled()) {
|
||||
return mFalsingManager.isFalseTouch();
|
||||
}
|
||||
return !mDraggedFarEnough;
|
||||
}
|
||||
|
||||
private void captureStartingChild(float x, float y) {
|
||||
if (mStartingChild == null) {
|
||||
mStartingChild = findView(x, y);
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.view.animation.AnimationUtils;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.classifier.FalsingManager;
|
||||
import com.android.systemui.statusbar.FlingAnimationUtils;
|
||||
import com.android.systemui.statusbar.KeyguardAffordanceView;
|
||||
|
||||
@@ -62,6 +63,7 @@ public class KeyguardAffordanceHelper {
|
||||
private Interpolator mAppearInterpolator;
|
||||
private Interpolator mDisappearInterpolator;
|
||||
private Animator mSwipeAnimator;
|
||||
private FalsingManager mFalsingManager;
|
||||
private int mMinBackgroundRadius;
|
||||
private boolean mMotionCancelled;
|
||||
private int mTouchTargetSize;
|
||||
@@ -109,6 +111,7 @@ public class KeyguardAffordanceHelper {
|
||||
android.R.interpolator.linear_out_slow_in);
|
||||
mDisappearInterpolator = AnimationUtils.loadInterpolator(mContext,
|
||||
android.R.interpolator.fast_out_linear_in);
|
||||
mFalsingManager = FalsingManager.getInstance(mContext);
|
||||
}
|
||||
|
||||
private void initIcons() {
|
||||
@@ -322,7 +325,12 @@ public class KeyguardAffordanceHelper {
|
||||
float vel = getCurrentVelocity(lastX, lastY);
|
||||
|
||||
// We snap back if the current translation is not far enough
|
||||
boolean snapBack = isBelowFalsingThreshold();
|
||||
boolean snapBack;
|
||||
if (mFalsingManager.isFalseTouch()) {
|
||||
snapBack = mFalsingManager.isFalseTouch();
|
||||
} else {
|
||||
snapBack = isBelowFalsingThreshold();
|
||||
}
|
||||
|
||||
// or if the velocity is in the opposite direction.
|
||||
boolean velIsInWrongDirection = vel * mTranslation < 0;
|
||||
|
||||
@@ -695,7 +695,7 @@ public class NotificationPanelView extends PanelView implements
|
||||
}
|
||||
|
||||
private boolean flingExpandsQs(float vel) {
|
||||
if (isBelowFalsingThreshold()) {
|
||||
if (isFalseTouch()) {
|
||||
return false;
|
||||
}
|
||||
if (Math.abs(vel) < mFlingAnimationUtils.getMinVelocityPxPerSecond()) {
|
||||
@@ -705,8 +705,14 @@ public class NotificationPanelView extends PanelView implements
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isBelowFalsingThreshold() {
|
||||
return !mQsTouchAboveFalsingThreshold && mStatusBarState == StatusBarState.KEYGUARD;
|
||||
private boolean isFalseTouch() {
|
||||
if (mStatusBarState != StatusBarState.KEYGUARD) {
|
||||
return false;
|
||||
}
|
||||
if (mFalsingManager.isClassiferEnabled()) {
|
||||
return mFalsingManager.isFalseTouch();
|
||||
}
|
||||
return !mQsTouchAboveFalsingThreshold;
|
||||
}
|
||||
|
||||
private float getQsExpansionFraction() {
|
||||
@@ -1431,7 +1437,7 @@ public class NotificationPanelView extends PanelView implements
|
||||
}
|
||||
return;
|
||||
}
|
||||
boolean belowFalsingThreshold = isBelowFalsingThreshold();
|
||||
boolean belowFalsingThreshold = isFalseTouch();
|
||||
if (belowFalsingThreshold) {
|
||||
vel = 0;
|
||||
}
|
||||
|
||||
@@ -610,8 +610,8 @@ public abstract class PanelView extends FrameLayout {
|
||||
if (!mStatusBar.isFalsingThresholdNeeded()) {
|
||||
return false;
|
||||
}
|
||||
if (mFalsingManager.isFalseTouch()) {
|
||||
return true;
|
||||
if (mFalsingManager.isClassiferEnabled()) {
|
||||
return mFalsingManager.isFalseTouch();
|
||||
}
|
||||
if (!mTouchAboveFalsingThreshold) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user