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