Compare commits
1 commit
e7fb7ed2b8
...
678a4e70ab
Author | SHA1 | Date | |
---|---|---|---|
678a4e70ab |
4 changed files with 50 additions and 53 deletions
|
@ -21,7 +21,7 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha
|
||||||
override suspend fun tryOpenEuiccChannel(
|
override suspend fun tryOpenEuiccChannel(
|
||||||
port: UiccPortInfoCompat,
|
port: UiccPortInfoCompat,
|
||||||
isdrAid: ByteArray
|
isdrAid: ByteArray
|
||||||
): EuiccChannel? {
|
): EuiccChannel? = try {
|
||||||
if (port.portIndex != 0) {
|
if (port.portIndex != 0) {
|
||||||
Log.w(
|
Log.w(
|
||||||
DefaultEuiccChannelManager.TAG,
|
DefaultEuiccChannelManager.TAG,
|
||||||
|
@ -35,54 +35,52 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha
|
||||||
DefaultEuiccChannelManager.TAG,
|
DefaultEuiccChannelManager.TAG,
|
||||||
"Trying OMAPI for physical slot ${port.card.physicalSlotIndex}"
|
"Trying OMAPI for physical slot ${port.card.physicalSlotIndex}"
|
||||||
)
|
)
|
||||||
return try {
|
EuiccChannelImpl(
|
||||||
EuiccChannelImpl(
|
context.getString(R.string.channel_type_omapi),
|
||||||
context.getString(R.string.channel_type_omapi),
|
port,
|
||||||
|
intrinsicChannelName = null,
|
||||||
|
OmapiApduInterface(
|
||||||
|
seService!!,
|
||||||
port,
|
port,
|
||||||
intrinsicChannelName = null,
|
context.preferenceRepository.verboseLoggingFlow
|
||||||
OmapiApduInterface(
|
),
|
||||||
seService!!,
|
isdrAid,
|
||||||
port,
|
context.preferenceRepository.verboseLoggingFlow,
|
||||||
context.preferenceRepository.verboseLoggingFlow
|
context.preferenceRepository.ignoreTLSCertificateFlow,
|
||||||
),
|
context.preferenceRepository.es10xMssFlow,
|
||||||
isdrAid,
|
)
|
||||||
context.preferenceRepository.verboseLoggingFlow,
|
} catch (_: IllegalArgumentException) {
|
||||||
context.preferenceRepository.ignoreTLSCertificateFlow,
|
// Failed
|
||||||
)
|
Log.w(
|
||||||
} catch (_: IllegalArgumentException) {
|
DefaultEuiccChannelManager.TAG,
|
||||||
// Failed
|
"OMAPI APDU interface unavailable for physical slot ${port.card.physicalSlotIndex} with ISD-R AID: ${isdrAid.encodeHex()}."
|
||||||
Log.w(
|
)
|
||||||
DefaultEuiccChannelManager.TAG,
|
null
|
||||||
"OMAPI APDU interface unavailable for physical slot ${port.card.physicalSlotIndex} with ISD-R AID: ${isdrAid.encodeHex()}."
|
|
||||||
)
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun tryOpenUsbEuiccChannel(
|
override fun tryOpenUsbEuiccChannel(
|
||||||
ccidCtx: UsbCcidContext,
|
ccidCtx: UsbCcidContext,
|
||||||
isdrAid: ByteArray
|
isdrAid: ByteArray
|
||||||
): EuiccChannel? {
|
): EuiccChannel? = try {
|
||||||
try {
|
EuiccChannelImpl(
|
||||||
return EuiccChannelImpl(
|
context.getString(R.string.channel_type_usb),
|
||||||
context.getString(R.string.channel_type_usb),
|
FakeUiccPortInfoCompat(FakeUiccCardInfoCompat(EuiccChannelManager.USB_CHANNEL_ID)),
|
||||||
FakeUiccPortInfoCompat(FakeUiccCardInfoCompat(EuiccChannelManager.USB_CHANNEL_ID)),
|
intrinsicChannelName = ccidCtx.productName,
|
||||||
intrinsicChannelName = ccidCtx.productName,
|
UsbApduInterface(
|
||||||
UsbApduInterface(
|
ccidCtx
|
||||||
ccidCtx
|
),
|
||||||
),
|
isdrAid,
|
||||||
isdrAid,
|
context.preferenceRepository.verboseLoggingFlow,
|
||||||
context.preferenceRepository.verboseLoggingFlow,
|
context.preferenceRepository.ignoreTLSCertificateFlow,
|
||||||
context.preferenceRepository.ignoreTLSCertificateFlow,
|
context.preferenceRepository.es10xMssFlow,
|
||||||
)
|
)
|
||||||
} catch (_: IllegalArgumentException) {
|
} catch (_: IllegalArgumentException) {
|
||||||
// Failed
|
// Failed
|
||||||
Log.w(
|
Log.w(
|
||||||
DefaultEuiccChannelManager.TAG,
|
DefaultEuiccChannelManager.TAG,
|
||||||
"USB APDU interface unavailable for ISD-R AID: ${isdrAid.encodeHex()}."
|
"USB APDU interface unavailable for ISD-R AID: ${isdrAid.encodeHex()}."
|
||||||
)
|
)
|
||||||
}
|
null
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun cleanup() {
|
override fun cleanup() {
|
||||||
|
|
|
@ -99,12 +99,6 @@ open class DefaultEuiccChannelManager(
|
||||||
val channel =
|
val channel =
|
||||||
tryOpenChannelFirstValidAid { euiccChannelFactory.tryOpenEuiccChannel(port, it) }
|
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) {
|
if (channel != null) {
|
||||||
channelCache.add(channel)
|
channelCache.add(channel)
|
||||||
return channel
|
return channel
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package im.angry.openeuicc.core
|
package im.angry.openeuicc.core
|
||||||
|
|
||||||
import im.angry.openeuicc.util.UiccPortInfoCompat
|
import im.angry.openeuicc.util.UiccPortInfoCompat
|
||||||
import im.angry.openeuicc.util.decodeHex
|
|
||||||
import kotlinx.coroutines.flow.Flow
|
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.ApduInterface
|
||||||
import net.typeblog.lpac_jni.LocalProfileAssistant
|
import net.typeblog.lpac_jni.LocalProfileAssistant
|
||||||
import net.typeblog.lpac_jni.impl.HttpInterfaceImpl
|
import net.typeblog.lpac_jni.impl.HttpInterfaceImpl
|
||||||
|
@ -15,7 +16,8 @@ class EuiccChannelImpl(
|
||||||
override val apduInterface: ApduInterface,
|
override val apduInterface: ApduInterface,
|
||||||
override val isdrAid: ByteArray,
|
override val isdrAid: ByteArray,
|
||||||
verboseLoggingFlow: Flow<Boolean>,
|
verboseLoggingFlow: Flow<Boolean>,
|
||||||
ignoreTLSCertificateFlow: Flow<Boolean>
|
ignoreTLSCertificateFlow: Flow<Boolean>,
|
||||||
|
es10xMssFlow: Flow<Int>,
|
||||||
) : EuiccChannel {
|
) : EuiccChannel {
|
||||||
override val slotId = port.card.physicalSlotIndex
|
override val slotId = port.card.physicalSlotIndex
|
||||||
override val logicalSlotId = port.logicalSlotIndex
|
override val logicalSlotId = port.logicalSlotIndex
|
||||||
|
@ -25,8 +27,10 @@ class EuiccChannelImpl(
|
||||||
LocalProfileAssistantImpl(
|
LocalProfileAssistantImpl(
|
||||||
isdrAid,
|
isdrAid,
|
||||||
apduInterface,
|
apduInterface,
|
||||||
HttpInterfaceImpl(verboseLoggingFlow, ignoreTLSCertificateFlow)
|
HttpInterfaceImpl(verboseLoggingFlow, ignoreTLSCertificateFlow),
|
||||||
)
|
).also {
|
||||||
|
it.setEs10xMss(runBlocking { es10xMssFlow.first().toByte() })
|
||||||
|
}
|
||||||
|
|
||||||
override val atr: ByteArray?
|
override val atr: ByteArray?
|
||||||
get() = (apduInterface as? ApduInterfaceAtrProvider)?.atr
|
get() = (apduInterface as? ApduInterfaceAtrProvider)?.atr
|
||||||
|
|
|
@ -42,6 +42,7 @@ class PrivilegedEuiccChannelFactory(context: Context) : DefaultEuiccChannelFacto
|
||||||
isdrAid,
|
isdrAid,
|
||||||
context.preferenceRepository.verboseLoggingFlow,
|
context.preferenceRepository.verboseLoggingFlow,
|
||||||
context.preferenceRepository.ignoreTLSCertificateFlow,
|
context.preferenceRepository.ignoreTLSCertificateFlow,
|
||||||
|
context.preferenceRepository.es10xMssFlow,
|
||||||
)
|
)
|
||||||
} catch (_: IllegalArgumentException) {
|
} catch (_: IllegalArgumentException) {
|
||||||
// Failed
|
// Failed
|
||||||
|
|
Loading…
Add table
Reference in a new issue