Loading core/res/res/values/config.xml +1 −0 Original line number Diff line number Diff line Loading @@ -5185,6 +5185,7 @@ <item>1,1,1.0,0,1</item> <item>1,1,1.0,.4,1</item> <item>1,1,1.0,.15,15</item> <item>0,0,0.7,0,1</item> </string-array> <!-- The integer index of the selected option in config_udfps_touch_detection_options --> Loading packages/SystemUI/src/com/android/systemui/biometrics/dagger/UdfpsModule.kt +2 −2 Original line number Diff line number Diff line Loading @@ -56,10 +56,10 @@ interface UdfpsModule { ) ) } else { BoundingBoxOverlapDetector() BoundingBoxOverlapDetector(values[2]) } } else { return BoundingBoxOverlapDetector() return BoundingBoxOverlapDetector(1f) } } } Loading packages/SystemUI/src/com/android/systemui/biometrics/udfps/BoundingBoxOverlapDetector.kt +18 −4 Original line number Diff line number Diff line Loading @@ -17,16 +17,30 @@ package com.android.systemui.biometrics.udfps import android.graphics.Rect import android.os.Build import android.util.Log import com.android.systemui.dagger.SysUISingleton /** Returns whether the touch coordinates are within the sensor's bounding box. */ @SysUISingleton class BoundingBoxOverlapDetector : OverlapDetector { class BoundingBoxOverlapDetector(private val targetSize: Float) : OverlapDetector { private val TAG = "BoundingBoxOverlapDetector" override fun isGoodOverlap( touchData: NormalizedTouchData, nativeSensorBounds: Rect, nativeOverlayBounds: Rect, ): Boolean = touchData.isWithinBounds(nativeOverlayBounds) && touchData.isWithinBounds(nativeSensorBounds) ): Boolean { val scaledRadius = (nativeSensorBounds.width() / 2) * targetSize val scaledSensorBounds = Rect( (nativeSensorBounds.centerX() - scaledRadius).toInt(), (nativeSensorBounds.centerY() - scaledRadius).toInt(), (nativeSensorBounds.centerX() + scaledRadius).toInt(), (nativeSensorBounds.centerY() + scaledRadius).toInt(), ) return touchData.isWithinBounds(scaledSensorBounds) } } packages/SystemUI/tests/src/com/android/systemui/biometrics/udfps/BoundingBoxOverlapDetectorTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ import org.junit.runners.Parameterized.Parameters @SmallTest @RunWith(Parameterized::class) class BoundingBoxOverlapDetectorTest(val testCase: TestCase) : SysuiTestCase() { val underTest = BoundingBoxOverlapDetector() val underTest = BoundingBoxOverlapDetector(1f) @Test fun isGoodOverlap() { Loading Loading @@ -83,7 +83,7 @@ private val TOUCH_DATA = GESTURE_START ) private val SENSOR = Rect(100 /* left */, 200 /* top */, 300 /* right */, 500 /* bottom */) private val SENSOR = Rect(100 /* left */, 200 /* top */, 300 /* right */, 400 /* bottom */) private val OVERLAY = Rect(0 /* left */, 100 /* top */, 400 /* right */, 600 /* bottom */) private fun genTestCases( Loading Loading
core/res/res/values/config.xml +1 −0 Original line number Diff line number Diff line Loading @@ -5185,6 +5185,7 @@ <item>1,1,1.0,0,1</item> <item>1,1,1.0,.4,1</item> <item>1,1,1.0,.15,15</item> <item>0,0,0.7,0,1</item> </string-array> <!-- The integer index of the selected option in config_udfps_touch_detection_options --> Loading
packages/SystemUI/src/com/android/systemui/biometrics/dagger/UdfpsModule.kt +2 −2 Original line number Diff line number Diff line Loading @@ -56,10 +56,10 @@ interface UdfpsModule { ) ) } else { BoundingBoxOverlapDetector() BoundingBoxOverlapDetector(values[2]) } } else { return BoundingBoxOverlapDetector() return BoundingBoxOverlapDetector(1f) } } } Loading
packages/SystemUI/src/com/android/systemui/biometrics/udfps/BoundingBoxOverlapDetector.kt +18 −4 Original line number Diff line number Diff line Loading @@ -17,16 +17,30 @@ package com.android.systemui.biometrics.udfps import android.graphics.Rect import android.os.Build import android.util.Log import com.android.systemui.dagger.SysUISingleton /** Returns whether the touch coordinates are within the sensor's bounding box. */ @SysUISingleton class BoundingBoxOverlapDetector : OverlapDetector { class BoundingBoxOverlapDetector(private val targetSize: Float) : OverlapDetector { private val TAG = "BoundingBoxOverlapDetector" override fun isGoodOverlap( touchData: NormalizedTouchData, nativeSensorBounds: Rect, nativeOverlayBounds: Rect, ): Boolean = touchData.isWithinBounds(nativeOverlayBounds) && touchData.isWithinBounds(nativeSensorBounds) ): Boolean { val scaledRadius = (nativeSensorBounds.width() / 2) * targetSize val scaledSensorBounds = Rect( (nativeSensorBounds.centerX() - scaledRadius).toInt(), (nativeSensorBounds.centerY() - scaledRadius).toInt(), (nativeSensorBounds.centerX() + scaledRadius).toInt(), (nativeSensorBounds.centerY() + scaledRadius).toInt(), ) return touchData.isWithinBounds(scaledSensorBounds) } }
packages/SystemUI/tests/src/com/android/systemui/biometrics/udfps/BoundingBoxOverlapDetectorTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ import org.junit.runners.Parameterized.Parameters @SmallTest @RunWith(Parameterized::class) class BoundingBoxOverlapDetectorTest(val testCase: TestCase) : SysuiTestCase() { val underTest = BoundingBoxOverlapDetector() val underTest = BoundingBoxOverlapDetector(1f) @Test fun isGoodOverlap() { Loading Loading @@ -83,7 +83,7 @@ private val TOUCH_DATA = GESTURE_START ) private val SENSOR = Rect(100 /* left */, 200 /* top */, 300 /* right */, 500 /* bottom */) private val SENSOR = Rect(100 /* left */, 200 /* top */, 300 /* right */, 400 /* bottom */) private val OVERLAY = Rect(0 /* left */, 100 /* top */, 400 /* right */, 600 /* bottom */) private fun genTestCases( Loading