summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ilya Matyukhin <ilyamaty@google.com> 2022-11-28 03:11:30 +0000
committer Ilya Matyukhin <ilyamaty@google.com> 2022-11-29 06:20:39 +0000
commitaa4b1c42bc0d763b6fdc0539e90d3f1d2ccc4503 (patch)
treece81202bcf0346d0d42d711395a5be7e4431ffa4
parentea6cdd17598fd2915b21bbd5150505e293874012 (diff)
Change computed properties to regular in UdfpsOverlayParams
Bug: 218374828 Test: atest SystemUITests:com.android.systemui.biometrics Change-Id: I07994051763a13486efbaa4cc7b6385b6dafa005
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/UdfpsOverlayParams.kt40
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/udfps/NormalizedTouchData.kt17
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/udfps/SinglePointerTouchProcessor.kt2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/biometrics/udfps/NormalizedTouchDataTest.kt4
4 files changed, 36 insertions, 27 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsOverlayParams.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsOverlayParams.kt
index 98d4c22d927d..7f3846ca4e40 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsOverlayParams.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsOverlayParams.kt
@@ -7,17 +7,23 @@ import android.view.Surface.Rotation
/**
* Collection of parameters that define an under-display fingerprint sensor (UDFPS) overlay.
*
- * @property sensorBounds coordinates of the bounding box around the sensor, in natural orientation,
- * in pixels, for the current resolution.
- * @property naturalDisplayWidth width of the physical display, in natural orientation, in pixels,
- * for the current resolution.
- * @property naturalDisplayHeight height of the physical display, in natural orientation, in pixels,
- * for the current resolution.
- * @property scaleFactor ratio of a dimension in the current resolution to the corresponding
- * dimension in the native resolution.
- * @property rotation current rotation of the display.
+ * [sensorBounds] coordinates of the bounding box around the sensor in natural orientation, in
+ * pixels, for the current resolution.
+ *
+ * [overlayBounds] coordinates of the UI overlay in natural orientation, in pixels, for the current
+ * resolution.
+ *
+ * [naturalDisplayWidth] width of the physical display in natural orientation, in pixels, for the
+ * current resolution.
+ *
+ * [naturalDisplayHeight] height of the physical display in natural orientation, in pixels, for the
+ * current resolution.
+ *
+ * [scaleFactor] ratio of a dimension in the current resolution to the corresponding dimension in
+ * the native resolution.
+ *
+ * [rotation] current rotation of the display.
*/
-
data class UdfpsOverlayParams(
val sensorBounds: Rect = Rect(),
val overlayBounds: Rect = Rect(),
@@ -26,19 +32,23 @@ data class UdfpsOverlayParams(
val scaleFactor: Float = 1f,
@Rotation val rotation: Int = Surface.ROTATION_0
) {
+
+ /** Same as [sensorBounds], but in native resolution. */
+ val nativeSensorBounds = Rect(sensorBounds).apply { scale(1f / scaleFactor) }
+
/** See [android.view.DisplayInfo.logicalWidth] */
- val logicalDisplayWidth
- get() = if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
+ val logicalDisplayWidth =
+ if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
naturalDisplayHeight
} else {
naturalDisplayWidth
}
/** See [android.view.DisplayInfo.logicalHeight] */
- val logicalDisplayHeight
- get() = if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
+ val logicalDisplayHeight =
+ if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
naturalDisplayWidth
} else {
naturalDisplayHeight
}
-} \ No newline at end of file
+}
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/udfps/NormalizedTouchData.kt b/packages/SystemUI/src/com/android/systemui/biometrics/udfps/NormalizedTouchData.kt
index f26c732a1b61..62bedc627b07 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/udfps/NormalizedTouchData.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/udfps/NormalizedTouchData.kt
@@ -16,9 +16,8 @@
package com.android.systemui.biometrics.udfps
-import android.graphics.RectF
+import android.graphics.Rect
import android.view.MotionEvent
-import com.android.systemui.biometrics.UdfpsOverlayParams
/** Touch data in natural orientation and native resolution. */
data class NormalizedTouchData(
@@ -52,13 +51,15 @@ data class NormalizedTouchData(
) {
/**
- * [overlayParams] contains the location and dimensions of the sensor area, as well as the scale
- * factor and orientation of the overlay. See [UdfpsOverlayParams].
+ * [nativeSensorBounds] contains the location and dimensions of the sensor area in native
+ * resolution and natural orientation.
*
- * Returns whether the given pointer is within the sensor's bounding box.
+ * Returns whether the coordinates of the given pointer are within the sensor's bounding box.
*/
- fun isWithinSensor(overlayParams: UdfpsOverlayParams): Boolean {
- val r = RectF(overlayParams.sensorBounds).apply { scale(1f / overlayParams.scaleFactor) }
- return r.left <= x && r.right >= x && r.top <= y && r.bottom >= y
+ fun isWithinSensor(nativeSensorBounds: Rect): Boolean {
+ return nativeSensorBounds.left <= x &&
+ nativeSensorBounds.right >= x &&
+ nativeSensorBounds.top <= y &&
+ nativeSensorBounds.bottom >= y
}
}
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 451b895d9574..dec8730e971f 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/udfps/SinglePointerTouchProcessor.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/udfps/SinglePointerTouchProcessor.kt
@@ -116,7 +116,7 @@ private fun MotionEvent.preprocess(
// TODO(b/253085297): Add multitouch support. pointerIndex can be > 0 for ACTION_MOVE.
val pointerIndex = 0
val touchData = normalize(pointerIndex, overlayParams)
- val isWithinSensor = touchData.isWithinSensor(overlayParams)
+ val isWithinSensor = touchData.isWithinSensor(overlayParams.nativeSensorBounds)
return PreprocessedTouch(touchData, previousPointerOnSensorId, isWithinSensor)
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/udfps/NormalizedTouchDataTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/udfps/NormalizedTouchDataTest.kt
index d72d803fad9e..834d0a69e427 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/udfps/NormalizedTouchDataTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/udfps/NormalizedTouchDataTest.kt
@@ -3,7 +3,6 @@ package com.android.systemui.biometrics.udfps
import android.graphics.Rect
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
-import com.android.systemui.biometrics.UdfpsOverlayParams
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith
@@ -17,7 +16,7 @@ class NormalizedTouchDataTest(val testCase: TestCase) : SysuiTestCase() {
@Test
fun isWithinSensor() {
val touchData = TOUCH_DATA.copy(x = testCase.x.toFloat(), y = testCase.y.toFloat())
- val actual = touchData.isWithinSensor(OVERLAY_PARAMS)
+ val actual = touchData.isWithinSensor(SENSOR)
assertThat(actual).isEqualTo(testCase.expected)
}
@@ -66,7 +65,6 @@ private val TOUCH_DATA =
)
private val SENSOR = Rect(100 /* left */, 200 /* top */, 300 /* right */, 500 /* bottom */)
-private val OVERLAY_PARAMS = UdfpsOverlayParams(sensorBounds = SENSOR)
private fun genTestCases(
xs: List<Int>,