Skip to content

Commit dde21fd

Browse files
authored
chore: kickoff release
2 parents b1bb0db + f13bf5e commit dde21fd

File tree

6 files changed

+20
-2
lines changed

6 files changed

+20
-2
lines changed

HostApp/HostApp/Views/ExampleLivenessView.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ struct ExampleLivenessView: View {
4545
viewModel.presentationState = .error(.countdownFaceTooClose)
4646
case .failure(.invalidSignature):
4747
viewModel.presentationState = .error(.invalidSignature)
48+
case .failure(.cameraNotAvailable):
49+
viewModel.presentationState = .error(.cameraNotAvailable)
4850
default:
4951
viewModel.presentationState = .liveness
5052
}
@@ -74,6 +76,8 @@ struct ExampleLivenessView: View {
7476
LivenessCheckErrorContentView.failedDuringCountdown
7577
case .invalidSignature:
7678
LivenessCheckErrorContentView.invalidSignature
79+
case .cameraNotAvailable:
80+
LivenessCheckErrorContentView.cameraNotAvailable
7781
default:
7882
LivenessCheckErrorContentView.unexpected
7983
}

HostApp/HostApp/Views/LivenessCheckErrorContentView.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ extension LivenessCheckErrorContentView {
5555
name: "The signature on the request is invalid.",
5656
description: "Ensure the device time is correct and try again."
5757
)
58+
59+
static let cameraNotAvailable = LivenessCheckErrorContentView(
60+
name: "The camera could not be started.",
61+
description: "There might be a hardware issue with the camera."
62+
)
5863
}
5964

6065
struct LivenessCheckErrorContentView_Previews: PreviewProvider {

Sources/FaceLiveness/Views/Liveness/FaceLivenessDetectionError.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ public struct FaceLivenessDetectionError: Error, Equatable {
126126
recoverySuggestion: "Ensure the device time is correct and try again."
127127
)
128128

129+
public static let cameraNotAvailable = FaceLivenessDetectionError(
130+
code: 18,
131+
message: "The camera is not available.",
132+
recoverySuggestion: "There might be a hardware issue."
133+
)
134+
129135
public static func == (lhs: FaceLivenessDetectionError, rhs: FaceLivenessDetectionError) -> Bool {
130136
lhs.code == rhs.code
131137
}

Sources/FaceLiveness/Views/Liveness/FaceLivenessDetectionView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ public struct FaceLivenessDetectorView: View {
205205
return .faceInOvalMatchExceededTimeLimitError
206206
case .socketClosed:
207207
return .socketClosed
208+
case .cameraNotAvailable:
209+
return .cameraNotAvailable
208210
default:
209211
return .cameraPermissionDenied
210212
}

Sources/FaceLiveness/Views/Liveness/FaceLivenessDetectionViewModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ class FaceLivenessDetectionViewModel: ObservableObject {
338338
switch captureSessionError {
339339
case LivenessCaptureSessionError.cameraUnavailable,
340340
LivenessCaptureSessionError.deviceInputUnavailable:
341-
342-
livenessError = .missingVideoPermission
341+
let authStatus = AVCaptureDevice.authorizationStatus(for: .video)
342+
livenessError = authStatus == .authorized ? .cameraNotAvailable : .missingVideoPermission
343343
case LivenessCaptureSessionError.captureSessionOutputUnavailable,
344344
LivenessCaptureSessionError.captureSessionInputUnavailable:
345345

Sources/FaceLiveness/Views/Liveness/LivenessStateMachine.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ struct LivenessStateMachine {
159159
static let couldNotOpenStream = LivenessError(code: 5, webSocketCloseCode: .unexpectedRuntimeError)
160160
static let socketClosed = LivenessError(code: 6, webSocketCloseCode: .normalClosure)
161161
static let viewResignation = LivenessError(code: 8, webSocketCloseCode: .viewClosure)
162+
static let cameraNotAvailable = LivenessError(code: 9, webSocketCloseCode: .missingVideoPermission)
162163

163164
static func == (lhs: LivenessError, rhs: LivenessError) -> Bool {
164165
lhs.code == rhs.code

0 commit comments

Comments
 (0)