Skip to content

Commit

Permalink
chore: kickoff release
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisabhash authored Aug 6, 2024
2 parents b1bb0db + f13bf5e commit dde21fd
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions HostApp/HostApp/Views/ExampleLivenessView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ struct ExampleLivenessView: View {
viewModel.presentationState = .error(.countdownFaceTooClose)
case .failure(.invalidSignature):
viewModel.presentationState = .error(.invalidSignature)
case .failure(.cameraNotAvailable):
viewModel.presentationState = .error(.cameraNotAvailable)
default:
viewModel.presentationState = .liveness
}
Expand Down Expand Up @@ -74,6 +76,8 @@ struct ExampleLivenessView: View {
LivenessCheckErrorContentView.failedDuringCountdown
case .invalidSignature:
LivenessCheckErrorContentView.invalidSignature
case .cameraNotAvailable:
LivenessCheckErrorContentView.cameraNotAvailable
default:
LivenessCheckErrorContentView.unexpected
}
Expand Down
5 changes: 5 additions & 0 deletions HostApp/HostApp/Views/LivenessCheckErrorContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ extension LivenessCheckErrorContentView {
name: "The signature on the request is invalid.",
description: "Ensure the device time is correct and try again."
)

static let cameraNotAvailable = LivenessCheckErrorContentView(
name: "The camera could not be started.",
description: "There might be a hardware issue with the camera."
)
}

struct LivenessCheckErrorContentView_Previews: PreviewProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ public struct FaceLivenessDetectionError: Error, Equatable {
recoverySuggestion: "Ensure the device time is correct and try again."
)

public static let cameraNotAvailable = FaceLivenessDetectionError(
code: 18,
message: "The camera is not available.",
recoverySuggestion: "There might be a hardware issue."
)

public static func == (lhs: FaceLivenessDetectionError, rhs: FaceLivenessDetectionError) -> Bool {
lhs.code == rhs.code
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ public struct FaceLivenessDetectorView: View {
return .faceInOvalMatchExceededTimeLimitError
case .socketClosed:
return .socketClosed
case .cameraNotAvailable:
return .cameraNotAvailable
default:
return .cameraPermissionDenied
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ class FaceLivenessDetectionViewModel: ObservableObject {
switch captureSessionError {
case LivenessCaptureSessionError.cameraUnavailable,
LivenessCaptureSessionError.deviceInputUnavailable:

livenessError = .missingVideoPermission
let authStatus = AVCaptureDevice.authorizationStatus(for: .video)
livenessError = authStatus == .authorized ? .cameraNotAvailable : .missingVideoPermission
case LivenessCaptureSessionError.captureSessionOutputUnavailable,
LivenessCaptureSessionError.captureSessionInputUnavailable:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ struct LivenessStateMachine {
static let couldNotOpenStream = LivenessError(code: 5, webSocketCloseCode: .unexpectedRuntimeError)
static let socketClosed = LivenessError(code: 6, webSocketCloseCode: .normalClosure)
static let viewResignation = LivenessError(code: 8, webSocketCloseCode: .viewClosure)
static let cameraNotAvailable = LivenessError(code: 9, webSocketCloseCode: .missingVideoPermission)

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

0 comments on commit dde21fd

Please sign in to comment.