Compare commits

...

1 commit

Author SHA1 Message Date
678a4e70ab
feat: integrate es10x MSS flow into channel implementations 2025-08-11 10:56:45 +08:00
4 changed files with 50 additions and 53 deletions

View file

@ -21,7 +21,7 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha
override suspend fun tryOpenEuiccChannel(
port: UiccPortInfoCompat,
isdrAid: ByteArray
): EuiccChannel? {
): EuiccChannel? = try {
if (port.portIndex != 0) {
Log.w(
DefaultEuiccChannelManager.TAG,
@ -35,7 +35,6 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha
DefaultEuiccChannelManager.TAG,
"Trying OMAPI for physical slot ${port.card.physicalSlotIndex}"
)
return try {
EuiccChannelImpl(
context.getString(R.string.channel_type_omapi),
port,
@ -48,6 +47,7 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha
isdrAid,
context.preferenceRepository.verboseLoggingFlow,
context.preferenceRepository.ignoreTLSCertificateFlow,
context.preferenceRepository.es10xMssFlow,
)
} catch (_: IllegalArgumentException) {
// Failed
@ -57,14 +57,12 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha
)
null
}
}
override fun tryOpenUsbEuiccChannel(
ccidCtx: UsbCcidContext,
isdrAid: ByteArray
): EuiccChannel? {
try {
return EuiccChannelImpl(
): EuiccChannel? = try {
EuiccChannelImpl(
context.getString(R.string.channel_type_usb),
FakeUiccPortInfoCompat(FakeUiccCardInfoCompat(EuiccChannelManager.USB_CHANNEL_ID)),
intrinsicChannelName = ccidCtx.productName,
@ -74,6 +72,7 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha
isdrAid,
context.preferenceRepository.verboseLoggingFlow,
context.preferenceRepository.ignoreTLSCertificateFlow,
context.preferenceRepository.es10xMssFlow,
)
} catch (_: IllegalArgumentException) {
// Failed
@ -81,8 +80,7 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha
DefaultEuiccChannelManager.TAG,
"USB APDU interface unavailable for ISD-R AID: ${isdrAid.encodeHex()}."
)
}
return null
null
}
override fun cleanup() {

View file

@ -99,12 +99,6 @@ open class DefaultEuiccChannelManager(
val channel =
tryOpenChannelFirstValidAid { euiccChannelFactory.tryOpenEuiccChannel(port, it) }
if (channel != null) {
val mss = context.preferenceRepository.es10xMssFlow.first()
Log.i(TAG, "Set ${channel.type} channel, ES10x MSS to $mss")
channel.lpa.setEs10xMss(mss.toByte())
}
if (channel != null) {
channelCache.add(channel)
return channel

View file

@ -1,8 +1,9 @@
package im.angry.openeuicc.core
import im.angry.openeuicc.util.UiccPortInfoCompat
import im.angry.openeuicc.util.decodeHex
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
import net.typeblog.lpac_jni.ApduInterface
import net.typeblog.lpac_jni.LocalProfileAssistant
import net.typeblog.lpac_jni.impl.HttpInterfaceImpl
@ -15,7 +16,8 @@ class EuiccChannelImpl(
override val apduInterface: ApduInterface,
override val isdrAid: ByteArray,
verboseLoggingFlow: Flow<Boolean>,
ignoreTLSCertificateFlow: Flow<Boolean>
ignoreTLSCertificateFlow: Flow<Boolean>,
es10xMssFlow: Flow<Int>,
) : EuiccChannel {
override val slotId = port.card.physicalSlotIndex
override val logicalSlotId = port.logicalSlotIndex
@ -25,8 +27,10 @@ class EuiccChannelImpl(
LocalProfileAssistantImpl(
isdrAid,
apduInterface,
HttpInterfaceImpl(verboseLoggingFlow, ignoreTLSCertificateFlow)
)
HttpInterfaceImpl(verboseLoggingFlow, ignoreTLSCertificateFlow),
).also {
it.setEs10xMss(runBlocking { es10xMssFlow.first().toByte() })
}
override val atr: ByteArray?
get() = (apduInterface as? ApduInterfaceAtrProvider)?.atr

View file

@ -42,6 +42,7 @@ class PrivilegedEuiccChannelFactory(context: Context) : DefaultEuiccChannelFacto
isdrAid,
context.preferenceRepository.verboseLoggingFlow,
context.preferenceRepository.ignoreTLSCertificateFlow,
context.preferenceRepository.es10xMssFlow,
)
} catch (_: IllegalArgumentException) {
// Failed