summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/org/simalliance/openmobileapi/service/SmartcardService.java20
-rw-r--r--src/org/simalliance/openmobileapi/service/terminals/SmartMxTerminal.java22
2 files changed, 34 insertions, 8 deletions
diff --git a/src/org/simalliance/openmobileapi/service/SmartcardService.java b/src/org/simalliance/openmobileapi/service/SmartcardService.java
index 05bbc2d..113bbc3 100644
--- a/src/org/simalliance/openmobileapi/service/SmartcardService.java
+++ b/src/org/simalliance/openmobileapi/service/SmartcardService.java
@@ -206,11 +206,25 @@ public final class SmartcardService extends Service {
+ " smartcard service onCreate");
final Context context = getApplicationContext();
- Log.d(_TAG,"NfcAdapter acquired");
new Thread(){
public void run() {
- NfcQcomAdapter.getNfcQcomAdapter(context);
- Log.d(_TAG,"binding established");
+ for(int tries = 0; tries < 3; tries++) {
+ try {
+ NfcQcomAdapter.getNfcQcomAdapter(context);
+ Log.d(_TAG,"binding established");
+ return;
+ } catch (UnsupportedOperationException e) {
+ String errorMsg = "Smartcard service gracefully failing to acquire NfcQcomAdapter at boot. try" + tries;
+ Log.e(_TAG, errorMsg);
+ new Throwable(_TAG + ": " + errorMsg, e);
+ e.printStackTrace();
+ }
+ try {
+ wait(5000);
+ } catch (Exception e) {
+ Log.d(_TAG, "Interupted while waiting for NfcQcomAdapter by " + e);
+ }
+ }
}
}.start();
// Start up the thread running the service. Note that we create a
diff --git a/src/org/simalliance/openmobileapi/service/terminals/SmartMxTerminal.java b/src/org/simalliance/openmobileapi/service/terminals/SmartMxTerminal.java
index d8952ca..0de4efb 100644
--- a/src/org/simalliance/openmobileapi/service/terminals/SmartMxTerminal.java
+++ b/src/org/simalliance/openmobileapi/service/terminals/SmartMxTerminal.java
@@ -62,14 +62,26 @@ public class SmartMxTerminal extends Terminal {
}
@Override
protected Void doInBackground(Void... unused) {
- try {
+ for(int tries = 0; tries < 3; tries++) {
+ try {
mNfcQcomAdapter = NfcQcomAdapter.getNfcQcomAdapter(context);
- if (mNfcQcomAdapter == null)
+ if (mNfcQcomAdapter == null) {
Log.d (TAG, "mNfcQcomAdapter is NULL");
- Log.d (TAG, "SmartMxTerminal NfcQcomAdapter");
+ } else {
+ Log.d (TAG, "acquired NfcQcomAdapter");
+ return null;
+ }
+ } catch (UnsupportedOperationException e) {
+ String errorMsg = "SmartMxTerminal() gracefully failing to acquire NfcQcomAdapter at boot. try" + tries;
+ Log.e(TAG, errorMsg);
+ new Throwable(TAG + ": " + errorMsg, e);
+ e.printStackTrace();
+ }
+ try {
+ wait(5000);
+ } catch (Exception e) {
+ Log.d(TAG, "Interupted while waiting for NfcQcomAdapter by " + e);
}
- catch( Exception e ){
- Log.e(TAG, "doInBackground(): got exception" + e.getMessage());;
}
return null;
}