Updated on 2026-08-14
This commit is contained in:
parent
cfebd18d17
commit
f8b2a70086
11 changed files with 101 additions and 87 deletions
|
|
@ -284,18 +284,14 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
|
||||
public override fun onPause() {
|
||||
nfcManager.onPause()
|
||||
if (readCardInfoTask != null) {
|
||||
readCardInfoTask!!.cancel(true)
|
||||
}
|
||||
readCardInfoTask?.cancel(true)
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
public override fun onStop() {
|
||||
// dismiss enable NFC dialog
|
||||
nfcManager.onStop()
|
||||
if (readCardInfoTask != null) {
|
||||
readCardInfoTask!!.cancel(true)
|
||||
}
|
||||
readCardInfoTask?.cancel(true)
|
||||
super.onStop()
|
||||
}
|
||||
|
||||
|
|
@ -329,7 +325,8 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
val ctx = TangemContext(card)
|
||||
when {
|
||||
card.status == TangemCard.Status.Loaded -> lastTag?.let {
|
||||
val engineCoin = CoinEngineFactory.create(ctx) ?: throw CardProtocol.TangemException("Can't create CoinEngine!")
|
||||
val engineCoin = CoinEngineFactory.create(ctx)
|
||||
?: throw CardProtocol.TangemException("Can't create CoinEngine!")
|
||||
engineCoin.defineWallet()
|
||||
//mCard.setWallet(Blockchain.calculateWalletAddress(mCard, pkUncompressed));
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.tangem.Constant
|
|||
import com.tangem.data.fingerprint.StartFingerprintReaderTask
|
||||
import com.tangem.tangemcard.android.reader.NfcManager
|
||||
import com.tangem.data.fingerprint.FingerprintHelper
|
||||
import com.tangem.domain.wallet.TangemContext
|
||||
import com.tangem.tangemcard.android.data.PINStorage
|
||||
import com.tangem.tangemcard.data.TangemCard
|
||||
import com.tangem.tangemcard.data.loadFromBundle
|
||||
|
|
@ -36,14 +37,39 @@ import java.io.IOException
|
|||
class PinRequestActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, FingerprintHelper.FingerprintHelperListener {
|
||||
|
||||
companion object {
|
||||
const val KEY_ALIAS = "pinKey"
|
||||
const val KEYSTORE = "AndroidKeyStore"
|
||||
|
||||
fun callingIntent(context: Activity, mode: String): Intent {
|
||||
val intent = Intent(context, PinRequestActivity::class.java)
|
||||
intent.putExtra(Constant.EXTRA_MODE, mode)
|
||||
return intent
|
||||
}
|
||||
|
||||
fun callingIntentRequestPin(context: Activity, mode: String, ctx: TangemContext, newPIN: String): Intent {
|
||||
val intent = Intent(context, PinRequestActivity::class.java)
|
||||
intent.putExtra(Constant.EXTRA_MODE, mode)
|
||||
ctx.saveToIntent(intent)
|
||||
return intent
|
||||
}
|
||||
|
||||
fun callingIntentRequestPin2(context: Activity, mode: String, ctx: TangemContext, newPIN2: String): Intent {
|
||||
val intent = Intent(context, PinRequestActivity::class.java)
|
||||
intent.putExtra(Constant.EXTRA_MODE, mode)
|
||||
ctx.saveToIntent(intent)
|
||||
return intent
|
||||
}
|
||||
|
||||
fun callingIntentConfirmPin(context: Activity, mode: String, newPIN: String): Intent {
|
||||
val intent = Intent(context, PinRequestActivity::class.java)
|
||||
intent.putExtra(Constant.EXTRA_NEW_PIN, newPIN)
|
||||
intent.putExtra(Constant.EXTRA_MODE, mode)
|
||||
return intent
|
||||
}
|
||||
|
||||
fun callingIntentConfirmPin2(context: Activity, mode: String, newPin2: String): Intent {
|
||||
val intent = Intent(context, PinRequestActivity::class.java)
|
||||
intent.putExtra(Constant.EXTRA_NEW_PIN_2, newPin2)
|
||||
intent.putExtra(Constant.EXTRA_MODE, mode)
|
||||
return intent
|
||||
}
|
||||
}
|
||||
|
||||
lateinit var mode: Mode
|
||||
|
|
@ -63,8 +89,6 @@ class PinRequestActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Finge
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_pin_request)
|
||||
|
||||
// MainActivity.commonInit(applicationContext)
|
||||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
mode = Mode.valueOf(intent.getStringExtra("mode"))
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ class PinSaveActivity : AppCompatActivity(), FingerprintHelper.FingerprintHelper
|
|||
|
||||
fun getKeyStore(): Boolean {
|
||||
try {
|
||||
keyStore = KeyStore.getInstance(PinRequestActivity.KEYSTORE)
|
||||
keyStore = KeyStore.getInstance(Constant.KEYSTORE)
|
||||
// create empty keystore
|
||||
keyStore!!.load(null)
|
||||
return true
|
||||
|
|
@ -188,12 +188,12 @@ class PinSaveActivity : AppCompatActivity(), FingerprintHelper.FingerprintHelper
|
|||
fun createNewKey(forceCreate: Boolean): Boolean {
|
||||
try {
|
||||
if (forceCreate)
|
||||
keyStore!!.deleteEntry(PinRequestActivity.KEY_ALIAS)
|
||||
keyStore!!.deleteEntry(Constant.KEY_ALIAS)
|
||||
|
||||
if (!keyStore!!.containsAlias(PinRequestActivity.KEY_ALIAS)) {
|
||||
val generator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, PinRequestActivity.KEYSTORE)
|
||||
if (!keyStore!!.containsAlias(Constant.KEY_ALIAS)) {
|
||||
val generator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, Constant.KEYSTORE)
|
||||
|
||||
generator.init(KeyGenParameterSpec.Builder(PinRequestActivity.KEY_ALIAS,
|
||||
generator.init(KeyGenParameterSpec.Builder(Constant.KEY_ALIAS,
|
||||
KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT)
|
||||
.setBlockModes(KeyProperties.BLOCK_MODE_CBC)
|
||||
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_PKCS7)
|
||||
|
|
@ -229,7 +229,7 @@ class PinSaveActivity : AppCompatActivity(), FingerprintHelper.FingerprintHelper
|
|||
fun initCipher(mode: Int): Boolean {
|
||||
try {
|
||||
keyStore!!.load(null)
|
||||
val keyspec = keyStore!!.getKey(PinRequestActivity.KEY_ALIAS, null) as SecretKey
|
||||
val keyspec = keyStore!!.getKey(Constant.KEY_ALIAS, null) as SecretKey
|
||||
|
||||
if (mode == Cipher.ENCRYPT_MODE) {
|
||||
cipher!!.init(mode, keyspec)
|
||||
|
|
|
|||
|
|
@ -43,8 +43,6 @@ class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_prepare_payment)
|
||||
|
||||
// MainActivity.commonInit(applicationContext)
|
||||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
ctx = TangemContext.loadFromBundle(this, intent.extras)
|
||||
|
|
|
|||
|
|
@ -44,8 +44,6 @@ class PurgeActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoc
|
|||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
// MainActivity.commonInit(applicationContext)
|
||||
|
||||
ctx = TangemContext.loadFromBundle(this, intent.extras)
|
||||
|
||||
tvCardID.text = ctx.card!!.cidDescription
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue