Call start() after SmartCard initialized

This commit is contained in:
Dmitry Novotochinov 2019-01-07 21:07:02 +03:00
parent cd432d19c2
commit 7c0feb912c
No known key found for this signature in database
GPG Key ID: 43D1DAF5AD39C927
3 changed files with 18 additions and 9 deletions

View File

@ -42,6 +42,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
public void onHostResume() {
if (this.smartCard == null) {
this.smartCard = new SmartCard(getCurrentActivity(), reactContext);
smartCard.start();
}
}

View File

@ -42,6 +42,7 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
private CardChannel cardChannel;
private EventEmitter eventEmitter;
private static final String TAG = "SmartCard";
private Boolean started = false;
private static final String WALLET_PATH = "m/44'/0'/0'/0/0";
private static final String WHISPER_PATH = "m/43'/60'/1581'/0'/0";
@ -65,15 +66,22 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
}
public boolean start() {
this.cardManager.start();
if (this.nfcAdapter != null) {
IntentFilter filter = new IntentFilter(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED);
activity.registerReceiver(this, filter);
nfcAdapter.enableReaderMode(activity, this.cardManager, NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK, null);
return true;
if (!started) {
this.cardManager.start();
started = true;
if (this.nfcAdapter != null) {
IntentFilter filter = new IntentFilter(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED);
activity.registerReceiver(this, filter);
nfcAdapter.enableReaderMode(activity, this.cardManager, NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK, null);
return true;
} else {
log("not support in this device");
return false;
}
} else {
log("not support in this device");
return false;
return true;
}
}

View File

@ -1,7 +1,7 @@
{
"name": "react-native-status-keycard",
"version": "2.3.0",
"version": "2.3.1",
"description": "React Native library to interact with Status Keycard using NFC connection (Android only)",
"main": "index.js",
"scripts": {