Snap for 5791668 from b3b156cf454defbcf3c5b2e50bb5594a70dfcaa9 to qt-c2f2-release
Change-Id: I423cbb14b9efaed72573fc7b896357a1a819256e
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 @@
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 @@
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 @@
* @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);
}