summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Martijn Coenen <martijn.coenen@nxp.com> 2010-12-10 10:46:56 -0800
committer Jeff Hamilton <jham@android.com> 2010-12-10 22:06:35 -0600
commitfc5a3b6cfb85679e82a39730c7154b55b0711a0c (patch)
tree91131c97bf5133a1a9c1740348d71046ae68098a
parent3300e4c3ea2f2317532ded6f9e79d6ad9e038679 (diff)
Changed transceive on all technologies to "raw", except for Mifare classes.
Change-Id: I3d680e37fec0ab84cdbb70d9fb6fff9527dd76a2
-rw-r--r--core/java/android/nfc/INfcTag.aidl2
-rw-r--r--core/java/android/nfc/technology/BasicTagTechnology.java4
-rw-r--r--core/java/android/nfc/technology/MifareClassic.java25
-rw-r--r--core/java/android/nfc/technology/MifareUltralight.java25
-rw-r--r--core/java/android/nfc/technology/Ndef.java5
-rw-r--r--core/java/android/nfc/technology/NdefFormatable.java5
6 files changed, 63 insertions, 3 deletions
diff --git a/core/java/android/nfc/INfcTag.aidl b/core/java/android/nfc/INfcTag.aidl
index f5c79e74d474..69e5bc7d3a88 100644
--- a/core/java/android/nfc/INfcTag.aidl
+++ b/core/java/android/nfc/INfcTag.aidl
@@ -29,7 +29,7 @@ interface INfcTag
byte[] getUid(int nativeHandle);
boolean isNdef(int nativeHandle);
boolean isPresent(int nativeHandle);
- byte[] transceive(int nativeHandle, in byte[] data);
+ byte[] transceive(int nativeHandle, in byte[] data, boolean raw);
int getLastError(int nativeHandle);
diff --git a/core/java/android/nfc/technology/BasicTagTechnology.java b/core/java/android/nfc/technology/BasicTagTechnology.java
index 6b281b9898a4..ba8bd559cfc2 100644
--- a/core/java/android/nfc/technology/BasicTagTechnology.java
+++ b/core/java/android/nfc/technology/BasicTagTechnology.java
@@ -181,9 +181,9 @@ import android.util.Log;
*/
public byte[] transceive(byte[] data) throws IOException {
try {
- byte[] response = mTagService.transceive(mTag.getServiceHandle(), data);
+ byte[] response = mTagService.transceive(mTag.getServiceHandle(), data, true);
if (response == null) {
- throw new IOException("transcieve failed");
+ throw new IOException("transceive failed");
}
return response;
} catch (RemoteException e) {
diff --git a/core/java/android/nfc/technology/MifareClassic.java b/core/java/android/nfc/technology/MifareClassic.java
index bd20808a1f26..defdcf263b79 100644
--- a/core/java/android/nfc/technology/MifareClassic.java
+++ b/core/java/android/nfc/technology/MifareClassic.java
@@ -285,5 +285,30 @@ public final class MifareClassic extends BasicTagTechnology {
public void writeSectorAccessControl(int sector, int access);
public void increment(int block);
public void decrement(int block);
+
*/
+ /**
+ * Send data to a tag and receive the response.
+ * <p>
+ * This method will block until the response is received. It can be canceled
+ * with {@link #close}.
+ * <p>Requires {@link android.Manifest.permission#NFC} permission.
+ *
+ * @param data bytes to send
+ * @return bytes received in response
+ * @throws IOException if the target is lost or connection closed
+ */
+ @Override
+ public byte[] transceive(byte[] data) throws IOException {
+ try {
+ byte[] response = mTagService.transceive(mTag.getServiceHandle(), data, false);
+ if (response == null) {
+ throw new IOException("transceive failed");
+ }
+ return response;
+ } catch (RemoteException e) {
+ attemptDeadServiceRecovery(e);
+ throw new IOException("NFC service died");
+ }
+ }
}
diff --git a/core/java/android/nfc/technology/MifareUltralight.java b/core/java/android/nfc/technology/MifareUltralight.java
index 6681688e5e45..58d264572976 100644
--- a/core/java/android/nfc/technology/MifareUltralight.java
+++ b/core/java/android/nfc/technology/MifareUltralight.java
@@ -71,6 +71,31 @@ public final class MifareUltralight extends BasicTagTechnology {
}
/**
+ * Send data to a tag and receive the response.
+ * <p>
+ * This method will block until the response is received. It can be canceled
+ * with {@link #close}.
+ * <p>Requires {@link android.Manifest.permission#NFC} permission.
+ *
+ * @param data bytes to send
+ * @return bytes received in response
+ * @throws IOException if the target is lost or connection closed
+ */
+ @Override
+ public byte[] transceive(byte[] data) throws IOException {
+ try {
+ byte[] response = mTagService.transceive(mTag.getServiceHandle(), data, false);
+ if (response == null) {
+ throw new IOException("transceive failed");
+ }
+ return response;
+ } catch (RemoteException e) {
+ attemptDeadServiceRecovery(e);
+ throw new IOException("NFC service died");
+ }
+ }
+
+ /**
* @throws IOException
*/
/*
diff --git a/core/java/android/nfc/technology/Ndef.java b/core/java/android/nfc/technology/Ndef.java
index b2e70c96007d..e76a573649e1 100644
--- a/core/java/android/nfc/technology/Ndef.java
+++ b/core/java/android/nfc/technology/Ndef.java
@@ -195,4 +195,9 @@ public final class Ndef extends BasicTagTechnology {
public void makeLowLevelReadonly() {
throw new UnsupportedOperationException();
}
+
+ @Override
+ public byte[] transceive(byte[] data) {
+ throw new UnsupportedOperationException();
+ }
}
diff --git a/core/java/android/nfc/technology/NdefFormatable.java b/core/java/android/nfc/technology/NdefFormatable.java
index 3ed37a512407..8744876abe6f 100644
--- a/core/java/android/nfc/technology/NdefFormatable.java
+++ b/core/java/android/nfc/technology/NdefFormatable.java
@@ -89,4 +89,9 @@ public final class NdefFormatable extends BasicTagTechnology {
attemptDeadServiceRecovery(e);
}
}
+
+ @Override
+ public byte[] transceive(byte[] data) {
+ throw new UnsupportedOperationException();
+ }
}