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 } guard appLockService.computeNeedsUnlock(didBecomeActiveAt: .now) else { return .unlocked }
return isBiometricUnlockAvailable ? .attemptingBiometricUnlock : .attemptingPINUnlock return isBiometricUnlockAvailable ? .attemptingBiometricUnlock : .attemptingPINUnlock
case (.attemptingBiometricUnlock, .didFinishBiometricUnlock(let result)): case (.attemptingBiometricUnlock, .didFinishBiometricUnlock(let result)):
return .dismissingBiometricUnlock(result) // Transitional state until the app becomes active again. if ProcessInfo.processInfo.isiOSAppOnMac { // On the Mac the app is already active at this point
case (.dismissingBiometricUnlock(let result), .didBecomeActive): return result.toStateMachineState()
return switch result { } else { // On iOS on the other hand it, biometrics keep it non-active
case .unlocked: .unlocked return .dismissingBiometricUnlock(result) // Transitional state until the app becomes active again.
case .failed: .attemptingPINUnlock
case .interrupted: .attemptingBiometricUnlock
} }
case (.dismissingBiometricUnlock(let result), .didBecomeActive):
return result.toStateMachineState()
case (.attemptingPINUnlock, .didUnlockWithPIN): case (.attemptingPINUnlock, .didUnlockWithPIN):
return .unlocked return .unlocked
case (.attemptingPINUnlock, .forceLogout): case (.attemptingPINUnlock, .forceLogout):
@@ -246,3 +246,13 @@ class AppLockFlowCoordinator: CoordinatorProtocol {
actionsSubject.send(.lockApp) actionsSubject.send(.lockApp)
} }
} }
private extension AppLockServiceBiometricResult {
func toStateMachineState() -> AppLockFlowCoordinator.State {
switch self {
case .unlocked: .unlocked
case .failed: .attemptingPINUnlock
case .interrupted: .attemptingBiometricUnlock
}
}
}