1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 package com.android.systemui.biometrics.data.repository
19 
20 import com.android.systemui.biometrics.shared.model.AuthenticationReason
21 import com.android.systemui.keyguard.shared.model.FingerprintAuthenticationStatus
22 import kotlinx.coroutines.flow.Flow
23 import kotlinx.coroutines.flow.MutableStateFlow
24 import kotlinx.coroutines.flow.StateFlow
25 import kotlinx.coroutines.flow.asStateFlow
26 import kotlinx.coroutines.flow.filterNotNull
27 
28 class FakeBiometricStatusRepository : BiometricStatusRepository {
29     private val _fingerprintAuthenticationReason =
30         MutableStateFlow<AuthenticationReason>(AuthenticationReason.NotRunning)
31     override val fingerprintAuthenticationReason: StateFlow<AuthenticationReason> =
32         _fingerprintAuthenticationReason.asStateFlow()
33 
34     private val _fingerprintAcquiredStatus =
35         MutableStateFlow<FingerprintAuthenticationStatus?>(null)
36     override val fingerprintAcquiredStatus: Flow<FingerprintAuthenticationStatus> =
37         _fingerprintAcquiredStatus.asStateFlow().filterNotNull()
38 
setFingerprintAuthenticationReasonnull39     fun setFingerprintAuthenticationReason(reason: AuthenticationReason) {
40         _fingerprintAuthenticationReason.value = reason
41     }
42 
setFingerprintAcquiredStatusnull43     fun setFingerprintAcquiredStatus(status: FingerprintAuthenticationStatus) {
44         _fingerprintAcquiredStatus.value = status
45     }
46 }
47