Updated on 2026-08-14
This commit is contained in:
commit
6b5209df4b
6 changed files with 25 additions and 9 deletions
|
|
@ -71,10 +71,4 @@ class SettingsFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedP
|
|||
preferenceScreen.sharedPreferences
|
||||
.unregisterOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
(activity as AppCompatActivity).setSupportActionBar(toolbar)
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -48,6 +48,7 @@ class CardSession(
|
|||
private val initialMessage: Message? = null
|
||||
) {
|
||||
|
||||
private val tag = this.javaClass.simpleName
|
||||
/**
|
||||
* True if some operation is still in progress.
|
||||
*/
|
||||
|
|
@ -164,7 +165,10 @@ class CardSession(
|
|||
} else {
|
||||
error.localizedMessage
|
||||
}
|
||||
if (error !is SessionError.UserCancelled) viewDelegate.onError(errorMessage)
|
||||
if (error !is SessionError.UserCancelled) {
|
||||
Log.e("tag", "Finishing with error: $errorMessage")
|
||||
viewDelegate.onError(errorMessage)
|
||||
}
|
||||
}
|
||||
|
||||
fun send(apdu: CommandApdu, callback: (result: CompletionResult<ResponseApdu>) -> Unit) {
|
||||
|
|
@ -176,6 +180,7 @@ class CardSession(
|
|||
|
||||
when (error) {
|
||||
is SessionError.NeedEncryption -> {
|
||||
Log.i(tag, "Establishing encryption")
|
||||
when (environment.encryptionMode) {
|
||||
EncryptionMode.NONE -> {
|
||||
environment.encryptionKey = null
|
||||
|
|
@ -186,7 +191,7 @@ class CardSession(
|
|||
environment.encryptionMode = EncryptionMode.STRONG
|
||||
}
|
||||
EncryptionMode.STRONG -> {
|
||||
Log.e(this::class.simpleName!!, "Encryption doesn't work")
|
||||
Log.e(tag, "Encryption doesn't work")
|
||||
callback(CompletionResult.Failure(SessionError.NeedEncryption()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ abstract class Command<T : CommandResponse> : CardSessionRunnable<T> {
|
|||
abstract fun deserialize(environment: SessionEnvironment, apdu: ResponseApdu): T
|
||||
|
||||
override fun run(session: CardSession, callback: (result: CompletionResult<T>) -> Unit) {
|
||||
Log.i("Command", "Sending ${this::class.java.simpleName}")
|
||||
transceive(session, callback)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.common.tlv
|
||||
|
||||
import com.tangem.Log
|
||||
import com.tangem.common.extensions.toHexString
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.IOException
|
||||
|
||||
|
|
@ -71,6 +72,10 @@ class Tlv {
|
|||
}
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "${this.tag} ($tagRaw): ${value.toHexString()}"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun List<Tlv>.serialize(): ByteArray =
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.tangem.common.tlv
|
||||
|
||||
import com.tangem.Log
|
||||
|
||||
class TlvBuilder {
|
||||
private val tlvs = mutableListOf<Tlv>()
|
||||
private val encoder = TlvEncoder()
|
||||
|
|
@ -10,6 +12,10 @@ class TlvBuilder {
|
|||
tlvs.add(encoder.encode(tag, value))
|
||||
}
|
||||
|
||||
fun serialize(): ByteArray = tlvs.serialize()
|
||||
fun serialize(): ByteArray {
|
||||
Log.v("TLV",
|
||||
"List of TLV that are being sent to a card:\n${tlvs.joinToString("\n")}")
|
||||
return tlvs.serialize()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -18,6 +18,11 @@ import java.util.*
|
|||
*/
|
||||
class TlvDecoder(val tlvList: List<Tlv>) {
|
||||
|
||||
init {
|
||||
Log.v("TLV",
|
||||
"List of TLV received from card:\n${tlvList.joinToString("\n")}")
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds [Tlv] by its [TlvTag].
|
||||
* Returns null if [Tlv] is not found, otherwise converts its value to [T].
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue