Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ca154852 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add data reporting for InteractionEvent Up and Unchanged"

parents d141c950 93b4b67b
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -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)
    }
}

+8 −4
Original line number Diff line number Diff line
@@ -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()