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

Commit ef43d675 authored by Austin Delgado's avatar Austin Delgado
Browse files

Add UDFPS ROTATION_180 support

Bug: 332582654
Test: SinglePointerTouchProcessorTest
Flag: None

Change-Id: If51e4ca54c5f6d0526045b0b2ac3331d9928b7f1
parent 5f8b94d3
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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.
+26 −29
Original line number Diff line number Diff line
@@ -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,