Disable biometric unlock when we disable pin code unlock (#6781)

* Disable biometric unlock when we disable pin code unlock
This commit is contained in:
Jorge Martin Espinosa 2026-05-18 22:19:22 +02:00 committed by GitHub
parent 603c4feda1
commit 60a2d35be7
5 changed files with 19 additions and 5 deletions

View file

@ -43,7 +43,7 @@ class DefaultLockScreenService(
private val coroutineScope: CoroutineScope, private val coroutineScope: CoroutineScope,
private val sessionObserver: SessionObserver, private val sessionObserver: SessionObserver,
private val appForegroundStateService: AppForegroundStateService, private val appForegroundStateService: AppForegroundStateService,
biometricAuthenticatorManager: BiometricAuthenticatorManager, private val biometricAuthenticatorManager: BiometricAuthenticatorManager,
) : LockScreenService { ) : LockScreenService {
private val _lockState = MutableStateFlow<LockScreenLockState>(LockScreenLockState.Unlocked) private val _lockState = MutableStateFlow<LockScreenLockState>(LockScreenLockState.Unlocked)
override val lockState: StateFlow<LockScreenLockState> = _lockState override val lockState: StateFlow<LockScreenLockState> = _lockState
@ -81,6 +81,7 @@ class DefaultLockScreenService(
override suspend fun onSessionDeleted(userId: String, wasLastSession: Boolean) { override suspend fun onSessionDeleted(userId: String, wasLastSession: Boolean) {
if (wasLastSession) { if (wasLastSession) {
pinCodeManager.deletePinCode() pinCodeManager.deletePinCode()
biometricAuthenticatorManager.disable()
} }
} }
}) })

View file

@ -24,6 +24,11 @@ interface BiometricAuthenticatorManager {
fun addCallback(callback: BiometricAuthenticator.Callback) fun addCallback(callback: BiometricAuthenticator.Callback)
fun removeCallback(callback: BiometricAuthenticator.Callback) fun removeCallback(callback: BiometricAuthenticator.Callback)
/**
* Disable using the biometric unlock feature and remove any data associated with it.
*/
suspend fun disable()
/** /**
* Remember a biometric authenticator ready for unlocking the app. * Remember a biometric authenticator ready for unlocking the app.
*/ */

View file

@ -80,10 +80,7 @@ class DefaultBiometricAuthenticatorManager(
private val internalCallback = object : DefaultBiometricUnlockCallback() { private val internalCallback = object : DefaultBiometricUnlockCallback() {
override fun onBiometricSetupError() { override fun onBiometricSetupError() {
coroutineScope.launch { coroutineScope.launch { disable() }
lockScreenStore.setIsBiometricUnlockAllowed(false)
secretKeyRepository.deleteKey(SECRET_KEY_ALIAS)
}
} }
} }
@ -120,6 +117,11 @@ class DefaultBiometricAuthenticatorManager(
) )
} }
override suspend fun disable() {
lockScreenStore.setIsBiometricUnlockAllowed(false)
secretKeyRepository.deleteKey(SECRET_KEY_ALIAS)
}
@Composable @Composable
private fun rememberBiometricAuthenticator( private fun rememberBiometricAuthenticator(
isAvailable: Boolean, isAvailable: Boolean,

View file

@ -59,6 +59,7 @@ class LockScreenSettingsPresenter(
if (showRemovePinConfirmation) { if (showRemovePinConfirmation) {
showRemovePinConfirmation = false showRemovePinConfirmation = false
pinCodeManager.deletePinCode() pinCodeManager.deletePinCode()
biometricAuthenticatorManager.disable()
} }
} }
} }

View file

@ -15,6 +15,7 @@ class FakeBiometricAuthenticatorManager(
override var isDeviceSecured: Boolean = true, override var isDeviceSecured: Boolean = true,
override var hasAvailableAuthenticator: Boolean = false, override var hasAvailableAuthenticator: Boolean = false,
private val createBiometricAuthenticator: () -> BiometricAuthenticator = { FakeBiometricAuthenticator() }, private val createBiometricAuthenticator: () -> BiometricAuthenticator = { FakeBiometricAuthenticator() },
private val disableLambda: suspend () -> Unit = { },
) : BiometricAuthenticatorManager { ) : BiometricAuthenticatorManager {
override fun addCallback(callback: BiometricAuthenticator.Callback) { override fun addCallback(callback: BiometricAuthenticator.Callback) {
// no-op // no-op
@ -37,4 +38,8 @@ class FakeBiometricAuthenticatorManager(
createBiometricAuthenticator() createBiometricAuthenticator()
} }
} }
override suspend fun disable() {
disableLambda()
}
} }