瀏覽代碼

core: Disable multi-SE support over USB for now

I would like to release the next version before I actually receive a
sample w/ multi-SE and fix up the USB side properly.
Peter Cai 1 月之前
父節點
當前提交
f3dbba0229
共有 1 個文件被更改,包括 14 次插入3 次删除
  1. 14 3
      app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelManager.kt

+ 14 - 3
app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelManager.kt

@@ -57,7 +57,10 @@ open class DefaultEuiccChannelManager(
     protected open val uiccCards: Collection<UiccCardInfoCompat>
         get() = (0..<tm.activeModemCountCompat).map { FakeUiccCardInfoCompat(it) }
 
-    private suspend inline fun tryOpenChannelWithKnownAids(openFn: (ByteArray, EuiccChannel.SecureElementId) -> EuiccChannel?): List<EuiccChannel> {
+    private suspend inline fun tryOpenChannelWithKnownAids(
+        supportsMultiSE: Boolean,
+        openFn: (ByteArray, EuiccChannel.SecureElementId) -> EuiccChannel?
+    ): List<EuiccChannel> {
         var isdrAidList =
             parseIsdrAidList(appContainer.preferenceRepository.isdrAidListFlow.first())
         val ret = mutableListOf<EuiccChannel>()
@@ -102,6 +105,12 @@ open class DefaultEuiccChannelManager(
                 if (channel != null) {
                     ret.add(channel)
                     openedAids.add(aid)
+
+                    // This only exists because the UI side doesn't yet support multi-SE over USB readers properly.
+                    // TODO: Fix that and remove this.
+                    if (!supportsMultiSE) {
+                        break@outer
+                    }
                 }
             }
 
@@ -145,8 +154,9 @@ open class DefaultEuiccChannelManager(
                 return null
             }
 
+            // This function is not responsible for managing USB channels (see the initial check), so supportsMultiSE is true.
             val channels =
-                tryOpenChannelWithKnownAids { isdrAid, seId ->
+                tryOpenChannelWithKnownAids(supportsMultiSE = true) { isdrAid, seId ->
                     euiccChannelFactory.tryOpenEuiccChannel(
                         port,
                         isdrAid,
@@ -374,7 +384,8 @@ open class DefaultEuiccChannelManager(
                     UsbCcidContext.createFromUsbDevice(context, device, iface) ?: return@forEach
 
                 try {
-                    val channels = tryOpenChannelWithKnownAids { isdrAid, seId ->
+                    // TODO: We should also support multiple SEs over USB readers (the code here already does, UI doesn't yet)
+                    val channels = tryOpenChannelWithKnownAids(supportsMultiSE = false) { isdrAid, seId ->
                         euiccChannelFactory.tryOpenUsbEuiccChannel(ccidCtx, isdrAid, seId)
                     }
                     if (channels.isNotEmpty() && channels[0].valid) {