Compare commits

...

2 commits

Author SHA1 Message Date
b090bb007c
fix: usb isd-r aid fallback 2025-04-01 20:39:12 +08:00
384270f57b
fix: usb isd-r aid fallback 2025-04-01 18:39:43 +08:00
3 changed files with 7 additions and 10 deletions

View file

@ -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 ISDR AID ${it.encodeHex()}") Log.i(TAG, "Opening channel, trying ISD-R AID: ${it.encodeHex()}")
openFn(it)?.let { channel -> openFn(it)?.let { channel ->
if (channel.valid) { if (channel.valid) {
@ -277,11 +277,7 @@ open class DefaultEuiccChannelManager(
) )
try { try {
val channel = tryOpenChannelFirstValidAid { val channel = tryOpenChannelFirstValidAid {
euiccChannelFactory.tryOpenUsbEuiccChannel( euiccChannelFactory.tryOpenUsbEuiccChannel(device, iface, it)
device,
iface,
it
)
} }
if (channel != null && channel.lpa.valid) { if (channel != null && channel.lpa.valid) {
usbChannel = channel usbChannel = channel

View file

@ -53,7 +53,7 @@ class UsbApduInterface(
"A9088100820101830107".decodeHex(), "A9088100820101830107".decodeHex(),
le = null, le = null,
) )
transmitApduByChannel(terminalCapabilities, 0,) transmitApduByChannel(terminalCapabilities, 0)
} }
override fun disconnect() { override fun disconnect() {
@ -70,12 +70,12 @@ class UsbApduInterface(
transmitApduByChannel(req, 0) transmitApduByChannel(req, 0)
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
return -1 return 0
} }
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 -1 return 0
} }
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 -1 return 0
} }
channels.add(channelId) channels.add(channelId)

View file

@ -36,6 +36,7 @@ fun formatFreeSpace(size: Int): String =
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)
.mapNotNull { .mapNotNull {
try { try {
it.decodeHex() it.decodeHex()