Fixes #3484 - Correctly interpret application state transitions for the screen lock when running on the Mac

This commit is contained in:
Stefan Ceriu
2025-05-07 17:51:44 +03:00
parent 08a7a50691
commit d77bad61dd
@@ -154,13 +154,13 @@ class AppLockFlowCoordinator: CoordinatorProtocol {
guard appLockService.computeNeedsUnlock(didBecomeActiveAt: .now) else { return .unlocked }
return isBiometricUnlockAvailable ? .attemptingBiometricUnlock : .attemptingPINUnlock
case (.attemptingBiometricUnlock, .didFinishBiometricUnlock(let result)):
return .dismissingBiometricUnlock(result) // Transitional state until the app becomes active again.
case (.dismissingBiometricUnlock(let result), .didBecomeActive):
return switch result {
case .unlocked: .unlocked
case .failed: .attemptingPINUnlock
case .interrupted: .attemptingBiometricUnlock
if ProcessInfo.processInfo.isiOSAppOnMac { // On the Mac the app is already active at this point
return result.toStateMachineState()
} else { // On iOS on the other hand it, biometrics keep it non-active
return .dismissingBiometricUnlock(result) // Transitional state until the app becomes active again.
}
case (.dismissingBiometricUnlock(let result), .didBecomeActive):
return result.toStateMachineState()
case (.attemptingPINUnlock, .didUnlockWithPIN):
return .unlocked
case (.attemptingPINUnlock, .forceLogout):
@@ -246,3 +246,13 @@ class AppLockFlowCoordinator: CoordinatorProtocol {
actionsSubject.send(.lockApp)
}
}
private extension AppLockServiceBiometricResult {
func toStateMachineState() -> AppLockFlowCoordinator.State {
switch self {
case .unlocked: .unlocked
case .failed: .attemptingPINUnlock
case .interrupted: .attemptingBiometricUnlock
}
}
}