Compare commits

..

1 commit

Author SHA1 Message Date
9541c14112
refactor: activity 2025-07-07 17:00:48 +08:00
2 changed files with 9 additions and 5 deletions

View file

@ -26,6 +26,7 @@ import kotlinx.coroutines.runBlocking
open class QuickAvailabilityFragment : Fragment(), OpenEuiccContextMarker {
companion object {
enum class Compatibility {
NOT_SUPPORTED,
COMPATIBLE,
NOT_COMPATIBLE,
}
@ -90,11 +91,11 @@ open class QuickAvailabilityFragment : Fragment(), OpenEuiccContextMarker {
}
suspend fun getCompatibilityCheckResult(): CompatibilityResult {
val seService = connectSEService(requireContext())
if (!seService.isConnected) {
return CompatibilityResult(Compatibility.NOT_COMPATIBLE)
val service = connectSEService(requireContext())
if (!service.isConnected) {
return CompatibilityResult(Compatibility.NOT_SUPPORTED)
}
val slots = seService.readers.filter { it.isSIM }.mapNotNull { reader ->
val slots = service.readers.filter { it.isSIM }.mapNotNull { reader ->
try {
// Note: we ONLY check the default ISD-R AID, because this test is for the _device_,
// NOT the eUICC. We don't care what AID a potential eUICC might use, all we need to
@ -107,7 +108,6 @@ open class QuickAvailabilityFragment : Fragment(), OpenEuiccContextMarker {
// SecurityException is only thrown when Channel is constructed, which means everything else needs to succeed
reader.slotIndex
} catch (_: Exception) {
// Ignore
null
}
}
@ -121,6 +121,9 @@ open class QuickAvailabilityFragment : Fragment(), OpenEuiccContextMarker {
val usbHost = requireContext().packageManager
.hasSystemFeature(PackageManager.FEATURE_USB_HOST)
val resId = when (result.compatibility) {
Compatibility.NOT_SUPPORTED ->
R.string.quick_availability_not_supported
Compatibility.COMPATIBLE ->
R.string.quick_availability_compatible

View file

@ -14,6 +14,7 @@
<!-- Quick Availability -->
<string name="quick_availability">Quick Availability</string>
<string name="quick_availability_compatible">Your smartphone can use %s compatible cards</string>
<string name="quick_availability_not_supported">Your smartphone is not supported with %s</string>
<string name="quick_availability_not_compatible">Your smartphone is not compatible with %s</string>
<string name="quick_availability_not_compatible_but_usb">Your smartphone is not compatible with %s, but can be managed using a USB smart card reader</string>
<string name="quick_availability_result_slots">SIM card slots accessible: %s</string>