Loading packages/SystemUI/src/com/android/systemui/classifier/brightline/BrightLineFalsingManager.java +11 −2 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import com.android.systemui.util.sensors.ProximitySensor; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.Locale; /** * FalsingManager designed to make clear why a touch was rejected. Loading @@ -42,7 +43,7 @@ import java.util.List; public class BrightLineFalsingManager implements FalsingManager { static final boolean DEBUG = false; private static final String TAG = "FalsingManagerPlugin"; private static final String TAG = "FalsingManager"; private final FalsingDataProvider mDataProvider; private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; Loading Loading @@ -142,7 +143,15 @@ public class BrightLineFalsingManager implements FalsingManager { boolean r = !mJustUnlockedWithFace && mClassifiers.stream().anyMatch(falsingClassifier -> { boolean result = falsingClassifier.isFalseTouch(); if (result) { logInfo(falsingClassifier.getClass().getName() + ": true"); logInfo(String.format( (Locale) null, "{classifier=%s, interactionType=%d}", falsingClassifier.getClass().getName(), mDataProvider.getInteractionType())); String reason = falsingClassifier.getReason(); if (reason != null) { logInfo(reason); } } else { logDebug(falsingClassifier.getClass().getName() + ": false"); } Loading packages/SystemUI/src/com/android/systemui/classifier/brightline/DiagonalClassifier.java +11 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ import android.provider.DeviceConfig; import com.android.systemui.util.DeviceConfigProxy; import java.util.Locale; /** * False on swipes that are too close to 45 degrees. * Loading Loading @@ -84,6 +86,15 @@ class DiagonalClassifier extends FalsingClassifier { maxAngle + ONE_HUNDRED_EIGHTY_DEG); } @Override String getReason() { return String.format( (Locale) null, "{angle=%f, vertical=%s}", getAngle(), isVertical()); } private boolean angleBetween(float angle, float min, float max) { // No need to normalize angle as it is guaranteed to be between 0 and 2*PI. min = normalizeAngle(min); Loading packages/SystemUI/src/com/android/systemui/classifier/brightline/DistanceClassifier.java +57 −30 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.view.VelocityTracker; import com.android.systemui.util.DeviceConfigProxy; import java.util.List; import java.util.Locale; /** * Ensure that the swipe + momentum covers a minimum distance. Loading Loading @@ -144,56 +145,82 @@ class DistanceClassifier extends FalsingClassifier { @Override public boolean isFalseTouch() { return !getDistances().getPassedFlingThreshold(); return !getPassedFlingThreshold(); } @Override String getReason() { DistanceVectors distanceVectors = getDistances(); return String.format( (Locale) null, "{distanceVectors=%s, isHorizontal=%s, velocityToDistanceMultiplier=%f, " + "horizontalFlingThreshold=%f, verticalFlingThreshold=%f, " + "horizontalSwipeThreshold=%f, verticalSwipeThreshold=%s}", distanceVectors, isHorizontal(), mVelocityToDistanceMultiplier, mHorizontalFlingThresholdPx, mVerticalFlingThresholdPx, mHorizontalSwipeThresholdPx, mVerticalSwipeThresholdPx); } boolean isLongSwipe() { boolean longSwipe = getDistances().getPassedDistanceThreshold(); boolean longSwipe = getPassedDistanceThreshold(); logDebug("Is longSwipe? " + longSwipe); return longSwipe; } private class DistanceVectors { final float mDx; final float mDy; private final float mVx; private final float mVy; DistanceVectors(float dX, float dY, float vX, float vY) { this.mDx = dX; this.mDy = dY; this.mVx = vX; this.mVy = vY; } boolean getPassedDistanceThreshold() { private boolean getPassedDistanceThreshold() { DistanceVectors distanceVectors = getDistances(); if (isHorizontal()) { logDebug("Horizontal swipe distance: " + Math.abs(mDx)); logDebug("Horizontal swipe distance: " + Math.abs(distanceVectors.mDx)); logDebug("Threshold: " + mHorizontalSwipeThresholdPx); return Math.abs(mDx) >= mHorizontalSwipeThresholdPx; return Math.abs(distanceVectors.mDx) >= mHorizontalSwipeThresholdPx; } logDebug("Vertical swipe distance: " + Math.abs(mDy)); logDebug("Vertical swipe distance: " + Math.abs(distanceVectors.mDy)); logDebug("Threshold: " + mVerticalSwipeThresholdPx); return Math.abs(mDy) >= mVerticalSwipeThresholdPx; return Math.abs(distanceVectors.mDy) >= mVerticalSwipeThresholdPx; } boolean getPassedFlingThreshold() { float dX = this.mDx + this.mVx * mVelocityToDistanceMultiplier; float dY = this.mDy + this.mVy * mVelocityToDistanceMultiplier; private boolean getPassedFlingThreshold() { DistanceVectors distanceVectors = getDistances(); float dX = distanceVectors.mDx + distanceVectors.mVx * mVelocityToDistanceMultiplier; float dY = distanceVectors.mDy + distanceVectors.mVy * mVelocityToDistanceMultiplier; if (isHorizontal()) { logDebug("Horizontal swipe and fling distance: " + this.mDx + ", " + this.mVx * mVelocityToDistanceMultiplier); logDebug("Horizontal swipe and fling distance: " + distanceVectors.mDx + ", " + distanceVectors.mVx * mVelocityToDistanceMultiplier); logDebug("Threshold: " + mHorizontalFlingThresholdPx); return Math.abs(dX) >= mHorizontalFlingThresholdPx; } logDebug("Vertical swipe and fling distance: " + this.mDy + ", " + this.mVy * mVelocityToDistanceMultiplier); logDebug("Vertical swipe and fling distance: " + distanceVectors.mDy + ", " + distanceVectors.mVy * mVelocityToDistanceMultiplier); logDebug("Threshold: " + mVerticalFlingThresholdPx); return Math.abs(dY) >= mVerticalFlingThresholdPx; } private class DistanceVectors { final float mDx; final float mDy; private final float mVx; private final float mVy; DistanceVectors(float dX, float dY, float vX, float vY) { this.mDx = dX; this.mDy = dY; this.mVx = vX; this.mVy = vY; } @Override public String toString() { return String.format((Locale) null, "{dx=%f, vx=%f, dy=%f, vy=%f}", mDx, mVx, mDy, mVy); } } } packages/SystemUI/src/com/android/systemui/classifier/brightline/FalsingClassifier.java +8 −0 Original line number Diff line number Diff line Loading @@ -117,6 +117,14 @@ abstract class FalsingClassifier { */ abstract boolean isFalseTouch(); /** * Give the classifier a chance to log more details about why it triggered. * * This should only be called after a call to {@link #isFalseTouch()}, and only if * {@link #isFalseTouch()} returns true; */ abstract String getReason(); static void logDebug(String msg) { BrightLineFalsingManager.logDebug(msg); } Loading packages/SystemUI/src/com/android/systemui/classifier/brightline/PointerCountClassifier.java +11 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ package com.android.systemui.classifier.brightline; import android.view.MotionEvent; import java.util.Locale; /** * False touch if more than one finger touches the screen. * Loading Loading @@ -50,4 +52,13 @@ class PointerCountClassifier extends FalsingClassifier { public boolean isFalseTouch() { return mMaxPointerCount > MAX_ALLOWED_POINTERS; } @Override String getReason() { return String.format( (Locale) null, "{pointersObserved=%d, threshold=%d}", mMaxPointerCount, MAX_ALLOWED_POINTERS); } } Loading
packages/SystemUI/src/com/android/systemui/classifier/brightline/BrightLineFalsingManager.java +11 −2 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import com.android.systemui.util.sensors.ProximitySensor; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.Locale; /** * FalsingManager designed to make clear why a touch was rejected. Loading @@ -42,7 +43,7 @@ import java.util.List; public class BrightLineFalsingManager implements FalsingManager { static final boolean DEBUG = false; private static final String TAG = "FalsingManagerPlugin"; private static final String TAG = "FalsingManager"; private final FalsingDataProvider mDataProvider; private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; Loading Loading @@ -142,7 +143,15 @@ public class BrightLineFalsingManager implements FalsingManager { boolean r = !mJustUnlockedWithFace && mClassifiers.stream().anyMatch(falsingClassifier -> { boolean result = falsingClassifier.isFalseTouch(); if (result) { logInfo(falsingClassifier.getClass().getName() + ": true"); logInfo(String.format( (Locale) null, "{classifier=%s, interactionType=%d}", falsingClassifier.getClass().getName(), mDataProvider.getInteractionType())); String reason = falsingClassifier.getReason(); if (reason != null) { logInfo(reason); } } else { logDebug(falsingClassifier.getClass().getName() + ": false"); } Loading
packages/SystemUI/src/com/android/systemui/classifier/brightline/DiagonalClassifier.java +11 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ import android.provider.DeviceConfig; import com.android.systemui.util.DeviceConfigProxy; import java.util.Locale; /** * False on swipes that are too close to 45 degrees. * Loading Loading @@ -84,6 +86,15 @@ class DiagonalClassifier extends FalsingClassifier { maxAngle + ONE_HUNDRED_EIGHTY_DEG); } @Override String getReason() { return String.format( (Locale) null, "{angle=%f, vertical=%s}", getAngle(), isVertical()); } private boolean angleBetween(float angle, float min, float max) { // No need to normalize angle as it is guaranteed to be between 0 and 2*PI. min = normalizeAngle(min); Loading
packages/SystemUI/src/com/android/systemui/classifier/brightline/DistanceClassifier.java +57 −30 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.view.VelocityTracker; import com.android.systemui.util.DeviceConfigProxy; import java.util.List; import java.util.Locale; /** * Ensure that the swipe + momentum covers a minimum distance. Loading Loading @@ -144,56 +145,82 @@ class DistanceClassifier extends FalsingClassifier { @Override public boolean isFalseTouch() { return !getDistances().getPassedFlingThreshold(); return !getPassedFlingThreshold(); } @Override String getReason() { DistanceVectors distanceVectors = getDistances(); return String.format( (Locale) null, "{distanceVectors=%s, isHorizontal=%s, velocityToDistanceMultiplier=%f, " + "horizontalFlingThreshold=%f, verticalFlingThreshold=%f, " + "horizontalSwipeThreshold=%f, verticalSwipeThreshold=%s}", distanceVectors, isHorizontal(), mVelocityToDistanceMultiplier, mHorizontalFlingThresholdPx, mVerticalFlingThresholdPx, mHorizontalSwipeThresholdPx, mVerticalSwipeThresholdPx); } boolean isLongSwipe() { boolean longSwipe = getDistances().getPassedDistanceThreshold(); boolean longSwipe = getPassedDistanceThreshold(); logDebug("Is longSwipe? " + longSwipe); return longSwipe; } private class DistanceVectors { final float mDx; final float mDy; private final float mVx; private final float mVy; DistanceVectors(float dX, float dY, float vX, float vY) { this.mDx = dX; this.mDy = dY; this.mVx = vX; this.mVy = vY; } boolean getPassedDistanceThreshold() { private boolean getPassedDistanceThreshold() { DistanceVectors distanceVectors = getDistances(); if (isHorizontal()) { logDebug("Horizontal swipe distance: " + Math.abs(mDx)); logDebug("Horizontal swipe distance: " + Math.abs(distanceVectors.mDx)); logDebug("Threshold: " + mHorizontalSwipeThresholdPx); return Math.abs(mDx) >= mHorizontalSwipeThresholdPx; return Math.abs(distanceVectors.mDx) >= mHorizontalSwipeThresholdPx; } logDebug("Vertical swipe distance: " + Math.abs(mDy)); logDebug("Vertical swipe distance: " + Math.abs(distanceVectors.mDy)); logDebug("Threshold: " + mVerticalSwipeThresholdPx); return Math.abs(mDy) >= mVerticalSwipeThresholdPx; return Math.abs(distanceVectors.mDy) >= mVerticalSwipeThresholdPx; } boolean getPassedFlingThreshold() { float dX = this.mDx + this.mVx * mVelocityToDistanceMultiplier; float dY = this.mDy + this.mVy * mVelocityToDistanceMultiplier; private boolean getPassedFlingThreshold() { DistanceVectors distanceVectors = getDistances(); float dX = distanceVectors.mDx + distanceVectors.mVx * mVelocityToDistanceMultiplier; float dY = distanceVectors.mDy + distanceVectors.mVy * mVelocityToDistanceMultiplier; if (isHorizontal()) { logDebug("Horizontal swipe and fling distance: " + this.mDx + ", " + this.mVx * mVelocityToDistanceMultiplier); logDebug("Horizontal swipe and fling distance: " + distanceVectors.mDx + ", " + distanceVectors.mVx * mVelocityToDistanceMultiplier); logDebug("Threshold: " + mHorizontalFlingThresholdPx); return Math.abs(dX) >= mHorizontalFlingThresholdPx; } logDebug("Vertical swipe and fling distance: " + this.mDy + ", " + this.mVy * mVelocityToDistanceMultiplier); logDebug("Vertical swipe and fling distance: " + distanceVectors.mDy + ", " + distanceVectors.mVy * mVelocityToDistanceMultiplier); logDebug("Threshold: " + mVerticalFlingThresholdPx); return Math.abs(dY) >= mVerticalFlingThresholdPx; } private class DistanceVectors { final float mDx; final float mDy; private final float mVx; private final float mVy; DistanceVectors(float dX, float dY, float vX, float vY) { this.mDx = dX; this.mDy = dY; this.mVx = vX; this.mVy = vY; } @Override public String toString() { return String.format((Locale) null, "{dx=%f, vx=%f, dy=%f, vy=%f}", mDx, mVx, mDy, mVy); } } }
packages/SystemUI/src/com/android/systemui/classifier/brightline/FalsingClassifier.java +8 −0 Original line number Diff line number Diff line Loading @@ -117,6 +117,14 @@ abstract class FalsingClassifier { */ abstract boolean isFalseTouch(); /** * Give the classifier a chance to log more details about why it triggered. * * This should only be called after a call to {@link #isFalseTouch()}, and only if * {@link #isFalseTouch()} returns true; */ abstract String getReason(); static void logDebug(String msg) { BrightLineFalsingManager.logDebug(msg); } Loading
packages/SystemUI/src/com/android/systemui/classifier/brightline/PointerCountClassifier.java +11 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ package com.android.systemui.classifier.brightline; import android.view.MotionEvent; import java.util.Locale; /** * False touch if more than one finger touches the screen. * Loading Loading @@ -50,4 +52,13 @@ class PointerCountClassifier extends FalsingClassifier { public boolean isFalseTouch() { return mMaxPointerCount > MAX_ALLOWED_POINTERS; } @Override String getReason() { return String.format( (Locale) null, "{pointersObserved=%d, threshold=%d}", mMaxPointerCount, MAX_ALLOWED_POINTERS); } }