Updated on 2026-08-14
This commit is contained in:
parent
7e7e3254f3
commit
0c419c3441
9 changed files with 167 additions and 17 deletions
|
|
@ -183,7 +183,7 @@ class Card(
|
|||
/**
|
||||
* Current status of the card.
|
||||
*/
|
||||
val status: CardStatus,
|
||||
val status: CardStatus?,
|
||||
|
||||
/**
|
||||
* Version of Tangem COS.
|
||||
|
|
@ -316,9 +316,9 @@ class ReadCommand : CommandSerializer<Card>() {
|
|||
val tlvMapper = TlvMapper(tlvData)
|
||||
|
||||
Card(
|
||||
cardId = tlvMapper.map(TlvTag.CardId),
|
||||
manufacturerName = tlvMapper.map(TlvTag.ManufactureId),
|
||||
status = tlvMapper.map(TlvTag.Status),
|
||||
cardId = tlvMapper.mapOptional(TlvTag.CardId) ?: "",
|
||||
manufacturerName = tlvMapper.mapOptional(TlvTag.ManufactureId) ?: "",
|
||||
status = tlvMapper.mapOptional(TlvTag.Status),
|
||||
|
||||
firmwareVersion = tlvMapper.mapOptional(TlvTag.Firmware),
|
||||
cardPublicKey = tlvMapper.mapOptional(TlvTag.CardPublicKey),
|
||||
|
|
|
|||
|
|
@ -53,9 +53,9 @@ class Tlv {
|
|||
}
|
||||
|
||||
|
||||
fun deserialize(mData: ByteArray): List<Tlv>? {
|
||||
fun deserialize(data: ByteArray, nfcV: Boolean = false): List<Tlv>? {
|
||||
val tlvList = mutableListOf<Tlv>()
|
||||
val stream = ByteArrayInputStream(mData)
|
||||
val stream = ByteArrayInputStream(data)
|
||||
var tlv: Tlv?
|
||||
do {
|
||||
try {
|
||||
|
|
@ -63,7 +63,7 @@ class Tlv {
|
|||
if (tlv != null) tlvList.add(tlv)
|
||||
} catch (e: IOException) {
|
||||
Log.e(this::class.java.simpleName,"TLVError: " + e.message)
|
||||
return null
|
||||
if (nfcV) break else return null
|
||||
}
|
||||
|
||||
} while (tlv != null)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
package com.tangem.tasks
|
||||
|
||||
import com.tangem.commands.*
|
||||
import com.tangem.common.CardEnvironment
|
||||
import com.tangem.commands.Card
|
||||
import com.tangem.commands.CardStatus
|
||||
import com.tangem.commands.CheckWalletCommand
|
||||
import com.tangem.commands.ReadCommand
|
||||
import com.tangem.common.CompletionResult
|
||||
import com.tangem.crypto.CryptoUtils
|
||||
|
||||
|
|
@ -41,6 +38,10 @@ internal class ScanTask : Task<ScanEvent>() {
|
|||
completeNfcSession(true, TaskError.MissingPreflightRead())
|
||||
callback(TaskEvent.Completion(TaskError.MissingPreflightRead()))
|
||||
|
||||
} else if (currentCard.cardData?.productMask == ProductMask.Tag) {
|
||||
completeNfcSession()
|
||||
callback(TaskEvent.Completion())
|
||||
|
||||
} else if (currentCard.status != CardStatus.Loaded) {
|
||||
completeNfcSession()
|
||||
callback(TaskEvent.Completion())
|
||||
|
|
|
|||
|
|
@ -190,6 +190,7 @@ abstract class Task<T> {
|
|||
is CompletionResult.Success -> {
|
||||
|
||||
val receivedCardId = readResult.data.cardId
|
||||
securityDelayDuration = readResult.data.pauseBeforePin2 ?: 0
|
||||
|
||||
if (environment.cardId != null && environment.cardId != receivedCardId) {
|
||||
completeNfcSession(true, TaskError.WrongCard())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue