Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class HCEService extends HostApduService implements HCEServiceCallback {
private static final String TAG = "HCEService";

private boolean isForeground;
private volatile boolean isDeactivated;
private String backgroundSessionUUID;
private RTNHCEAndroidModule hceModule;
private byte[] pendingCAPDU;
Expand Down Expand Up @@ -118,6 +119,7 @@ public void onBackgroundHCEFinish(String handle) {
HeadlessJsTaskContext headlessJsTaskContext = Companion.getInstance(reactContext);
headlessJsTaskContext.finishTask(taskId);
taskSessionIdMap.remove(handle);
stopSelf();
}

@Override
Expand All @@ -144,6 +146,11 @@ public void onRespondAPDU(String handle, String rapdu) {
@Override
public byte[] processCommandApdu(byte[] command, Bundle extras) {
Log.d(TAG, "HCEService:processCommandApdu");

if (isDeactivated) {
onCreate();
}

String capdu = BinaryUtils.ByteArrayToHexString(command).toUpperCase(Locale.ROOT);

if (isForeground) {
Expand Down Expand Up @@ -181,6 +188,7 @@ public void onCreate() {
}

isForeground = isAppOnForeground(getApplicationContext());
isDeactivated = false;
pendingCAPDU = null;
hceModule = null;
needsResponse = false;
Expand Down Expand Up @@ -242,6 +250,7 @@ public void onHeadlessJsTaskFinish(int i) {
public void onDeactivated(int reason) {
Log.d(TAG, "HCEService:onDeactivated: " + reason);
needsResponse = false;
isDeactivated = true;

if (isForeground) {
if (this.hceModule != null && this.hceModule.isHCEActiveConnection()) {
Expand Down