Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f3dbba02 authored by Peter Cai's avatar Peter Cai
Browse files

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.
parent 0c305ff6
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -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) {