Compare commits
2 commits
e31200d142
...
b090bb007c
Author | SHA1 | Date | |
---|---|---|---|
b090bb007c | |||
384270f57b |
4 changed files with 27 additions and 32 deletions
|
@ -60,7 +60,7 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha
|
|||
Log.i(DefaultEuiccChannelManager.TAG, "Is OMAPI channel, setting MSS to 60")
|
||||
it.lpa.setEs10xMss(60)
|
||||
}
|
||||
} catch (_: IllegalArgumentException) {
|
||||
} catch (e: IllegalArgumentException) {
|
||||
// Failed
|
||||
Log.w(
|
||||
DefaultEuiccChannelManager.TAG,
|
||||
|
@ -80,29 +80,20 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha
|
|||
if (bulkIn == null || bulkOut == null) return null
|
||||
val conn = usbManager.openDevice(usbDevice) ?: return null
|
||||
if (!conn.claimInterface(usbInterface, true)) return null
|
||||
try {
|
||||
return EuiccChannelImpl(
|
||||
context.getString(R.string.usb),
|
||||
FakeUiccPortInfoCompat(FakeUiccCardInfoCompat(EuiccChannelManager.USB_CHANNEL_ID)),
|
||||
intrinsicChannelName = usbDevice.productName,
|
||||
UsbApduInterface(
|
||||
conn,
|
||||
bulkIn,
|
||||
bulkOut,
|
||||
context.preferenceRepository.verboseLoggingFlow
|
||||
),
|
||||
isdrAid,
|
||||
context.preferenceRepository.verboseLoggingFlow,
|
||||
context.preferenceRepository.ignoreTLSCertificateFlow,
|
||||
)
|
||||
} catch (_: IllegalArgumentException) {
|
||||
// Failed
|
||||
Log.w(
|
||||
DefaultEuiccChannelManager.TAG,
|
||||
"USB APDU interface unavailable for ${usbDevice.vendorId}:${usbDevice.productId}."
|
||||
)
|
||||
}
|
||||
return null
|
||||
return EuiccChannelImpl(
|
||||
context.getString(R.string.usb),
|
||||
FakeUiccPortInfoCompat(FakeUiccCardInfoCompat(EuiccChannelManager.USB_CHANNEL_ID)),
|
||||
intrinsicChannelName = usbDevice.productName,
|
||||
UsbApduInterface(
|
||||
conn,
|
||||
bulkIn,
|
||||
bulkOut,
|
||||
context.preferenceRepository.verboseLoggingFlow
|
||||
),
|
||||
isdrAid,
|
||||
context.preferenceRepository.verboseLoggingFlow,
|
||||
context.preferenceRepository.ignoreTLSCertificateFlow,
|
||||
)
|
||||
}
|
||||
|
||||
override fun cleanup() {
|
||||
|
|
|
@ -55,7 +55,7 @@ open class DefaultEuiccChannelManager(
|
|||
parseIsdrAidList(appContainer.preferenceRepository.isdrAidListFlow.first())
|
||||
|
||||
return isdrAidList.firstNotNullOfOrNull {
|
||||
Log.i(TAG, "Opening channel, trying ISDR AID ${it.encodeHex()}")
|
||||
Log.i(TAG, "Opening channel, trying ISD-R AID: ${it.encodeHex()}")
|
||||
|
||||
openFn(it)?.let { channel ->
|
||||
if (channel.valid) {
|
||||
|
|
|
@ -70,12 +70,12 @@ class UsbApduInterface(
|
|||
transmitApduByChannel(req, 0)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
return -1
|
||||
return 0
|
||||
}
|
||||
|
||||
if (!isSuccessResponse(resp)) {
|
||||
Log.d(TAG, "OPEN LOGICAL CHANNEL failed: ${resp.encodeHex()}")
|
||||
return -1
|
||||
return 0
|
||||
}
|
||||
|
||||
val channelId = resp[0].toInt()
|
||||
|
@ -87,7 +87,7 @@ class UsbApduInterface(
|
|||
|
||||
if (!isSuccessResponse(selectAidResp)) {
|
||||
Log.d(TAG, "Select DF failed : ${selectAidResp.encodeHex()}")
|
||||
return -1
|
||||
return 0
|
||||
}
|
||||
|
||||
channels.add(channelId)
|
||||
|
|
|
@ -34,12 +34,16 @@ fun formatFreeSpace(size: Int): String =
|
|||
* If none is found, at least EUICC_DEFAULT_ISDR_AID is returned
|
||||
*/
|
||||
fun parseIsdrAidList(s: String): List<ByteArray> =
|
||||
s.split('\n')
|
||||
.map(String::trim)
|
||||
.filter { !it.startsWith('#') }
|
||||
s.split('\n').map(String::trim).filter { !it.startsWith('#') }
|
||||
.map(String::trim)
|
||||
.filter(String::isNotEmpty)
|
||||
.mapNotNull { runCatching(it::decodeHex).getOrNull() }
|
||||
.mapNotNull {
|
||||
try {
|
||||
it.decodeHex()
|
||||
} catch (_: IllegalArgumentException) {
|
||||
null
|
||||
}
|
||||
}
|
||||
.ifEmpty { listOf(EUICC_DEFAULT_ISDR_AID.decodeHex()) }
|
||||
|
||||
fun String.prettyPrintJson(): String {
|
||||
|
|
Loading…
Add table
Reference in a new issue