Add data reporting for InteractionEvent Up and Unchanged

SinglePointerTouchProcessor now always reports touch data for the finger
on the sensor or the first pointer if outside.

Bug: 266856441
Test: atest
SystemUITests: com.android.systemui.biometrics.udfps.SinglePointerTouchProcessorTest
Change-Id: If2f2241d6a69a0261245dcb423e5ad06b97e3752
This commit is contained in:
Austin Delgado
2023-02-07 10:11:23 -08:00
parent 0c4b41830e
commit 93b4b67b5e
2 changed files with 21 additions and 13 deletions

View File

@@ -92,9 +92,14 @@ private fun processActionMove(touch: PreprocessedTouch): TouchProcessorResult {
val data = touch.data.find { it.pointerId == pointerOnSensorId } ?: NormalizedTouchData()
ProcessedTouch(InteractionEvent.DOWN, data.pointerId, data)
} else if (hadPointerOnSensor && !hasPointerOnSensor) {
ProcessedTouch(InteractionEvent.UP, INVALID_POINTER_ID, NormalizedTouchData())
val data =
touch.data.find { it.pointerId == touch.previousPointerOnSensorId }
?: NormalizedTouchData()
ProcessedTouch(InteractionEvent.UP, INVALID_POINTER_ID, data)
} else {
val data = touch.data.find { it.pointerId == pointerOnSensorId } ?: NormalizedTouchData()
val data =
touch.data.find { it.pointerId == pointerOnSensorId }
?: touch.data.firstOrNull() ?: NormalizedTouchData()
ProcessedTouch(InteractionEvent.UNCHANGED, pointerOnSensorId, data)
}
}
@@ -102,16 +107,15 @@ private fun processActionMove(touch: PreprocessedTouch): TouchProcessorResult {
private fun processActionUp(touch: PreprocessedTouch, actionId: Int): TouchProcessorResult {
// Finger lifted and it was the only finger on the sensor
return if (touch.pointersOnSensor.size == 1 && touch.pointersOnSensor.contains(actionId)) {
ProcessedTouch(
InteractionEvent.UP,
pointerOnSensorId = INVALID_POINTER_ID,
NormalizedTouchData()
)
val data = touch.data.find { it.pointerId == actionId } ?: NormalizedTouchData()
ProcessedTouch(InteractionEvent.UP, pointerOnSensorId = INVALID_POINTER_ID, data)
} else {
// Pick new pointerOnSensor that's not the finger that was lifted
val pointerOnSensorId = touch.pointersOnSensor.find { it != actionId } ?: INVALID_POINTER_ID
val data = touch.data.find { it.pointerId == pointerOnSensorId } ?: NormalizedTouchData()
ProcessedTouch(InteractionEvent.UNCHANGED, data.pointerId, data)
val data =
touch.data.find { it.pointerId == pointerOnSensorId }
?: touch.data.firstOrNull() ?: NormalizedTouchData()
ProcessedTouch(InteractionEvent.UNCHANGED, pointerOnSensorId, data)
}
}

View File

@@ -607,12 +607,16 @@ private fun genPositiveTestCases(
pointerCoords = pointerCoords
)
val expectedTouchDataPointer =
currentPointers.find { it.id == expectedPointerOnSensorId }
?: currentPointers.find { it.id == previousPointerOnSensorId }
?: currentPointers[0]
val expectedTouchData =
if (expectedPointerOnSensorId != INVALID_POINTER_ID) {
if (motionEventAction != MotionEvent.ACTION_CANCEL) {
NORMALIZED_TOUCH_DATA.copy(
pointerId = expectedPointerOnSensorId,
x = ROTATION_0_INPUTS.getNativeX(isWithinSensor = true),
y = ROTATION_0_INPUTS.getNativeY(isWithinSensor = true)
pointerId = expectedTouchDataPointer.id,
x = ROTATION_0_INPUTS.getNativeX(expectedTouchDataPointer.onSensor),
y = ROTATION_0_INPUTS.getNativeY(expectedTouchDataPointer.onSensor)
)
} else {
NormalizedTouchData()