Compare commits

...

2 commits

Author SHA1 Message Date
Peter Cai a101ae6805 CompatibilityCheck: Improve OMAPI connectivity check
Some checks failed
/ build-debug (push) Has been cancelled
Stop failing the test if only some slots can be seen. Display a text
warning users of that, but don't appear as a failure.
2024-03-04 18:38:15 -05:00
Peter Cai 49af0ffee9 CompatibilityCheck: Return FAILURE_UNKNOWN when no SIM readers are found 2024-03-04 18:23:53 -05:00
2 changed files with 13 additions and 5 deletions

View file

@ -47,11 +47,13 @@ abstract class CompatibilityCheck(context: Context) {
abstract val title: String
protected abstract val defaultDescription: String
protected lateinit var successDescription: String
protected lateinit var failureDescription: String
val description: String
get() = when {
(state == State.FAILURE || state == State.FAILURE_UNKNOWN) && this::failureDescription.isInitialized -> failureDescription
state == State.SUCCESS && this::successDescription.isInitialized -> successDescription
else -> defaultDescription
}
@ -111,9 +113,9 @@ internal class OmapiConnCheck(private val context: Context): CompatibilityCheck(
failureDescription = context.getString(R.string.compatibility_check_omapi_connectivity_fail)
return State.FAILURE
} else if (simReaders.size < tm.activeModemCountCompat) {
failureDescription = context.getString(R.string.compatibility_check_omapi_connectivity_fail_sim_number,
successDescription = context.getString(R.string.compatibility_check_omapi_connectivity_partial_success_sim_number,
simReaders.map { it.slotIndex }.joinToString(", "))
return State.FAILURE
return State.SUCCESS
}
return State.SUCCESS
@ -132,7 +134,13 @@ internal class IsdrChannelAccessCheck(private val context: Context): Compatibili
override suspend fun doCheck(): State {
val seService = connectSEService(context)
val (validSlotIds, result) = seService.readers.filter { it.isSIM }.map {
val readers = seService.readers.filter { it.isSIM }
if (readers.isEmpty()) {
failureDescription = context.getString(R.string.compatibility_check_isdr_channel_desc_unknown)
return State.FAILURE_UNKNOWN
}
val (validSlotIds, result) = readers.map {
try {
it.openSession().openLogicalChannel(ISDR_AID)?.close()
Pair(it.slotIndex, State.SUCCESS)

View file

@ -9,8 +9,8 @@
<string name="compatibility_check_system_features_no_omapi">Your device has no support for accessing SIM cards via OMAPI.</string>
<string name="compatibility_check_omapi_connectivity">OMAPI Connectivity</string>
<string name="compatibility_check_omapi_connectivity_desc">Does your device allow access to Secure Elements on SIM cards via OMAPI?</string>
<string name="compatibility_check_omapi_connectivity_fail">Unable to detect Secure Element readers for SIM cards via OMAPI.</string>
<string name="compatibility_check_omapi_connectivity_fail_sim_number">Only the following SIM slots are accessible via OMAPI: %s.</string>
<string name="compatibility_check_omapi_connectivity_fail">Unable to detect Secure Element readers for SIM cards via OMAPI. If you have not inserted a SIM in this device, try inserting one and retry this check.</string>
<string name="compatibility_check_omapi_connectivity_partial_success_sim_number">Successfully detected Secure Element access, but only for the following SIM slots: %s.</string>
<string name="compatibility_check_isdr_channel">ISD-R Channel Access</string>
<string name="compatibility_check_isdr_channel_desc">Does your device support opening an ISD-R (management) channel to eSIMs via OMAPI?</string>
<string name="compatibility_check_isdr_channel_desc_unknown">Cannot determine whether ISD-R access through OMAPI is supported. You might want to retry with SIM cards inserted (any SIM card will do) if not already.</string>