diff options
author | Andrew Chant <achant@google.com> | 2019-08-08 12:41:20 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-08-08 12:41:20 -0700 |
commit | b2e2e354388543bfcc638a187dbd2a31e52b94fb (patch) | |
tree | d502c8027f6d4ae06e828d4450c80aad169cd8de | |
parent | 03c3d9be0095fbf834bf760c7035e4f551f821d9 (diff) | |
parent | b3b156cf454defbcf3c5b2e50bb5594a70dfcaa9 (diff) | |
download | SecureElement-b2e2e354388543bfcc638a187dbd2a31e52b94fb.tar.gz |
Don't retry on failure for Terminals after index 1
am: b3b156cf45
Change-Id: Iffb0d4f118d8fa6d01e09cc0d10c1b8e4b2d333d
-rw-r--r-- | src/com/android/se/SecureElementService.java | 4 | ||||
-rw-r--r-- | src/com/android/se/Terminal.java | 9 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/com/android/se/SecureElementService.java b/src/com/android/se/SecureElementService.java index 480141a..6f72377 100644 --- a/src/com/android/se/SecureElementService.java +++ b/src/com/android/se/SecureElementService.java @@ -158,7 +158,9 @@ public final class SecureElementService extends Service { do { name = terminalName + Integer.toString(index); Terminal terminal = new Terminal(name, this); - terminal.initialize(); + + // Only retry on fail for the first terminal of each type. + terminal.initialize(index == 1); mTerminals.put(name, terminal); } while (++index > 0); } catch (NoSuchElementException e) { diff --git a/src/com/android/se/Terminal.java b/src/com/android/se/Terminal.java index e17ac88..d21c323 100644 --- a/src/com/android/se/Terminal.java +++ b/src/com/android/se/Terminal.java @@ -160,7 +160,7 @@ public class Terminal { switch (message.what) { case EVENT_GET_HAL: try { - initialize(); + initialize(true); } catch (Exception e) { Log.e(mTag, mName + " could not be initialized again"); sendMessageDelayed(obtainMessage(EVENT_GET_HAL, 0), @@ -185,18 +185,19 @@ public class Terminal { * @throws NoSuchElementException if there is no HAL implementation for the specified SE name * @throws RemoteException if there is a failure communicating with the remote */ - public void initialize() throws NoSuchElementException, RemoteException { + public void initialize(boolean retryOnFail) throws NoSuchElementException, RemoteException { synchronized (mLock) { android.hardware.secure_element.V1_1.ISecureElement seHal11 = null; try { seHal11 = - android.hardware.secure_element.V1_1.ISecureElement.getService(mName, true); + android.hardware.secure_element.V1_1.ISecureElement.getService(mName, + retryOnFail); } catch (Exception e) { Log.d(mTag, "SE Hal V1.1 is not supported"); } if (seHal11 == null) { - mSEHal = ISecureElement.getService(mName, true); + mSEHal = ISecureElement.getService(mName, retryOnFail); if (mSEHal == null) { throw new NoSuchElementException("No HAL is provided for " + mName); } |