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

Commit 3471ac79 authored by KRIS CHEN's avatar KRIS CHEN Committed by Automerger Merge Worker
Browse files

Merge "Implement targetSize in BoundingBoxOverlapDetector" into udc-d1-dev am: 103e0ef0

parents c5fa4bb4 103e0ef0
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -5188,6 +5188,7 @@
        <item>1,1,1.0,0,1</item>
        <item>1,1,1.0,0,1</item>
        <item>1,1,1.0,.4,1</item>
        <item>1,1,1.0,.4,1</item>
        <item>1,1,1.0,.15,15</item>
        <item>1,1,1.0,.15,15</item>
        <item>0,0,0.7,0,1</item>
    </string-array>
    </string-array>


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


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


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

    private val TAG = "BoundingBoxOverlapDetector"

    override fun isGoodOverlap(
    override fun isGoodOverlap(
        touchData: NormalizedTouchData,
        touchData: NormalizedTouchData,
        nativeSensorBounds: Rect,
        nativeSensorBounds: Rect,
        nativeOverlayBounds: Rect,
        nativeOverlayBounds: Rect,
    ): Boolean =
    ): Boolean {
        touchData.isWithinBounds(nativeOverlayBounds) &&
        val scaledRadius = (nativeSensorBounds.width() / 2) * targetSize
            touchData.isWithinBounds(nativeSensorBounds)
        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 Original line Diff line number Diff line
@@ -28,7 +28,7 @@ import org.junit.runners.Parameterized.Parameters
@SmallTest
@SmallTest
@RunWith(Parameterized::class)
@RunWith(Parameterized::class)
class BoundingBoxOverlapDetectorTest(val testCase: TestCase) : SysuiTestCase() {
class BoundingBoxOverlapDetectorTest(val testCase: TestCase) : SysuiTestCase() {
    val underTest = BoundingBoxOverlapDetector()
    val underTest = BoundingBoxOverlapDetector(1f)


    @Test
    @Test
    fun isGoodOverlap() {
    fun isGoodOverlap() {
@@ -83,7 +83,7 @@ private val TOUCH_DATA =
        GESTURE_START
        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 val OVERLAY = Rect(0 /* left */, 100 /* top */, 400 /* right */, 600 /* bottom */)


private fun genTestCases(
private fun genTestCases(