Loading packages/SettingsLib/src/com/android/settingslib/udfps/UdfpsOverlayParams.kt +3 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,9 @@ data class UdfpsOverlayParams( /** Same as [sensorBounds], but in native resolution. */ val nativeSensorBounds = Rect(sensorBounds).apply { scale(1f / scaleFactor) } /** Same as [overlayBounds], but in native resolution. */ val nativeOverlayBounds = Rect(overlayBounds).apply { scale(1f / scaleFactor) } /** See [android.view.DisplayInfo.logicalWidth] */ val logicalDisplayWidth = if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) { Loading packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java +1 −1 Original line number Diff line number Diff line Loading @@ -636,7 +636,7 @@ public class UdfpsController implements DozeReceiver, Dumpable { mOverlay.getOverlayView().getViewRootImpl().getInputToken()); } return processedTouch.getTouchData().isWithinSensor(mOverlayParams.getNativeSensorBounds()); return processedTouch.getTouchData().isWithinBounds(mOverlayParams.getNativeSensorBounds()); } private boolean oldOnTouch(long requestId, @NonNull MotionEvent event, boolean fromUdfpsView) { Loading packages/SystemUI/src/com/android/systemui/biometrics/udfps/BoundingBoxOverlapDetector.kt +7 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,11 @@ import com.android.systemui.dagger.SysUISingleton /** Returns whether the touch coordinates are within the sensor's bounding box. */ @SysUISingleton class BoundingBoxOverlapDetector : OverlapDetector { override fun isGoodOverlap(touchData: NormalizedTouchData, nativeSensorBounds: Rect): Boolean = touchData.isWithinSensor(nativeSensorBounds) override fun isGoodOverlap( touchData: NormalizedTouchData, nativeSensorBounds: Rect, nativeOverlayBounds: Rect, ): Boolean = touchData.isWithinBounds(nativeOverlayBounds) && touchData.isWithinBounds(nativeSensorBounds) } packages/SystemUI/src/com/android/systemui/biometrics/udfps/EllipseOverlapDetector.kt +15 −6 Original line number Diff line number Diff line Loading @@ -30,8 +30,8 @@ private enum class SensorPixelPosition { TARGET // Pixel within sensor center target } private val isDebug = true private val TAG = "EllipseOverlapDetector" private const val isDebug = false private const val TAG = "EllipseOverlapDetector" /** * Approximates the touch as an ellipse and determines whether the ellipse has a sufficient overlap Loading @@ -39,12 +39,21 @@ private val TAG = "EllipseOverlapDetector" */ @SysUISingleton class EllipseOverlapDetector(private val params: EllipseOverlapDetectorParams) : OverlapDetector { override fun isGoodOverlap(touchData: NormalizedTouchData, nativeSensorBounds: Rect): Boolean { // First, check if touch is within bounding box, if (nativeSensorBounds.contains(touchData.x.toInt(), touchData.y.toInt())) { override fun isGoodOverlap( touchData: NormalizedTouchData, nativeSensorBounds: Rect, nativeOverlayBounds: Rect, ): Boolean { // First, check if touch is within bounding box to exit early if (touchData.isWithinBounds(nativeSensorBounds)) { return true } // Check touch is within overlay bounds, not worth checking if outside if (!touchData.isWithinBounds(nativeOverlayBounds)) { return false } var isTargetTouched = false var sensorPixels = 0 var coveredPixels = 0 Loading Loading @@ -77,7 +86,7 @@ class EllipseOverlapDetector(private val params: EllipseOverlapDetectorParams) : val percentage: Float = coveredPixels.toFloat() / sensorPixels if (isDebug) { Log.v( Log.d( TAG, "covered: $coveredPixels, sensor: $sensorPixels, " + "percentage: $percentage, isCenterTouched: $isTargetTouched" Loading packages/SystemUI/src/com/android/systemui/biometrics/udfps/NormalizedTouchData.kt +8 −8 Original line number Diff line number Diff line Loading @@ -51,16 +51,16 @@ data class NormalizedTouchData( ) { /** * [nativeSensorBounds] contains the location and dimensions of the sensor area in native * resolution and natural orientation. * [nativeBounds] contains the location and dimensions of the area in native resolution and * natural orientation. * * Returns whether the coordinates of the given pointer are within the sensor's bounding box. * Returns whether the coordinates of the given pointer are within the bounding box. */ fun isWithinSensor(nativeSensorBounds: Rect): Boolean { return nativeSensorBounds.left <= x && nativeSensorBounds.right >= x && nativeSensorBounds.top <= y && nativeSensorBounds.bottom >= y fun isWithinBounds(nativeBounds: Rect): Boolean { return nativeBounds.left <= x && nativeBounds.right >= x && nativeBounds.top <= y && nativeBounds.bottom >= y } @JvmOverloads Loading Loading
packages/SettingsLib/src/com/android/settingslib/udfps/UdfpsOverlayParams.kt +3 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,9 @@ data class UdfpsOverlayParams( /** Same as [sensorBounds], but in native resolution. */ val nativeSensorBounds = Rect(sensorBounds).apply { scale(1f / scaleFactor) } /** Same as [overlayBounds], but in native resolution. */ val nativeOverlayBounds = Rect(overlayBounds).apply { scale(1f / scaleFactor) } /** See [android.view.DisplayInfo.logicalWidth] */ val logicalDisplayWidth = if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) { Loading
packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java +1 −1 Original line number Diff line number Diff line Loading @@ -636,7 +636,7 @@ public class UdfpsController implements DozeReceiver, Dumpable { mOverlay.getOverlayView().getViewRootImpl().getInputToken()); } return processedTouch.getTouchData().isWithinSensor(mOverlayParams.getNativeSensorBounds()); return processedTouch.getTouchData().isWithinBounds(mOverlayParams.getNativeSensorBounds()); } private boolean oldOnTouch(long requestId, @NonNull MotionEvent event, boolean fromUdfpsView) { Loading
packages/SystemUI/src/com/android/systemui/biometrics/udfps/BoundingBoxOverlapDetector.kt +7 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,11 @@ import com.android.systemui.dagger.SysUISingleton /** Returns whether the touch coordinates are within the sensor's bounding box. */ @SysUISingleton class BoundingBoxOverlapDetector : OverlapDetector { override fun isGoodOverlap(touchData: NormalizedTouchData, nativeSensorBounds: Rect): Boolean = touchData.isWithinSensor(nativeSensorBounds) override fun isGoodOverlap( touchData: NormalizedTouchData, nativeSensorBounds: Rect, nativeOverlayBounds: Rect, ): Boolean = touchData.isWithinBounds(nativeOverlayBounds) && touchData.isWithinBounds(nativeSensorBounds) }
packages/SystemUI/src/com/android/systemui/biometrics/udfps/EllipseOverlapDetector.kt +15 −6 Original line number Diff line number Diff line Loading @@ -30,8 +30,8 @@ private enum class SensorPixelPosition { TARGET // Pixel within sensor center target } private val isDebug = true private val TAG = "EllipseOverlapDetector" private const val isDebug = false private const val TAG = "EllipseOverlapDetector" /** * Approximates the touch as an ellipse and determines whether the ellipse has a sufficient overlap Loading @@ -39,12 +39,21 @@ private val TAG = "EllipseOverlapDetector" */ @SysUISingleton class EllipseOverlapDetector(private val params: EllipseOverlapDetectorParams) : OverlapDetector { override fun isGoodOverlap(touchData: NormalizedTouchData, nativeSensorBounds: Rect): Boolean { // First, check if touch is within bounding box, if (nativeSensorBounds.contains(touchData.x.toInt(), touchData.y.toInt())) { override fun isGoodOverlap( touchData: NormalizedTouchData, nativeSensorBounds: Rect, nativeOverlayBounds: Rect, ): Boolean { // First, check if touch is within bounding box to exit early if (touchData.isWithinBounds(nativeSensorBounds)) { return true } // Check touch is within overlay bounds, not worth checking if outside if (!touchData.isWithinBounds(nativeOverlayBounds)) { return false } var isTargetTouched = false var sensorPixels = 0 var coveredPixels = 0 Loading Loading @@ -77,7 +86,7 @@ class EllipseOverlapDetector(private val params: EllipseOverlapDetectorParams) : val percentage: Float = coveredPixels.toFloat() / sensorPixels if (isDebug) { Log.v( Log.d( TAG, "covered: $coveredPixels, sensor: $sensorPixels, " + "percentage: $percentage, isCenterTouched: $isTargetTouched" Loading
packages/SystemUI/src/com/android/systemui/biometrics/udfps/NormalizedTouchData.kt +8 −8 Original line number Diff line number Diff line Loading @@ -51,16 +51,16 @@ data class NormalizedTouchData( ) { /** * [nativeSensorBounds] contains the location and dimensions of the sensor area in native * resolution and natural orientation. * [nativeBounds] contains the location and dimensions of the area in native resolution and * natural orientation. * * Returns whether the coordinates of the given pointer are within the sensor's bounding box. * Returns whether the coordinates of the given pointer are within the bounding box. */ fun isWithinSensor(nativeSensorBounds: Rect): Boolean { return nativeSensorBounds.left <= x && nativeSensorBounds.right >= x && nativeSensorBounds.top <= y && nativeSensorBounds.bottom >= y fun isWithinBounds(nativeBounds: Rect): Boolean { return nativeBounds.left <= x && nativeBounds.right >= x && nativeBounds.top <= y && nativeBounds.bottom >= y } @JvmOverloads Loading