add thread to avoid main thread freezing
This commit is contained in:
parent
c97d629a7d
commit
2d5893d562
|
@ -148,13 +148,17 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void saveMnemonic(final String mnemonic, final String pairing, final String pin, final Promise promise) {
|
public void saveMnemonic(final String mnemonic, final String pairing, final String pin, final Promise promise) {
|
||||||
try {
|
new Thread(new Runnable() {
|
||||||
smartCard.saveMnemonic(mnemonic, pairing, pin);
|
public void run() {
|
||||||
promise.resolve(true);
|
try {
|
||||||
} catch (IOException | APDUException e) {
|
smartCard.saveMnemonic(mnemonic, pairing, pin);
|
||||||
Log.d(TAG, e.getMessage());
|
promise.resolve(true);
|
||||||
promise.reject(e);
|
} catch (IOException | APDUException e) {
|
||||||
}
|
Log.d(TAG, e.getMessage());
|
||||||
|
promise.reject(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
|
@ -173,23 +177,31 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void deriveKey(final String path, final String pairing, final String pin, final Promise promise) {
|
public void deriveKey(final String path, final String pairing, final String pin, final Promise promise) {
|
||||||
try {
|
new Thread(new Runnable() {
|
||||||
smartCard.deriveKey(path, pairing, pin);
|
public void run() {
|
||||||
promise.resolve(path);
|
try {
|
||||||
} catch (IOException | APDUException e) {
|
smartCard.deriveKey(path, pairing, pin);
|
||||||
Log.d(TAG, e.getMessage());
|
promise.resolve(path);
|
||||||
promise.reject(e);
|
} catch (IOException | APDUException e) {
|
||||||
}
|
Log.d(TAG, e.getMessage());
|
||||||
|
promise.reject(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void exportKey(final String pairing, final String pin, final Promise promise) {
|
public void exportKey(final String pairing, final String pin, final Promise promise) {
|
||||||
try {
|
new Thread(new Runnable() {
|
||||||
promise.resolve(smartCard.exportKey(pairing, pin));
|
public void run() {
|
||||||
} catch (IOException | APDUException e) {
|
try {
|
||||||
Log.d(TAG, e.getMessage());
|
promise.resolve(smartCard.exportKey(pairing, pin));
|
||||||
promise.reject(e);
|
} catch (IOException | APDUException e) {
|
||||||
}
|
Log.d(TAG, e.getMessage());
|
||||||
|
promise.reject(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
|
@ -254,96 +266,127 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
|
||||||
Log.d(TAG, e.getMessage());
|
Log.d(TAG, e.getMessage());
|
||||||
promise.reject(e);
|
promise.reject(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void verifyPin(final String pairing, final String pin, final Promise promise) {
|
public void verifyPin(final String pairing, final String pin, final Promise promise) {
|
||||||
try {
|
new Thread(new Runnable() {
|
||||||
promise.resolve(smartCard.verifyPin(pairing, pin));
|
public void run() {
|
||||||
} catch (IOException | APDUException e) {
|
try {
|
||||||
Log.d(TAG, e.getMessage());
|
promise.resolve(smartCard.verifyPin(pairing, pin));
|
||||||
promise.reject(e);
|
} catch (IOException | APDUException e) {
|
||||||
}
|
Log.d(TAG, e.getMessage());
|
||||||
|
promise.reject(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void changePin(final String pairing, final String currentPin, final String newPin, final Promise promise) {
|
public void changePin(final String pairing, final String currentPin, final String newPin, final Promise promise) {
|
||||||
try {
|
new Thread(new Runnable() {
|
||||||
smartCard.changePin(pairing, currentPin, newPin);
|
public void run() {
|
||||||
promise.resolve(true);
|
try {
|
||||||
} catch (IOException | APDUException e) {
|
smartCard.changePin(pairing, currentPin, newPin);
|
||||||
Log.d(TAG, e.getMessage());
|
promise.resolve(true);
|
||||||
promise.reject(e);
|
} catch (IOException | APDUException e) {
|
||||||
}
|
Log.d(TAG, e.getMessage());
|
||||||
|
promise.reject(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void unblockPin(final String pairing, final String puk, final String newPin, final Promise promise) {
|
public void unblockPin(final String pairing, final String puk, final String newPin, final Promise promise) {
|
||||||
try {
|
new Thread(new Runnable() {
|
||||||
smartCard.unblockPin(pairing, puk, newPin);
|
public void run() {
|
||||||
promise.resolve(true);
|
try {
|
||||||
} catch (IOException | APDUException e) {
|
smartCard.unblockPin(pairing, puk, newPin);
|
||||||
Log.d(TAG, e.getMessage());
|
promise.resolve(true);
|
||||||
promise.reject(e);
|
} catch (IOException | APDUException e) {
|
||||||
}
|
Log.d(TAG, e.getMessage());
|
||||||
|
promise.reject(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void unpair(final String pairing, final String pin, final Promise promise) {
|
public void unpair(final String pairing, final String pin, final Promise promise) {
|
||||||
try {
|
new Thread(new Runnable() {
|
||||||
smartCard.unpair(pairing, pin);
|
public void run() {
|
||||||
promise.resolve(true);
|
try {
|
||||||
} catch (IOException | APDUException e) {
|
smartCard.unpair(pairing, pin);
|
||||||
Log.d(TAG, e.getMessage());
|
promise.resolve(true);
|
||||||
promise.reject(e);
|
} catch (IOException | APDUException e) {
|
||||||
}
|
Log.d(TAG, e.getMessage());
|
||||||
|
promise.reject(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void delete(final Promise promise) {
|
public void delete(final Promise promise) {
|
||||||
try {
|
new Thread(new Runnable() {
|
||||||
smartCard.delete();
|
public void run() {
|
||||||
promise.resolve(true);
|
try {
|
||||||
} catch (IOException | APDUException e) {
|
smartCard.delete();
|
||||||
Log.d(TAG, e.getMessage());
|
promise.resolve(true);
|
||||||
promise.reject(e);
|
} catch (IOException | APDUException e) {
|
||||||
}
|
Log.d(TAG, e.getMessage());
|
||||||
|
promise.reject(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void removeKey(final String pairing, final String pin, final Promise promise) {
|
public void removeKey(final String pairing, final String pin, final Promise promise) {
|
||||||
try {
|
new Thread(new Runnable() {
|
||||||
smartCard.removeKey(pairing, pin);
|
public void run() {
|
||||||
promise.resolve(true);
|
try {
|
||||||
} catch (IOException | APDUException e) {
|
smartCard.removeKey(pairing, pin);
|
||||||
Log.d(TAG, e.getMessage());
|
promise.resolve(true);
|
||||||
promise.reject(e);
|
} catch (IOException | APDUException e) {
|
||||||
}
|
Log.d(TAG, e.getMessage());
|
||||||
|
promise.reject(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void removeKeyWithUnpair(final String pairing, final String pin, final Promise promise) {
|
public void removeKeyWithUnpair(final String pairing, final String pin, final Promise promise) {
|
||||||
try {
|
new Thread(new Runnable() {
|
||||||
smartCard.removeKeyWithUnpair(pairing, pin);
|
public void run() {
|
||||||
promise.resolve(true);
|
try {
|
||||||
} catch (IOException | APDUException e) {
|
smartCard.removeKeyWithUnpair(pairing, pin);
|
||||||
Log.d(TAG, e.getMessage());
|
promise.resolve(true);
|
||||||
promise.reject(e);
|
} catch (IOException | APDUException e) {
|
||||||
}
|
Log.d(TAG, e.getMessage());
|
||||||
|
promise.reject(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void unpairAndDelete(final String pairing, final String pin, final Promise promise) {
|
public void unpairAndDelete(final String pairing, final String pin, final Promise promise) {
|
||||||
try {
|
new Thread(new Runnable() {
|
||||||
smartCard.unpairAndDelete(pairing, pin);
|
public void run() {
|
||||||
promise.resolve(true);
|
try {
|
||||||
} catch (IOException | APDUException e) {
|
smartCard.unpairAndDelete(pairing, pin);
|
||||||
Log.d(TAG, e.getMessage());
|
promise.resolve(true);
|
||||||
promise.reject(e);
|
} catch (IOException | APDUException e) {
|
||||||
}
|
Log.d(TAG, e.getMessage());
|
||||||
|
promise.reject(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue