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

Commit 103e0ef0 authored by KRIS CHEN's avatar KRIS CHEN Committed by Android (Google) Code Review
Browse files

Merge "Implement targetSize in BoundingBoxOverlapDetector" into udc-d1-dev

parents 298e24fb 7f68a342
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5185,6 +5185,7 @@
        <item>1,1,1.0,0,1</item>
        <item>1,1,1.0,.4,1</item>
        <item>1,1,1.0,.15,15</item>
        <item>0,0,0.7,0,1</item>
    </string-array>

    <!-- The integer index of the selected option in config_udfps_touch_detection_options -->
+2 −2
Original line number Diff line number Diff line
@@ -56,10 +56,10 @@ interface UdfpsModule {
                        )
                    )
                } else {
                    BoundingBoxOverlapDetector()
                    BoundingBoxOverlapDetector(values[2])
                }
            } else {
                return BoundingBoxOverlapDetector()
                return BoundingBoxOverlapDetector(1f)
            }
        }
    }
+18 −4
Original line number Diff line number Diff line
@@ -17,16 +17,30 @@
package com.android.systemui.biometrics.udfps

import android.graphics.Rect
import android.os.Build
import android.util.Log
import com.android.systemui.dagger.SysUISingleton

/** Returns whether the touch coordinates are within the sensor's bounding box. */
@SysUISingleton
class BoundingBoxOverlapDetector : OverlapDetector {
class BoundingBoxOverlapDetector(private val targetSize: Float) : OverlapDetector {

    private val TAG = "BoundingBoxOverlapDetector"

    override fun isGoodOverlap(
        touchData: NormalizedTouchData,
        nativeSensorBounds: Rect,
        nativeOverlayBounds: Rect,
    ): Boolean =
        touchData.isWithinBounds(nativeOverlayBounds) &&
            touchData.isWithinBounds(nativeSensorBounds)
    ): Boolean {
        val scaledRadius = (nativeSensorBounds.width() / 2) * targetSize
        val scaledSensorBounds =
            Rect(
                (nativeSensorBounds.centerX() - scaledRadius).toInt(),
                (nativeSensorBounds.centerY() - scaledRadius).toInt(),
                (nativeSensorBounds.centerX() + scaledRadius).toInt(),
                (nativeSensorBounds.centerY() + scaledRadius).toInt(),
            )

        return touchData.isWithinBounds(scaledSensorBounds)
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ import org.junit.runners.Parameterized.Parameters
@SmallTest
@RunWith(Parameterized::class)
class BoundingBoxOverlapDetectorTest(val testCase: TestCase) : SysuiTestCase() {
    val underTest = BoundingBoxOverlapDetector()
    val underTest = BoundingBoxOverlapDetector(1f)

    @Test
    fun isGoodOverlap() {
@@ -83,7 +83,7 @@ private val TOUCH_DATA =
        GESTURE_START
    )

private val SENSOR = Rect(100 /* left */, 200 /* top */, 300 /* right */, 500 /* bottom */)
private val SENSOR = Rect(100 /* left */, 200 /* top */, 300 /* right */, 400 /* bottom */)
private val OVERLAY = Rect(0 /* left */, 100 /* top */, 400 /* right */, 600 /* bottom */)

private fun genTestCases(