summaryrefslogtreecommitdiff
path: root/nfc-extras/java/com/android/nfc_extras/NfcExecutionEnvironment.java
diff options
context:
space:
mode:
authorNick Pelly <npelly@google.com>2011-04-26 16:38:00 -0700
committerNick Pelly <npelly@google.com>2011-04-26 16:38:00 -0700
commitcc9ee72bd42bb40b1852f907f58305adde12ecc2 (patch)
tree4870cc32b9330093d21ba4a7167ee6dbc127e400 /nfc-extras/java/com/android/nfc_extras/NfcExecutionEnvironment.java
parentd2127c438fc858a4f6c8ad75b7a1e4491da69a78 (diff)
Implement dead service recovery in NFC extras library.
Change-Id: I4f1d714c625470df4cda2c4c9aacb8d27bfabb10
Diffstat (limited to 'nfc-extras/java/com/android/nfc_extras/NfcExecutionEnvironment.java')
-rw-r--r--nfc-extras/java/com/android/nfc_extras/NfcExecutionEnvironment.java21
1 files changed, 12 insertions, 9 deletions
diff --git a/nfc-extras/java/com/android/nfc_extras/NfcExecutionEnvironment.java b/nfc-extras/java/com/android/nfc_extras/NfcExecutionEnvironment.java
index 3efe49236de9..eb2f6f859191 100644
--- a/nfc-extras/java/com/android/nfc_extras/NfcExecutionEnvironment.java
+++ b/nfc-extras/java/com/android/nfc_extras/NfcExecutionEnvironment.java
@@ -29,7 +29,7 @@ import android.os.IBinder;
import android.os.RemoteException;
public class NfcExecutionEnvironment {
- private final INfcAdapterExtras mService;
+ private final NfcAdapterExtras mExtras;
/**
* Broadcast Action: An ISO-DEP AID was selected.
@@ -55,8 +55,8 @@ public class NfcExecutionEnvironment {
*/
public static final String EXTRA_AID = "com.android.nfc_extras.extra.AID";
- NfcExecutionEnvironment(INfcAdapterExtras service) {
- mService = service;
+ NfcExecutionEnvironment(NfcAdapterExtras extras) {
+ mExtras = extras;
}
/**
@@ -75,10 +75,11 @@ public class NfcExecutionEnvironment {
*/
public void open() throws IOException {
try {
- Bundle b = mService.open(new Binder());
+ Bundle b = mExtras.getService().open(new Binder());
throwBundle(b);
} catch (RemoteException e) {
- return;
+ mExtras.attemptDeadServiceRecovery(e);
+ throw new IOException("NFC Service was dead, try again");
}
}
@@ -92,9 +93,10 @@ public class NfcExecutionEnvironment {
*/
public void close() throws IOException {
try {
- throwBundle(mService.close());
+ throwBundle(mExtras.getService().close());
} catch (RemoteException e) {
- return;
+ mExtras.attemptDeadServiceRecovery(e);
+ throw new IOException("NFC Service was dead");
}
}
@@ -109,9 +111,10 @@ public class NfcExecutionEnvironment {
public byte[] transceive(byte[] in) throws IOException {
Bundle b;
try {
- b = mService.transceive(in);
+ b = mExtras.getService().transceive(in);
} catch (RemoteException e) {
- throw new IOException(e.getMessage());
+ mExtras.attemptDeadServiceRecovery(e);
+ throw new IOException("NFC Service was dead, need to re-open");
}
throwBundle(b);
return b.getByteArray("out");