diff options
| author | 2024-04-09 15:39:34 -0700 | |
|---|---|---|
| committer | 2024-04-09 15:53:46 -0700 | |
| commit | ef43d675a81ad8f27ae63016efb3c456bea6353c (patch) | |
| tree | 08328f51ae88f8e606c2b099b2aaf9b33dbc890d | |
| parent | 5f8b94d31c0ffe0f747e46faf9d2a98dba1c95e7 (diff) | |
Add UDFPS ROTATION_180 support
Bug: 332582654
Test: SinglePointerTouchProcessorTest
Flag: None
Change-Id: If51e4ca54c5f6d0526045b0b2ac3331d9928b7f1
2 files changed, 28 insertions, 30 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/udfps/SinglePointerTouchProcessor.kt b/packages/SystemUI/src/com/android/systemui/biometrics/udfps/SinglePointerTouchProcessor.kt index 83b3380ae6be..1eef91debab3 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/udfps/SinglePointerTouchProcessor.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/udfps/SinglePointerTouchProcessor.kt @@ -27,7 +27,8 @@ import com.android.systemui.biometrics.udfps.TouchProcessorResult.ProcessedTouch import com.android.systemui.dagger.SysUISingleton import javax.inject.Inject -private val SUPPORTED_ROTATIONS = setOf(Surface.ROTATION_90, Surface.ROTATION_270) +private val SUPPORTED_ROTATIONS = + setOf(Surface.ROTATION_90, Surface.ROTATION_270, Surface.ROTATION_180) /** * TODO(b/259140693): Consider using an object pool of TouchProcessorResult to avoid allocations. diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/udfps/SinglePointerTouchProcessorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/udfps/SinglePointerTouchProcessorTest.kt index 99c2c4076403..aff93bd339ad 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/udfps/SinglePointerTouchProcessorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/udfps/SinglePointerTouchProcessorTest.kt @@ -465,10 +465,34 @@ private val ROTATION_90_INPUTS = nativeYOutsideSensor = 150f, ) -/* ROTATION_180 is not supported. It's treated the same as ROTATION_0. */ +/* + * ROTATION_180 map: + * _ _ _ _ + * _ _ s _ + * _ _ s _ + * _ _ _ _ + * _ O _ _ + * _ _ _ _ + * + * (_) empty space + * (S) sensor + * (O) touch outside of the sensor + */ +private val ROTATION_180_NATIVE_SENSOR_BOUNDS = + Rect( + 200, /* left */ + 100, /* top */ + 300, /* right */ + 300, /* bottom */ + ) private val ROTATION_180_INPUTS = - ROTATION_0_INPUTS.copy( + OrientationBasedInputs( rotation = Surface.ROTATION_180, + nativeOrientation = (ORIENTATION - Math.PI.toFloat() / 2), + nativeXWithinSensor = ROTATION_180_NATIVE_SENSOR_BOUNDS.exactCenterX(), + nativeYWithinSensor = ROTATION_180_NATIVE_SENSOR_BOUNDS.exactCenterY(), + nativeXOutsideSensor = 150f, + nativeYOutsideSensor = 450f, ) /* @@ -639,33 +663,6 @@ private fun genPositiveTestCases( } } -private fun genTestCasesForUnsupportedAction( - motionEventAction: Int -): List<SinglePointerTouchProcessorTest.TestCase> { - val isGoodOverlap = true - val previousPointerOnSensorIds = listOf(INVALID_POINTER_ID, POINTER_ID_1) - return previousPointerOnSensorIds.map { previousPointerOnSensorId -> - val overlayParams = ROTATION_0_INPUTS.toOverlayParams(scaleFactor = 1f) - val nativeX = ROTATION_0_INPUTS.getNativeX(isGoodOverlap) - val nativeY = ROTATION_0_INPUTS.getNativeY(isGoodOverlap) - val event = - MOTION_EVENT.copy( - action = motionEventAction, - x = nativeX, - y = nativeY, - minor = NATIVE_MINOR, - major = NATIVE_MAJOR, - ) - SinglePointerTouchProcessorTest.TestCase( - event = event, - currentPointers = listOf(TestPointer(id = POINTER_ID_1, onSensor = isGoodOverlap)), - previousPointerOnSensorId = previousPointerOnSensorId, - overlayParams = overlayParams, - expected = TouchProcessorResult.Failure(), - ) - } -} - private fun obtainMotionEvent( action: Int, pointerId: Int, |