From 58bd80556a316dbbec5e4e437aeea439c3a37c62 Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Mon, 27 Nov 2023 20:20:38 -0500 Subject: [PATCH] core: TelephonyManagerApduInterface: convert to UByte first Otherwise, the integer representation will be negative when the byte value is greater than 127. --- .../openeuicc/core/TelephonyManagerApduInterface.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/im/angry/openeuicc/core/TelephonyManagerApduInterface.kt b/app/src/main/java/im/angry/openeuicc/core/TelephonyManagerApduInterface.kt index ec16c50..e4924ea 100644 --- a/app/src/main/java/im/angry/openeuicc/core/TelephonyManagerApduInterface.kt +++ b/app/src/main/java/im/angry/openeuicc/core/TelephonyManagerApduInterface.kt @@ -42,11 +42,11 @@ class TelephonyManagerApduInterface( override fun transmit(tx: ByteArray): ByteArray { check(lastChannel != -1) { "Uninitialized" } - val cla = tx[0].toInt() - val instruction = tx[1].toInt() - val p1 = tx[2].toInt() - val p2 = tx[3].toInt() - val p3 = tx[4].toInt() + val cla = tx[0].toUByte().toInt() + val instruction = tx[1].toUByte().toInt() + val p1 = tx[2].toUByte().toInt() + val p2 = tx[3].toUByte().toInt() + val p3 = tx[4].toUByte().toInt() val p4 = tx.drop(5).toByteArray().encodeHex() return tm.iccTransmitApduLogicalChannelBySlot(info.slotId, lastChannel,