Merge "Adding more tests for FingerprintSettingsV2" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
12bf914caf
@@ -26,6 +26,7 @@ import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.last
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@@ -49,7 +50,13 @@ class FingerprintSettingsNavigationViewModel(
|
||||
if (challengeInit == null || tokenInit == null) {
|
||||
_nextStep.update { LaunchConfirmDeviceCredential(userId) }
|
||||
} else {
|
||||
viewModelScope.launch { showSettingsHelper() }
|
||||
viewModelScope.launch {
|
||||
if (fingerprintManagerInteractor.enrolledFingerprints.last().isEmpty()) {
|
||||
_nextStep.update { EnrollFirstFingerprint(userId, null, challenge, token) }
|
||||
} else {
|
||||
showSettingsHelper()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -17,8 +17,7 @@
|
||||
package com.android.settings.biometrics.fingerprint2.ui.viewmodel
|
||||
|
||||
import android.hardware.fingerprint.FingerprintManager
|
||||
import android.hardware.fingerprint.FingerprintSensorProperties.TYPE_UDFPS_OPTICAL
|
||||
import android.hardware.fingerprint.FingerprintSensorProperties.TYPE_UDFPS_ULTRASONIC
|
||||
import android.hardware.fingerprint.FingerprintSensorProperties
|
||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.ViewModel
|
||||
@@ -67,24 +66,6 @@ class FingerprintSettingsViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
fingerprintSensorPropertiesInternal.update {
|
||||
fingerprintManagerInteractor.sensorPropertiesInternal()
|
||||
}
|
||||
}
|
||||
|
||||
viewModelScope.launch {
|
||||
navigationViewModel.nextStep.filterNotNull().collect {
|
||||
_isShowingDialog.update { null }
|
||||
if (it is ShowSettings) {
|
||||
// reset state
|
||||
updateSettingsData()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val _fingerprintStateViewModel: MutableStateFlow<FingerprintStateViewModel?> =
|
||||
MutableStateFlow(null)
|
||||
val fingerprintState: Flow<FingerprintStateViewModel?> =
|
||||
@@ -103,7 +84,6 @@ class FingerprintSettingsViewModel(
|
||||
MutableSharedFlow()
|
||||
|
||||
private val attemptsSoFar: MutableStateFlow<Int> = MutableStateFlow(0)
|
||||
|
||||
/**
|
||||
* This is a very tricky flow. The current fingerprint manager APIs are not robust, and a proper
|
||||
* implementation would take quite a lot of code to implement, it might be easier to rewrite
|
||||
@@ -139,7 +119,13 @@ class FingerprintSettingsViewModel(
|
||||
return@combine false
|
||||
}
|
||||
val sensorType = sensorProps[0].sensorType
|
||||
if (listOf(TYPE_UDFPS_OPTICAL, TYPE_UDFPS_ULTRASONIC).contains(sensorType)) {
|
||||
if (
|
||||
listOf(
|
||||
FingerprintSensorProperties.TYPE_UDFPS_OPTICAL,
|
||||
FingerprintSensorProperties.TYPE_UDFPS_ULTRASONIC
|
||||
)
|
||||
.contains(sensorType)
|
||||
) {
|
||||
return@combine false
|
||||
}
|
||||
|
||||
@@ -182,6 +168,24 @@ class FingerprintSettingsViewModel(
|
||||
}
|
||||
.flowOn(backgroundDispatcher)
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
fingerprintSensorPropertiesInternal.update {
|
||||
fingerprintManagerInteractor.sensorPropertiesInternal()
|
||||
}
|
||||
}
|
||||
|
||||
viewModelScope.launch {
|
||||
navigationViewModel.nextStep.filterNotNull().collect {
|
||||
_isShowingDialog.update { null }
|
||||
if (it is ShowSettings) {
|
||||
// reset state
|
||||
updateSettingsData()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** The rename dialog has finished */
|
||||
fun onRenameDialogFinished() {
|
||||
_isShowingDialog.update { null }
|
||||
|
Reference in New Issue
Block a user