Loading packages/SystemUI/src/com/android/systemui/SwipeHelper.java +11 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -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) Loading packages/SystemUI/src/com/android/systemui/classifier/FalsingManager.java +20 −2 Original line number Diff line number Diff line Loading @@ -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, Loading Loading @@ -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); Loading @@ -121,6 +135,10 @@ public class FalsingManager implements SensorEventListener { } } public boolean isClassiferEnabled() { return mHumanInteractionClassifier.isEnabled(); } private boolean isEnabled() { return mHumanInteractionClassifier.isEnabled() || mDataCollector.isEnabled(); } Loading packages/SystemUI/src/com/android/systemui/classifier/HumanInteractionClassifier.java +4 −1 Original line number Diff line number Diff line Loading @@ -149,8 +149,11 @@ public class HumanInteractionClassifier extends Classifier { } public boolean isFalseTouch() { if (mEnableClassifier) { return mHistoryEvaluator.getEvaluation() >= 5.0f; } return false; } public boolean isEnabled() { return mEnableClassifier; Loading packages/SystemUI/src/com/android/systemui/statusbar/DragDownHelper.java +8 −1 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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); Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java +9 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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() { Loading Loading @@ -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; Loading Loading
packages/SystemUI/src/com/android/systemui/SwipeHelper.java +11 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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) { Loading Loading @@ -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) Loading
packages/SystemUI/src/com/android/systemui/classifier/FalsingManager.java +20 −2 Original line number Diff line number Diff line Loading @@ -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, Loading Loading @@ -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); Loading @@ -121,6 +135,10 @@ public class FalsingManager implements SensorEventListener { } } public boolean isClassiferEnabled() { return mHumanInteractionClassifier.isEnabled(); } private boolean isEnabled() { return mHumanInteractionClassifier.isEnabled() || mDataCollector.isEnabled(); } Loading
packages/SystemUI/src/com/android/systemui/classifier/HumanInteractionClassifier.java +4 −1 Original line number Diff line number Diff line Loading @@ -149,8 +149,11 @@ public class HumanInteractionClassifier extends Classifier { } public boolean isFalseTouch() { if (mEnableClassifier) { return mHistoryEvaluator.getEvaluation() >= 5.0f; } return false; } public boolean isEnabled() { return mEnableClassifier; Loading
packages/SystemUI/src/com/android/systemui/statusbar/DragDownHelper.java +8 −1 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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); Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java +9 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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() { Loading Loading @@ -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; Loading