Compare commits
1 commit
85dfd44b4f
...
9541c14112
Author | SHA1 | Date | |
---|---|---|---|
9541c14112 |
2 changed files with 25 additions and 13 deletions
|
@ -26,6 +26,7 @@ import kotlinx.coroutines.runBlocking
|
||||||
open class QuickAvailabilityFragment : Fragment(), OpenEuiccContextMarker {
|
open class QuickAvailabilityFragment : Fragment(), OpenEuiccContextMarker {
|
||||||
companion object {
|
companion object {
|
||||||
enum class Compatibility {
|
enum class Compatibility {
|
||||||
|
NOT_SUPPORTED,
|
||||||
COMPATIBLE,
|
COMPATIBLE,
|
||||||
NOT_COMPATIBLE,
|
NOT_COMPATIBLE,
|
||||||
}
|
}
|
||||||
|
@ -36,14 +37,21 @@ open class QuickAvailabilityFragment : Fragment(), OpenEuiccContextMarker {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val conclusion: TextView by lazy { requireView().requireViewById(R.id.quick_availability_conclusion) }
|
private val conclusion: TextView by lazy {
|
||||||
|
requireView().requireViewById(R.id.quick_availability_conclusion)
|
||||||
|
}
|
||||||
|
|
||||||
private val resultSlots: TextView by lazy { requireView().requireViewById(R.id.quick_availability_result_slots) }
|
private val resultSlots: TextView by lazy {
|
||||||
|
requireView().requireViewById(R.id.quick_availability_result_slots)
|
||||||
|
}
|
||||||
|
|
||||||
private val resultNotes: TextView by lazy { requireView().requireViewById(R.id.quick_availability_result_notes) }
|
private val resultNotes: TextView by lazy {
|
||||||
|
requireView().requireViewById(R.id.quick_availability_result_notes)
|
||||||
private val hidden: CheckBox by lazy { requireView().requireViewById(R.id.quick_availability_hidden) }
|
}
|
||||||
|
|
||||||
|
private val hidden: CheckBox by lazy {
|
||||||
|
requireView().requireViewById(R.id.quick_availability_hidden)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
|
@ -58,7 +66,9 @@ open class QuickAvailabilityFragment : Fragment(), OpenEuiccContextMarker {
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
lifecycleScope.launch { onCompatibilityUpdate() }
|
lifecycleScope.launch {
|
||||||
|
onCompatibilityUpdate(getCompatibilityCheckResult())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onContinueToApp() {
|
fun onContinueToApp() {
|
||||||
|
@ -69,8 +79,7 @@ open class QuickAvailabilityFragment : Fragment(), OpenEuiccContextMarker {
|
||||||
(requireActivity() as QuickAvailabilityActivity).launchMainActivity()
|
(requireActivity() as QuickAvailabilityActivity).launchMainActivity()
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun onCompatibilityUpdate() {
|
fun onCompatibilityUpdate(result: CompatibilityResult) {
|
||||||
val result = getCompatibilityCheckResult()
|
|
||||||
conclusion.text = formatConclusion(result)
|
conclusion.text = formatConclusion(result)
|
||||||
if (result.compatibility != Compatibility.COMPATIBLE) return
|
if (result.compatibility != Compatibility.COMPATIBLE) return
|
||||||
resultSlots.isVisible = true
|
resultSlots.isVisible = true
|
||||||
|
@ -82,11 +91,11 @@ open class QuickAvailabilityFragment : Fragment(), OpenEuiccContextMarker {
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getCompatibilityCheckResult(): CompatibilityResult {
|
suspend fun getCompatibilityCheckResult(): CompatibilityResult {
|
||||||
val seService = connectSEService(requireContext())
|
val service = connectSEService(requireContext())
|
||||||
if (!seService.isConnected) {
|
if (!service.isConnected) {
|
||||||
return CompatibilityResult(Compatibility.NOT_COMPATIBLE)
|
return CompatibilityResult(Compatibility.NOT_SUPPORTED)
|
||||||
}
|
}
|
||||||
val slots = seService.readers.filter { it.isSIM }.mapNotNull { reader ->
|
val slots = service.readers.filter { it.isSIM }.mapNotNull { reader ->
|
||||||
try {
|
try {
|
||||||
// Note: we ONLY check the default ISD-R AID, because this test is for the _device_,
|
// 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
|
// NOT the eUICC. We don't care what AID a potential eUICC might use, all we need to
|
||||||
|
@ -99,7 +108,6 @@ open class QuickAvailabilityFragment : Fragment(), OpenEuiccContextMarker {
|
||||||
// SecurityException is only thrown when Channel is constructed, which means everything else needs to succeed
|
// SecurityException is only thrown when Channel is constructed, which means everything else needs to succeed
|
||||||
reader.slotIndex
|
reader.slotIndex
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
// Ignore
|
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,6 +121,9 @@ open class QuickAvailabilityFragment : Fragment(), OpenEuiccContextMarker {
|
||||||
val usbHost = requireContext().packageManager
|
val usbHost = requireContext().packageManager
|
||||||
.hasSystemFeature(PackageManager.FEATURE_USB_HOST)
|
.hasSystemFeature(PackageManager.FEATURE_USB_HOST)
|
||||||
val resId = when (result.compatibility) {
|
val resId = when (result.compatibility) {
|
||||||
|
Compatibility.NOT_SUPPORTED ->
|
||||||
|
R.string.quick_availability_not_supported
|
||||||
|
|
||||||
Compatibility.COMPATIBLE ->
|
Compatibility.COMPATIBLE ->
|
||||||
R.string.quick_availability_compatible
|
R.string.quick_availability_compatible
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
<!-- Quick Availability -->
|
<!-- Quick Availability -->
|
||||||
<string name="quick_availability">Quick Availability</string>
|
<string name="quick_availability">Quick Availability</string>
|
||||||
<string name="quick_availability_compatible">Your smartphone can use %s compatible cards</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">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_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>
|
<string name="quick_availability_result_slots">SIM card slots accessible: %s</string>
|
||||||
|
|
Loading…
Add table
Reference in a new issue