diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2015-02-06 20:44:23 -0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2015-02-06 20:44:23 -0800 |
commit | a2427ece2b294a9afb3752b6595b0e5b00e6f847 (patch) | |
tree | 61808cbe0be170c30c392848e66726bcd3436399 | |
parent | 4165f01cf4c795b202e21d82244d93ae0b37dd11 (diff) | |
parent | 63cf30972cf6c0f155acd6b819cb7612076ec469 (diff) | |
download | android_packages_apps_SmartCardService-stable/cm-12.1-YOG4P.tar.gz android_packages_apps_SmartCardService-stable/cm-12.1-YOG4P.tar.bz2 android_packages_apps_SmartCardService-stable/cm-12.1-YOG4P.zip |
Merge "NFC: Handle exception and retry to get NfcQcomAdaper"staging/cm-12.1stable/cm-12.1-YOG7Dstable/cm-12.1-YOG4Pstable/cm-12.1-YOG3Ccm-12.1
-rw-r--r-- | src/org/simalliance/openmobileapi/service/SmartcardService.java | 20 | ||||
-rw-r--r-- | src/org/simalliance/openmobileapi/service/terminals/SmartMxTerminal.java | 22 |
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; } |