Updated on 2026-08-14
This commit is contained in:
parent
bdd27a5dfd
commit
e1984e63aa
5 changed files with 5 additions and 176 deletions
|
|
@ -15,7 +15,7 @@ android {
|
|||
applicationId "com.tangem.wallet"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 28
|
||||
versionCode 100
|
||||
versionCode 101
|
||||
versionName "0.811.1." + generateVersionName()
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@ package com.tangem;
|
|||
import android.app.Application;
|
||||
import android.support.v7.app.AppCompatDelegate;
|
||||
|
||||
import com.tangem.data.db.PINStorage;
|
||||
import com.tangem.di.DaggerNavigatorComponent;
|
||||
import com.tangem.di.DaggerNetworkComponent;
|
||||
import com.tangem.di.NavigatorComponent;
|
||||
import com.tangem.di.NetworkComponent;
|
||||
import com.tangem.domain.cardReader.Firmwares;
|
||||
import com.tangem.domain.wallet.Issuer;
|
||||
import com.tangem.tangemcard.data.Issuer;
|
||||
import com.tangem.tangemcard.data.local.Firmwares;
|
||||
import com.tangem.tangemcard.data.local.PINStorage;
|
||||
|
||||
public class App extends Application {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,67 +0,0 @@
|
|||
package com.tangem.data.nfc;
|
||||
|
||||
import android.content.Context;
|
||||
import android.nfc.tech.IsoDep;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tangem.domain.cardReader.CardProtocol;
|
||||
import com.tangem.domain.cardReader.NfcManager;
|
||||
import com.tangem.data.db.PINStorage;
|
||||
import com.tangem.domain.wallet.TangemCard;
|
||||
import com.tangem.util.Util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ReadCardInfoTask extends Thread {
|
||||
public static final String TAG = ReadCardInfoTask.class.getSimpleName();
|
||||
|
||||
private IsoDep mIsoDep;
|
||||
private CardProtocol.Notifications mNotifications;
|
||||
private boolean isCancelled = false;
|
||||
private Context mContext;
|
||||
private NfcManager mNfcManager;
|
||||
|
||||
// this fields are static to optimize process when need enter pin and scan card again
|
||||
private static ArrayList<String> lastRead_UnsuccessfullPINs = new ArrayList<>();
|
||||
private static TangemCard.EncryptionMode lastRead_Encryption = null;
|
||||
private static String lastRead_UID;
|
||||
|
||||
public static void resetLastReadInfo() {
|
||||
lastRead_UID = "";
|
||||
lastRead_Encryption = null;
|
||||
lastRead_UnsuccessfullPINs.clear();
|
||||
}
|
||||
|
||||
public ReadCardInfoTask(Context context, NfcManager nfcManager, IsoDep isoDep, CardProtocol.Notifications notifications) {
|
||||
mContext = context;
|
||||
mIsoDep = isoDep;
|
||||
mNotifications = notifications;
|
||||
mNfcManager = nfcManager;
|
||||
// ReadCardInfoTask.lastRead_UID = lastRead_UID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (mIsoDep == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// for Samsung's bugs -
|
||||
// Workaround for the Samsung Galaxy S5 (since the
|
||||
// first connection always hangs on transceive).
|
||||
int timeout = mIsoDep.getTimeout();
|
||||
mIsoDep.connect();
|
||||
mIsoDep.close();
|
||||
mIsoDep.connect();
|
||||
mIsoDep.setTimeout(timeout);
|
||||
try {
|
||||
CardProtocol protocol = new CardProtocol(mContext, mIsoDep, mNotifications);
|
||||
mNotifications.onReadStart(protocol);
|
||||
try {
|
||||
mNotifications.onReadProgress(protocol, 5);
|
||||
|
||||
byte[] UID = mIsoDep.getTag().getId();
|
||||
String sUID = Util.byteArrayToHexString(UID);
|
||||
if (!lastRead_UID.equals(sUID)) {
|
||||
resetLastReadInfo();
|
||||
}
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
|
||||
/**
|
||||
* Created by dvol on 04.02.2018.
|
||||
*/
|
||||
|
||||
public class VerifyCardTask extends Thread {
|
||||
public static final String TAG = VerifyCardTask.class.getSimpleName();
|
||||
|
||||
private IsoDep mIsoDep;
|
||||
private CardProtocol.Notifications mNotifications;
|
||||
private boolean isCancelled = false;
|
||||
private Context mContext;
|
||||
private TangemCard mCard;
|
||||
private NfcManager mNfcManager;
|
||||
|
||||
public VerifyCardTask(Context context, TangemCard card, NfcManager nfcManager, IsoDep isoDep, CardProtocol.Notifications notifications) {
|
||||
mCard = card;
|
||||
mContext = context;
|
||||
mIsoDep = isoDep;
|
||||
mNotifications = notifications;
|
||||
mNfcManager = nfcManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (mIsoDep == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// for Samsung's bugs -
|
||||
// Workaround for the Samsung Galaxy S5 (since the
|
||||
// first connection always hangs on transceive).
|
||||
int timeout = mIsoDep.getTimeout();
|
||||
mIsoDep.connect();
|
||||
mIsoDep.close();
|
||||
mIsoDep.connect();
|
||||
mIsoDep.setTimeout(timeout);
|
||||
try {
|
||||
CardProtocol protocol = new CardProtocol(mContext, mIsoDep, mCard, mNotifications);
|
||||
mNotifications.onReadStart(protocol);
|
||||
try {
|
||||
mNotifications.onReadProgress(protocol, 5);
|
||||
|
||||
Log.i(TAG, "[-- Start verify card --]");
|
||||
|
||||
if (isCancelled) return;
|
||||
|
||||
String PIN = mCard.getPIN();
|
||||
protocol.setPIN(PIN);
|
||||
protocol.run_Read(false);
|
||||
PINStorage.setLastUsedPIN(PIN);
|
||||
mNotifications.onReadProgress(protocol, 20);
|
||||
if (isCancelled) return;
|
||||
protocol.run_VerifyCard();
|
||||
mNotifications.onReadProgress(protocol, 50);
|
||||
Log.i(TAG, "Manufacturer: " + protocol.getCard().getManufacturer().getOfficialName());
|
||||
if (isCancelled) return;
|
||||
if (protocol.getCard().getStatus() == TangemCard.Status.Loaded) {
|
||||
protocol.run_CheckWalletWithSignatureVerify();
|
||||
mNotifications.onReadProgress(protocol, 80);
|
||||
}
|
||||
if (isCancelled) return;
|
||||
Firmwares.VerifyCodeRecord record = Firmwares.selectRandomVerifyCodeBlock(mCard.getFirmwareVersion());
|
||||
if (isCancelled) return;
|
||||
if (record != null) {
|
||||
byte[] returnedDigest = protocol.run_VerifyCode(record.hashAlg, record.blockIndex, record.blockCount, record.challenge);
|
||||
mCard.setCodeConfirmed(Arrays.equals(returnedDigest, record.digest));
|
||||
} else {
|
||||
mCard.setCodeConfirmed(null);
|
||||
}
|
||||
mNotifications.onReadProgress(protocol, 90);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
protocol.setError(e);
|
||||
|
||||
} finally {
|
||||
Log.i(TAG, "[-- Finish verify card --]");
|
||||
mNotifications.onReadFinish(protocol);
|
||||
}
|
||||
} finally {
|
||||
mNfcManager.ignoreTag(mIsoDep.getTag());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void cancel(Boolean AllowInterrupt) {
|
||||
try {
|
||||
if (isAlive()) {
|
||||
isCancelled = true;
|
||||
join(500);
|
||||
}
|
||||
if (isAlive() && AllowInterrupt) {
|
||||
interrupt();
|
||||
mNotifications.onReadCancel();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -47,8 +47,7 @@ class Navigator {
|
|||
|
||||
fun showPinSwap(context: Activity, newPIN: String, newPIN2: String) {
|
||||
context.startActivityForResult(PinSwapActivity.callingIntent(context, newPIN, newPIN2), Constant.REQUEST_CODE_SWAP_PIN)
|
||||
fun showVerifyCard(context: Activity, ctx: TangemContext) {
|
||||
context.startActivityForResult(VerifyCardActivity.callingIntent(context, ctx), Constant.REQUEST_CODE_VERIFY_CARD)
|
||||
|
||||
}
|
||||
|
||||
fun showPurge(context: Activity) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue