diff --git a/wallet/src/main/java/com/android/identity_credential/wallet/ui/destination/provisioncredential/AusweisModel.kt b/wallet/src/main/java/com/android/identity_credential/wallet/ui/destination/provisioncredential/AusweisModel.kt index 96e301b39..69ac38624 100644 --- a/wallet/src/main/java/com/android/identity_credential/wallet/ui/destination/provisioncredential/AusweisModel.kt +++ b/wallet/src/main/java/com/android/identity_credential/wallet/ui/destination/provisioncredential/AusweisModel.kt @@ -64,6 +64,7 @@ class AusweisModel( data class Auth(val progress: Int): Status() data object NetworkError: Status() data object GenericError: Status() + data object PinError: Status() private lateinit var sdk: IAusweisApp2Sdk private lateinit var sessionId: String @@ -122,7 +123,11 @@ class AusweisModel( fun startWorkflow(simulatedCard: Boolean) { useSimulatedCard = simulatedCard job = coroutineScope.launch { - runAusweisSdk() + try { + runAusweisSdk() + } catch (err: UnexpectedStateException) { + Logger.e(TAG, "Error communicating with the card", err) + } } } @@ -140,7 +145,7 @@ class AusweisModel( fun tryAgain() { status.value = null - navController.navigate(AusweisModel.Route.INITIAL.route) + navController.navigate(Route.INITIAL.route) initialize() } @@ -279,7 +284,13 @@ class AusweisModel( } else if (type == "READER") { // TODO: process READER } else { - throw IllegalStateException("Unexpected message type: $type") + if (type == "ENTER_CAN" || type == "ENTER_PUK") { + status.value = PinError + } else { + status.value = GenericError + } + navController.navigate(Route.ERROR.route) + throw UnexpectedStateException(type ?: "") } } } @@ -306,4 +317,7 @@ class AusweisModel( private fun disableCardScanning(nfcAdapter: NfcAdapter?) { nfcAdapter?.disableReaderMode(context.getActivity()) } + + class UnexpectedStateException(type: String): + IllegalStateException("Unexpected message type: $type") } \ No newline at end of file diff --git a/wallet/src/main/java/com/android/identity_credential/wallet/ui/destination/provisioncredential/EvidenceRequest.kt b/wallet/src/main/java/com/android/identity_credential/wallet/ui/destination/provisioncredential/EvidenceRequest.kt index e210032f7..94343ce7b 100644 --- a/wallet/src/main/java/com/android/identity_credential/wallet/ui/destination/provisioncredential/EvidenceRequest.kt +++ b/wallet/src/main/java/com/android/identity_credential/wallet/ui/destination/provisioncredential/EvidenceRequest.kt @@ -1593,8 +1593,10 @@ fun AusweisView( text = stringResource( if (status.value == AusweisModel.NetworkError) { R.string.eid_network_error + } else if (status.value == AusweisModel.PinError) { + R.string.eid_pin_error } else { - R.string.eid_generic_error + R.string.eid_generic_error }), textAlign = TextAlign.Center, modifier = Modifier.padding(8.dp), diff --git a/wallet/src/main/res/values/strings.xml b/wallet/src/main/res/values/strings.xml index a8fd818f4..a2f22284d 100644 --- a/wallet/src/main/res/values/strings.xml +++ b/wallet/src/main/res/values/strings.xml @@ -389,6 +389,7 @@ Scanning eID using NFC Enter your PIN Error establishing network connection + Incorrect PIN entered too many times. The card is locked. Use Ausweis App to unlock the card. Error scanning or processing the card Try again