File tree Expand file tree Collapse file tree 4 files changed +17
-11
lines changed
liveness/src/main/java/com/amplifyframework/ui/liveness/ui
samples/liveness/app/src/main/java/com/amplifyframework/ui/sample/liveness Expand file tree Collapse file tree 4 files changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -124,9 +124,12 @@ fun FaceLivenessDetector(
124124 disableStartView,
125125 onChallengeComplete = {
126126 scope.launch {
127- isFinished = true
128- resetOrientation()
129- currentOnComplete.call()
127+ // if we are already finished, we already provided a result in complete or failed
128+ if (! isFinished) {
129+ isFinished = true
130+ resetOrientation()
131+ currentOnComplete.call()
132+ }
130133 }
131134 },
132135 onChallengeFailed = {
Original file line number Diff line number Diff line change @@ -46,11 +46,10 @@ import com.amplifyframework.ui.liveness.model.LivenessCheckState
4646 livenessCheckState : LivenessCheckState
4747) {
4848 val instructionText = livenessCheckState.instructionId?.let { stringResource(it) } ? : return
49- val showProgress = livenessCheckState is LivenessCheckState .Success
5049 if (livenessCheckState.isActionable) {
5150 FaceOvalInstructionMessage (message = instructionText)
5251 } else {
53- InstructionMessage (message = instructionText, showProgress = showProgress )
52+ InstructionMessage (message = instructionText, showProgress = true )
5453 }
5554}
5655@Composable
Original file line number Diff line number Diff line change @@ -88,6 +88,8 @@ class MainViewModel : ViewModel() {
8888 }
8989
9090 fun fetchSessionResult (sessionId : String ) {
91+ if (_resultData .value != null ) return // we already have result, likely timeout
92+
9193 _fetchingResult .value = true
9294 viewModelScope.launch {
9395 try {
@@ -125,6 +127,7 @@ class MainViewModel : ViewModel() {
125127 fun reportErrorResult (exception : FaceLivenessDetectionException ) {
126128 sessionId.value?.let {
127129 _resultData .value = ResultData (it, error = exception)
130+ _fetchingResult .value = false
128131 }
129132 }
130133
Original file line number Diff line number Diff line change @@ -299,15 +299,16 @@ private fun getDisplayError(error: FaceLivenessDetectionException): DisplayError
299299 is FaceLivenessDetectionException .SessionTimedOutException -> {
300300 DisplayError (
301301 title = stringResource(id = R .string.error_timed_out_title),
302- message = if (error.message.contains(" did not match oval" , true )) {
303- stringResource(id = R .string.error_timed_out_face_fit_message)
304- } else {
305- stringResource(id = R .string.error_timed_out_session_message)
306- }
302+ message = stringResource(id = R .string.error_timed_out_session_message)
307303 )
308304 }
309305 else -> {
310- if (error.message.contains(" failed during countdown" , ignoreCase = true )) {
306+ if (error.message.contains(" did not match oval" , true )) {
307+ DisplayError (
308+ title = stringResource(id = R .string.error_timed_out_title),
309+ message = stringResource(id = R .string.error_timed_out_face_fit_message)
310+ )
311+ } else if (error.message.contains(" failed during countdown" , ignoreCase = true )) {
311312 DisplayError (
312313 title = stringResource(id = R .string.error_failure_during_countdown_title),
313314 message = stringResource(id = R .string.error_failure_during_countdown_message)
You can’t perform that action at this time.
0 commit comments