Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,12 @@ fun FaceLivenessDetector(
disableStartView,
onChallengeComplete = {
scope.launch {
isFinished = true
resetOrientation()
currentOnComplete.call()
// if we are already finished, we already provided a result in complete or failed
if (!isFinished) {
isFinished = true
resetOrientation()
currentOnComplete.call()
}
}
},
onChallengeFailed = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ import com.amplifyframework.ui.liveness.model.LivenessCheckState
livenessCheckState: LivenessCheckState
) {
val instructionText = livenessCheckState.instructionId?.let { stringResource(it) } ?: return
val showProgress = livenessCheckState is LivenessCheckState.Success
if (livenessCheckState.isActionable) {
FaceOvalInstructionMessage(message = instructionText)
} else {
InstructionMessage(message = instructionText, showProgress = showProgress)
InstructionMessage(message = instructionText, showProgress = true)
}
}
@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class MainViewModel : ViewModel() {
}

fun fetchSessionResult(sessionId: String) {
if (_resultData.value != null) return //we already have result, likely timeout

_fetchingResult.value = true
viewModelScope.launch {
try {
Expand Down Expand Up @@ -125,6 +127,7 @@ class MainViewModel : ViewModel() {
fun reportErrorResult(exception: FaceLivenessDetectionException) {
sessionId.value?.let {
_resultData.value = ResultData(it, error = exception)
_fetchingResult.value = false
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,16 @@ private fun getDisplayError(error: FaceLivenessDetectionException): DisplayError
is FaceLivenessDetectionException.SessionTimedOutException -> {
DisplayError(
title = stringResource(id = R.string.error_timed_out_title),
message = if (error.message.contains("did not match oval", true)) {
stringResource(id = R.string.error_timed_out_face_fit_message)
} else {
stringResource(id = R.string.error_timed_out_session_message)
}
message = stringResource(id = R.string.error_timed_out_session_message)
)
}
else -> {
if (error.message.contains("failed during countdown", ignoreCase = true)) {
if (error.message.contains("did not match oval", true)) {
DisplayError(
title = stringResource(id = R.string.error_timed_out_title),
message = stringResource(id = R.string.error_timed_out_face_fit_message)
)
} else if (error.message.contains("failed during countdown", ignoreCase = true)) {
DisplayError(
title = stringResource(id = R.string.error_failure_during_countdown_title),
message = stringResource(id = R.string.error_failure_during_countdown_message)
Expand Down