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

Commit ac173383 authored by Joshua McCloskey's avatar Joshua McCloskey Committed by Joshua Mccloskey
Browse files

Added additional properties to FingerprintSensor

Test: atest
Bug: 297082837
Change-Id: I583a7090327ced94a9d9b6f5571136e068fcd0d4
parent 728a214d
Loading
Loading
Loading
Loading
+14 −2
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package com.android.systemui.biometrics.shared.model
package com.android.systemui.biometrics.shared.model


import android.graphics.Rect
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal


/** Fingerprint sensor property. Represents [FingerprintSensorPropertiesInternal]. */
/** Fingerprint sensor property. Represents [FingerprintSensorPropertiesInternal]. */
@@ -23,12 +24,23 @@ data class FingerprintSensor(
    val sensorId: Int,
    val sensorId: Int,
    val sensorStrength: SensorStrength,
    val sensorStrength: SensorStrength,
    val maxEnrollmentsPerUser: Int,
    val maxEnrollmentsPerUser: Int,
    val sensorType: FingerprintSensorType
    val sensorType: FingerprintSensorType,
    val sensorBounds: Rect,
    val sensorRadius: Int,
)
)


/** Convert [FingerprintSensorPropertiesInternal] to corresponding [FingerprintSensor] */
/** Convert [FingerprintSensorPropertiesInternal] to corresponding [FingerprintSensor] */
fun FingerprintSensorPropertiesInternal.toFingerprintSensor(): FingerprintSensor {
fun FingerprintSensorPropertiesInternal.toFingerprintSensor(): FingerprintSensor {
    val sensorStrength: SensorStrength = this.sensorStrength.toSensorStrength()
    val sensorStrength: SensorStrength = this.sensorStrength.toSensorStrength()
    val sensorType: FingerprintSensorType = this.sensorType.toSensorType()
    val sensorType: FingerprintSensorType = this.sensorType.toSensorType()
    return FingerprintSensor(this.sensorId, sensorStrength, this.maxEnrollmentsPerUser, sensorType)
    val sensorBounds: Rect = this.location.rect
    val sensorRadius = this.location.sensorRadius
    return FingerprintSensor(
        this.sensorId,
        sensorStrength,
        this.maxEnrollmentsPerUser,
        sensorType,
        sensorBounds,
        sensorRadius,
    )
}
}
+7 −0
Original line number Original line Diff line number Diff line
@@ -33,3 +33,10 @@ fun Int.toSensorStrength(): SensorStrength =
        SensorProperties.STRENGTH_STRONG -> SensorStrength.STRONG
        SensorProperties.STRENGTH_STRONG -> SensorStrength.STRONG
        else -> throw IllegalArgumentException("Invalid SensorStrength value: $this")
        else -> throw IllegalArgumentException("Invalid SensorStrength value: $this")
    }
    }
/** Convert [SensorStrength] to corresponding [Int] */
fun SensorStrength.toInt(): Int =
    when (this) {
        SensorStrength.CONVENIENCE -> SensorProperties.STRENGTH_CONVENIENCE
        SensorStrength.WEAK -> SensorProperties.STRENGTH_WEAK
        SensorStrength.STRONG -> SensorProperties.STRENGTH_STRONG
    }