diff options
| author | 2023-09-09 02:38:46 +0000 | |
|---|---|---|
| committer | 2023-09-09 02:38:46 +0000 | |
| commit | 97babbeb1f44aa123daf483ea5f7da03bbb3ed4e (patch) | |
| tree | 99c0ddd7979323777350a3814fcc557e2b40f0d4 | |
| parent | f8e3f1ee852e3fdcc1c2ae3118425c7daa247a44 (diff) | |
| parent | 85385b9bd24aff5e20c50b5f134ca2e0195fae42 (diff) | |
Merge "Re-do of FingerprintSensorProperties ui layer refactor" into udc-qpr-dev
9 files changed, 140 insertions, 108 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/FingerprintPropertyRepository.kt b/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/FingerprintPropertyRepository.kt index daff5feb0123..aa33100a3abe 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/FingerprintPropertyRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/FingerprintPropertyRepository.kt @@ -16,13 +16,19 @@ package com.android.systemui.biometrics.data.repository +import android.Manifest.permission.USE_BIOMETRIC_INTERNAL +import android.annotation.RequiresPermission +import android.hardware.biometrics.ComponentInfoInternal import android.hardware.biometrics.SensorLocationInternal +import android.hardware.biometrics.SensorProperties import android.hardware.fingerprint.FingerprintManager +import android.hardware.fingerprint.FingerprintSensorProperties import android.hardware.fingerprint.FingerprintSensorPropertiesInternal import android.hardware.fingerprint.IFingerprintAuthenticatorsRegisteredCallback import com.android.systemui.biometrics.shared.model.FingerprintSensorType import com.android.systemui.biometrics.shared.model.SensorStrength import com.android.systemui.biometrics.shared.model.toSensorStrength +import com.android.systemui.biometrics.shared.model.toSensorType import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLogging import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow import com.android.systemui.dagger.SysUISingleton @@ -31,11 +37,10 @@ import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.flow.asStateFlow -import kotlinx.coroutines.flow.shareIn +import kotlinx.coroutines.flow.map +import kotlinx.coroutines.flow.stateIn /** * A repository for the global state of FingerprintProperty. @@ -44,22 +49,17 @@ import kotlinx.coroutines.flow.shareIn */ interface FingerprintPropertyRepository { - /** - * If the repository is initialized or not. Other properties are defaults until this is true. - */ - val isInitialized: Flow<Boolean> - /** The id of fingerprint sensor. */ - val sensorId: StateFlow<Int> + val sensorId: Flow<Int> /** The security strength of sensor (convenience, weak, strong). */ - val strength: StateFlow<SensorStrength> + val strength: Flow<SensorStrength> /** The types of fingerprint sensor (rear, ultrasonic, optical, etc.). */ - val sensorType: StateFlow<FingerprintSensorType> + val sensorType: Flow<FingerprintSensorType> /** The sensor location relative to each physical display. */ - val sensorLocations: StateFlow<Map<String, SensorLocationInternal>> + val sensorLocations: Flow<Map<String, SensorLocationInternal>> } @SysUISingleton @@ -70,64 +70,64 @@ constructor( private val fingerprintManager: FingerprintManager?, ) : FingerprintPropertyRepository { - override val isInitialized: Flow<Boolean> = + @RequiresPermission(USE_BIOMETRIC_INTERNAL) + private val props: StateFlow<FingerprintSensorPropertiesInternal> = conflatedCallbackFlow { val callback = object : IFingerprintAuthenticatorsRegisteredCallback.Stub() { override fun onAllAuthenticatorsRegistered( sensors: List<FingerprintSensorPropertiesInternal> ) { - if (sensors.isNotEmpty()) { - setProperties(sensors[0]) - trySendWithFailureLogging(true, TAG, "initialize properties") + if (sensors.isEmpty()) { + trySendWithFailureLogging( + DEFAULT_PROPS, + TAG, + "no registered sensors, use default props" + ) + } else { + trySendWithFailureLogging( + sensors[0], + TAG, + "update properties on authenticators registered" + ) } } } fingerprintManager?.addAuthenticatorsRegisteredCallback(callback) - trySendWithFailureLogging(false, TAG, "initial value defaulting to false") awaitClose {} } - .shareIn(scope = applicationScope, started = SharingStarted.Eagerly, replay = 1) - - private val _sensorId: MutableStateFlow<Int> = MutableStateFlow(-1) - override val sensorId: StateFlow<Int> = _sensorId.asStateFlow() + .stateIn( + applicationScope, + started = SharingStarted.Eagerly, + initialValue = DEFAULT_PROPS, + ) - private val _strength: MutableStateFlow<SensorStrength> = - MutableStateFlow(SensorStrength.CONVENIENCE) - override val strength = _strength.asStateFlow() + override val sensorId: Flow<Int> = props.map { it.sensorId } - private val _sensorType: MutableStateFlow<FingerprintSensorType> = - MutableStateFlow(FingerprintSensorType.UNKNOWN) - override val sensorType = _sensorType.asStateFlow() + override val strength: Flow<SensorStrength> = props.map { it.sensorStrength.toSensorStrength() } - private val _sensorLocations: MutableStateFlow<Map<String, SensorLocationInternal>> = - MutableStateFlow(mapOf("" to SensorLocationInternal.DEFAULT)) - override val sensorLocations: StateFlow<Map<String, SensorLocationInternal>> = - _sensorLocations.asStateFlow() + override val sensorType: Flow<FingerprintSensorType> = + props.map { it.sensorType.toSensorType() } - private fun setProperties(prop: FingerprintSensorPropertiesInternal) { - _sensorId.value = prop.sensorId - _strength.value = prop.sensorStrength.toSensorStrength() - _sensorType.value = sensorTypeIntToObject(prop.sensorType) - _sensorLocations.value = - prop.allLocations.associateBy { sensorLocationInternal -> + override val sensorLocations: Flow<Map<String, SensorLocationInternal>> = + props.map { + it.allLocations.associateBy { sensorLocationInternal -> sensorLocationInternal.displayId } - } + } companion object { private const val TAG = "FingerprintPropertyRepositoryImpl" - } -} - -private fun sensorTypeIntToObject(value: Int): FingerprintSensorType { - return when (value) { - 0 -> FingerprintSensorType.UNKNOWN - 1 -> FingerprintSensorType.REAR - 2 -> FingerprintSensorType.UDFPS_ULTRASONIC - 3 -> FingerprintSensorType.UDFPS_OPTICAL - 4 -> FingerprintSensorType.POWER_BUTTON - 5 -> FingerprintSensorType.HOME_BUTTON - else -> throw IllegalArgumentException("Invalid SensorType value: $value") + private val DEFAULT_PROPS = + FingerprintSensorPropertiesInternal( + -1 /* sensorId */, + SensorProperties.STRENGTH_CONVENIENCE, + 0 /* maxEnrollmentsPerUser */, + listOf<ComponentInfoInternal>(), + FingerprintSensorProperties.TYPE_UNKNOWN, + false /* halControlsIllumination */, + true /* resetLockoutRequiresHardwareAuthToken */, + listOf<SensorLocationInternal>(SensorLocationInternal.DEFAULT) + ) } } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/PromptSelectorInteractor.kt b/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/PromptSelectorInteractor.kt index 5badcaf06003..a6ad24e47edb 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/PromptSelectorInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/PromptSelectorInteractor.kt @@ -32,7 +32,6 @@ import com.android.systemui.biometrics.shared.model.PromptKind import com.android.systemui.dagger.SysUISingleton import javax.inject.Inject import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.map @@ -69,7 +68,7 @@ interface PromptSelectorInteractor { val isConfirmationRequired: Flow<Boolean> /** Fingerprint sensor type */ - val sensorType: StateFlow<FingerprintSensorType> + val sensorType: Flow<FingerprintSensorType> /** Use biometrics for authentication. */ fun useBiometricsForAuthentication( @@ -95,7 +94,7 @@ interface PromptSelectorInteractor { class PromptSelectorInteractorImpl @Inject constructor( - private val fingerprintPropertyRepository: FingerprintPropertyRepository, + fingerprintPropertyRepository: FingerprintPropertyRepository, private val promptRepository: PromptRepository, lockPatternUtils: LockPatternUtils, ) : PromptSelectorInteractor { @@ -147,8 +146,7 @@ constructor( } } - override val sensorType: StateFlow<FingerprintSensorType> = - fingerprintPropertyRepository.sensorType + override val sensorType: Flow<FingerprintSensorType> = fingerprintPropertyRepository.sensorType override fun useBiometricsForAuthentication( promptInfo: PromptInfo, diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/SideFpsOverlayInteractor.kt b/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/SideFpsOverlayInteractor.kt index aa85e5f3b21a..75ae061f8cce 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/SideFpsOverlayInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/SideFpsOverlayInteractor.kt @@ -17,32 +17,43 @@ package com.android.systemui.biometrics.domain.interactor import android.hardware.biometrics.SensorLocationInternal -import android.util.Log import com.android.systemui.biometrics.data.repository.FingerprintPropertyRepository import com.android.systemui.dagger.SysUISingleton import javax.inject.Inject +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.combine /** Business logic for SideFps overlay offsets. */ interface SideFpsOverlayInteractor { - /** Get the corresponding offsets based on different displayId. */ - fun getOverlayOffsets(displayId: String): SensorLocationInternal + /** The displayId of the current display. */ + val displayId: Flow<String> + + /** Overlay offsets corresponding to given displayId. */ + val overlayOffsets: Flow<SensorLocationInternal> + + /** Called on display changes, used to keep the display state in sync */ + fun onDisplayChanged(displayId: String) } @SysUISingleton class SideFpsOverlayInteractorImpl @Inject -constructor(private val fingerprintPropertyRepository: FingerprintPropertyRepository) : +constructor(fingerprintPropertyRepository: FingerprintPropertyRepository) : SideFpsOverlayInteractor { - override fun getOverlayOffsets(displayId: String): SensorLocationInternal { - val offsets = fingerprintPropertyRepository.sensorLocations.value - return if (offsets.containsKey(displayId)) { - offsets[displayId]!! - } else { - Log.w(TAG, "No location specified for display: $displayId") - offsets[""]!! + private val _displayId: MutableStateFlow<String> = MutableStateFlow("") + override val displayId: Flow<String> = _displayId.asStateFlow() + + override val overlayOffsets: Flow<SensorLocationInternal> = + combine(displayId, fingerprintPropertyRepository.sensorLocations) { displayId, offsets -> + offsets[displayId] ?: SensorLocationInternal.DEFAULT } + + override fun onDisplayChanged(displayId: String) { + _displayId.value = displayId } companion object { diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/shared/model/FingerprintSensorType.kt b/packages/SystemUI/src/com/android/systemui/biometrics/shared/model/FingerprintSensorType.kt index df5cefdb876d..c6fdcb318998 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/shared/model/FingerprintSensorType.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/shared/model/FingerprintSensorType.kt @@ -27,3 +27,15 @@ enum class FingerprintSensorType { POWER_BUTTON, HOME_BUTTON, } + +/** Convert [this] to corresponding [FingerprintSensorType] */ +fun Int.toSensorType(): FingerprintSensorType = + when (this) { + FingerprintSensorProperties.TYPE_UNKNOWN -> FingerprintSensorType.UNKNOWN + FingerprintSensorProperties.TYPE_REAR -> FingerprintSensorType.REAR + FingerprintSensorProperties.TYPE_UDFPS_ULTRASONIC -> FingerprintSensorType.UDFPS_ULTRASONIC + FingerprintSensorProperties.TYPE_UDFPS_OPTICAL -> FingerprintSensorType.UDFPS_OPTICAL + FingerprintSensorProperties.TYPE_POWER_BUTTON -> FingerprintSensorType.POWER_BUTTON + FingerprintSensorProperties.TYPE_HOME_BUTTON -> FingerprintSensorType.HOME_BUTTON + else -> throw IllegalArgumentException("Invalid SensorType value: $this") + } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/shared/model/SensorStrength.kt b/packages/SystemUI/src/com/android/systemui/biometrics/shared/model/SensorStrength.kt index 30e865eff8b8..476daac5ff00 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/shared/model/SensorStrength.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/shared/model/SensorStrength.kt @@ -28,8 +28,8 @@ enum class SensorStrength { /** Convert [this] to corresponding [SensorStrength] */ fun Int.toSensorStrength(): SensorStrength = when (this) { - 0 -> SensorStrength.CONVENIENCE - 1 -> SensorStrength.WEAK - 2 -> SensorStrength.STRONG + SensorProperties.STRENGTH_CONVENIENCE -> SensorStrength.CONVENIENCE + SensorProperties.STRENGTH_WEAK -> SensorStrength.WEAK + SensorProperties.STRENGTH_STRONG -> SensorStrength.STRONG else -> throw IllegalArgumentException("Invalid SensorStrength value: $this") } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptFingerprintIconViewModel.kt b/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptFingerprintIconViewModel.kt index 9b30acb84428..b406ea41eff0 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptFingerprintIconViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptFingerprintIconViewModel.kt @@ -33,7 +33,7 @@ class PromptFingerprintIconViewModel @Inject constructor( private val displayStateInteractor: DisplayStateInteractor, - private val promptSelectorInteractor: PromptSelectorInteractor, + promptSelectorInteractor: PromptSelectorInteractor, ) { /** Current device rotation. */ private var rotation: Int = Surface.ROTATION_0 diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/FingerprintRepositoryImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/FingerprintRepositoryImplTest.kt index 239e317b92f5..ed9ae5e3dc01 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/FingerprintRepositoryImplTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/FingerprintRepositoryImplTest.kt @@ -29,6 +29,7 @@ import com.android.systemui.biometrics.shared.model.FingerprintSensorType import com.android.systemui.biometrics.shared.model.SensorStrength import com.android.systemui.coroutines.collectLastValue import com.google.common.truth.Truth.assertThat +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.runCurrent @@ -44,6 +45,7 @@ import org.mockito.Mock import org.mockito.Mockito.verify import org.mockito.junit.MockitoJUnit +@OptIn(ExperimentalCoroutinesApi::class) @SmallTest @RunWith(JUnit4::class) class FingerprintRepositoryImplTest : SysuiTestCase() { @@ -73,10 +75,15 @@ class FingerprintRepositoryImplTest : SysuiTestCase() { @Test fun initializeProperties() = testScope.runTest { - val isInitialized = collectLastValue(repository.isInitialized) + val sensorId by collectLastValue(repository.sensorId) + val strength by collectLastValue(repository.strength) + val sensorType by collectLastValue(repository.sensorType) + val sensorLocations by collectLastValue(repository.sensorLocations) - assertDefaultProperties() - assertThat(isInitialized()).isFalse() + // Assert default properties. + assertThat(sensorId).isEqualTo(-1) + assertThat(strength).isEqualTo(SensorStrength.CONVENIENCE) + assertThat(sensorType).isEqualTo(FingerprintSensorType.UNKNOWN) val fingerprintProps = listOf( @@ -115,31 +122,24 @@ class FingerprintRepositoryImplTest : SysuiTestCase() { fingerprintAuthenticatorsCaptor.value.onAllAuthenticatorsRegistered(fingerprintProps) - assertThat(repository.sensorId.value).isEqualTo(1) - assertThat(repository.strength.value).isEqualTo(SensorStrength.STRONG) - assertThat(repository.sensorType.value).isEqualTo(FingerprintSensorType.REAR) + assertThat(sensorId).isEqualTo(1) + assertThat(strength).isEqualTo(SensorStrength.STRONG) + assertThat(sensorType).isEqualTo(FingerprintSensorType.REAR) - assertThat(repository.sensorLocations.value.size).isEqualTo(2) - assertThat(repository.sensorLocations.value).containsKey("display_id_1") - with(repository.sensorLocations.value["display_id_1"]!!) { + assertThat(sensorLocations?.size).isEqualTo(2) + assertThat(sensorLocations).containsKey("display_id_1") + with(sensorLocations?.get("display_id_1")!!) { assertThat(displayId).isEqualTo("display_id_1") assertThat(sensorLocationX).isEqualTo(100) assertThat(sensorLocationY).isEqualTo(300) assertThat(sensorRadius).isEqualTo(20) } - assertThat(repository.sensorLocations.value).containsKey("") - with(repository.sensorLocations.value[""]!!) { + assertThat(sensorLocations).containsKey("") + with(sensorLocations?.get("")!!) { assertThat(displayId).isEqualTo("") assertThat(sensorLocationX).isEqualTo(540) assertThat(sensorLocationY).isEqualTo(1636) assertThat(sensorRadius).isEqualTo(130) } - assertThat(isInitialized()).isTrue() } - - private fun assertDefaultProperties() { - assertThat(repository.sensorId.value).isEqualTo(-1) - assertThat(repository.strength.value).isEqualTo(SensorStrength.CONVENIENCE) - assertThat(repository.sensorType.value).isEqualTo(FingerprintSensorType.UNKNOWN) - } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/domain/interactor/SideFpsOverlayInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/domain/interactor/SideFpsOverlayInteractorTest.kt index fd96cf45504b..712eef13421b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/domain/interactor/SideFpsOverlayInteractorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/domain/interactor/SideFpsOverlayInteractorTest.kt @@ -22,6 +22,7 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.biometrics.data.repository.FakeFingerprintPropertyRepository import com.android.systemui.biometrics.shared.model.FingerprintSensorType import com.android.systemui.biometrics.shared.model.SensorStrength +import com.android.systemui.coroutines.collectLastValue import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.StandardTestDispatcher import kotlinx.coroutines.test.TestScope @@ -51,7 +52,7 @@ class SideFpsOverlayInteractorTest : SysuiTestCase() { } @Test - fun testGetOverlayOffsets() = + fun testOverlayOffsetUpdates() = testScope.runTest { fingerprintRepository.setProperties( sensorId = 1, @@ -76,16 +77,32 @@ class SideFpsOverlayInteractorTest : SysuiTestCase() { ) ) - var offsets = interactor.getOverlayOffsets("display_id_1") - assertThat(offsets.displayId).isEqualTo("display_id_1") - assertThat(offsets.sensorLocationX).isEqualTo(100) - assertThat(offsets.sensorLocationY).isEqualTo(300) - assertThat(offsets.sensorRadius).isEqualTo(20) + val displayId by collectLastValue(interactor.displayId) + val offsets by collectLastValue(interactor.overlayOffsets) - offsets = interactor.getOverlayOffsets("invalid_display_id") - assertThat(offsets.displayId).isEqualTo("") - assertThat(offsets.sensorLocationX).isEqualTo(540) - assertThat(offsets.sensorLocationY).isEqualTo(1636) - assertThat(offsets.sensorRadius).isEqualTo(130) + // Assert offsets of empty displayId. + assertThat(displayId).isEqualTo("") + assertThat(offsets?.displayId).isEqualTo("") + assertThat(offsets?.sensorLocationX).isEqualTo(540) + assertThat(offsets?.sensorLocationY).isEqualTo(1636) + assertThat(offsets?.sensorRadius).isEqualTo(130) + + // Offsets should be updated correctly. + interactor.onDisplayChanged("display_id_1") + assertThat(displayId).isEqualTo("display_id_1") + assertThat(offsets?.displayId).isEqualTo("display_id_1") + assertThat(offsets?.sensorLocationX).isEqualTo(100) + assertThat(offsets?.sensorLocationY).isEqualTo(300) + assertThat(offsets?.sensorRadius).isEqualTo(20) + + // Should return default offset when the displayId is invalid. + interactor.onDisplayChanged("invalid_display_id") + assertThat(displayId).isEqualTo("invalid_display_id") + assertThat(offsets?.displayId).isEqualTo(SensorLocationInternal.DEFAULT.displayId) + assertThat(offsets?.sensorLocationX) + .isEqualTo(SensorLocationInternal.DEFAULT.sensorLocationX) + assertThat(offsets?.sensorLocationY) + .isEqualTo(SensorLocationInternal.DEFAULT.sensorLocationY) + assertThat(offsets?.sensorRadius).isEqualTo(SensorLocationInternal.DEFAULT.sensorRadius) } } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/data/repository/FakeFingerprintPropertyRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/data/repository/FakeFingerprintPropertyRepository.kt index 2362a5241244..0c5e43809fab 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/data/repository/FakeFingerprintPropertyRepository.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/data/repository/FakeFingerprintPropertyRepository.kt @@ -20,16 +20,12 @@ import android.hardware.biometrics.SensorLocationInternal import com.android.systemui.biometrics.shared.model.FingerprintSensorType import com.android.systemui.biometrics.shared.model.SensorStrength import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow class FakeFingerprintPropertyRepository : FingerprintPropertyRepository { - private val _isInitialized: MutableStateFlow<Boolean> = MutableStateFlow(false) - override val isInitialized = _isInitialized.asStateFlow() - private val _sensorId: MutableStateFlow<Int> = MutableStateFlow(-1) - override val sensorId: StateFlow<Int> = _sensorId.asStateFlow() + override val sensorId = _sensorId.asStateFlow() private val _strength: MutableStateFlow<SensorStrength> = MutableStateFlow(SensorStrength.CONVENIENCE) @@ -37,12 +33,11 @@ class FakeFingerprintPropertyRepository : FingerprintPropertyRepository { private val _sensorType: MutableStateFlow<FingerprintSensorType> = MutableStateFlow(FingerprintSensorType.UNKNOWN) - override val sensorType: StateFlow<FingerprintSensorType> = _sensorType.asStateFlow() + override val sensorType = _sensorType.asStateFlow() private val _sensorLocations: MutableStateFlow<Map<String, SensorLocationInternal>> = MutableStateFlow(mapOf("" to SensorLocationInternal.DEFAULT)) - override val sensorLocations: StateFlow<Map<String, SensorLocationInternal>> = - _sensorLocations.asStateFlow() + override val sensorLocations = _sensorLocations.asStateFlow() fun setProperties( sensorId: Int, @@ -54,6 +49,5 @@ class FakeFingerprintPropertyRepository : FingerprintPropertyRepository { _strength.value = strength _sensorType.value = sensorType _sensorLocations.value = sensorLocations - _isInitialized.value = true } } |