Updated on 2026-08-14
This commit is contained in:
parent
4db63c1685
commit
4288dd4dc3
15 changed files with 177 additions and 26 deletions
|
|
@ -97,4 +97,6 @@ object Constant {
|
|||
const val REQUEST_CODE_SCAN_QR_SECRET = "REQUEST_CODE_SCAN_QR_SECRET"
|
||||
const val REQUEST_CODE_SCAN_QR_USER_ID = "REQUEST_CODE_SCAN_QR_USER_ID"
|
||||
|
||||
const val TERMINAL_PRIVATE_KEY = "terminalPrivateKey"
|
||||
const val TERMINAL_PUBLIC_KEY = "terminalPublicKey"
|
||||
}
|
||||
|
|
@ -3,9 +3,9 @@ package com.tangem.data.dp
|
|||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
|
||||
import com.orhanobut.hawk.Hawk
|
||||
import com.tangem.Constant
|
||||
import com.tangem.tangem_card.reader.CardCrypto
|
||||
|
||||
class PrefsManager {
|
||||
companion object {
|
||||
|
|
@ -47,4 +47,18 @@ class PrefsManager {
|
|||
}
|
||||
|
||||
fun getAllCids(): String = Hawk.get("CID_Key", "")
|
||||
|
||||
val terminalKeys: Map<String, ByteArray>
|
||||
get() {
|
||||
val privateKey = Hawk.get<ByteArray>(Constant.TERMINAL_PRIVATE_KEY) ?: byteArrayOf()
|
||||
val publicKey = Hawk.get<ByteArray>(Constant.TERMINAL_PUBLIC_KEY) ?: byteArrayOf()
|
||||
return if (privateKey.isNotEmpty() && publicKey.isNotEmpty()) {
|
||||
mapOf(Constant.TERMINAL_PRIVATE_KEY to privateKey, Constant.TERMINAL_PUBLIC_KEY to publicKey)
|
||||
} else {
|
||||
val keys = CardCrypto.generateTerminalKeys()
|
||||
Hawk.put(Constant.TERMINAL_PRIVATE_KEY, keys[Constant.TERMINAL_PRIVATE_KEY])
|
||||
Hawk.put(Constant.TERMINAL_PUBLIC_KEY, keys[Constant.TERMINAL_PUBLIC_KEY])
|
||||
keys
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -19,6 +19,7 @@ import com.tangem.tangem_card.data.TangemCard
|
|||
import com.tangem.tangem_card.reader.CardProtocol
|
||||
import com.tangem.tangem_card.tasks.CustomReadCardTask
|
||||
import com.tangem.tangem_card.tasks.ReadCardInfoTask
|
||||
import com.tangem.tangem_sdk.android.data.PINStorage
|
||||
import com.tangem.tangem_sdk.android.nfc.NfcDeviceAntennaLocation
|
||||
import com.tangem.tangem_sdk.android.reader.NfcReader
|
||||
import com.tangem.tangem_sdk.data.EXTRA_TANGEM_CARD
|
||||
|
|
@ -124,6 +125,10 @@ class MainFragment : BaseFragment(), NavigationResultListener, NfcAdapter.Reader
|
|||
|
||||
lastTag = tag
|
||||
|
||||
val terminalKeys = viewModel.getTerminalKeys()
|
||||
PINStorage.setTerminalPrivateKey(terminalKeys[Constant.TERMINAL_PRIVATE_KEY])
|
||||
PINStorage.setTerminalPublicKey(terminalKeys[Constant.TERMINAL_PUBLIC_KEY])
|
||||
|
||||
task = ReadCardInfoTask(NfcReader((activity as MainActivity).nfcManager, isoDep),
|
||||
App.localStorage, App.pinStorage, this)
|
||||
task?.start()
|
||||
|
|
@ -161,6 +166,10 @@ class MainFragment : BaseFragment(), NavigationResultListener, NfcAdapter.Reader
|
|||
val card = TangemCard(uid)
|
||||
cardInfo.getBundle(EXTRA_TANGEM_CARD)?.let { card.loadFromBundle(it) }
|
||||
|
||||
val terminalKeys = viewModel.getTerminalKeys()
|
||||
card.terminalPrivateKey = terminalKeys[Constant.TERMINAL_PRIVATE_KEY]
|
||||
card.terminalPublicKey = terminalKeys[Constant.TERMINAL_PUBLIC_KEY]
|
||||
|
||||
val ctx = TangemContext(card)
|
||||
when {
|
||||
card.status == TangemCard.Status.Loaded -> lastTag?.let {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import androidx.lifecycle.LiveData
|
|||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.tangem.Constant
|
||||
import com.tangem.data.dp.PrefsManager
|
||||
import com.tangem.data.network.ServerApiCommon
|
||||
import com.tangem.wallet.BuildConfig
|
||||
|
||||
|
|
@ -35,4 +36,9 @@ class MainViewModel : ViewModel() {
|
|||
}
|
||||
serverApiCommon.requestLastVersion()
|
||||
}
|
||||
|
||||
fun getTerminalKeys(): Map<String, ByteArray> {
|
||||
return PrefsManager.getInstance().terminalKeys
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -354,8 +354,10 @@ class VerifyCardFragment : BaseFragment(), NavigationResultListener, NfcAdapter.
|
|||
if (ctx.card!!.supportBlock()!!)
|
||||
features += "Blockable\n"
|
||||
|
||||
if (ctx.card!!.supportLinkingTerminal())
|
||||
features += "Linking terminal is supported"
|
||||
|
||||
if (ctx.card!!.supportOnlyOneCommandAtTime()!!)
|
||||
if (ctx.card!!.supportOnlyOneCommandAtTime())
|
||||
features += "Atomic command mode"
|
||||
|
||||
if (features.endsWith("\n"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue