diff options
| 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 |
| commit | fc5a3b6cfb85679e82a39730c7154b55b0711a0c (patch) | |
| tree | 91131c97bf5133a1a9c1740348d71046ae68098a /core/java | |
| parent | 3300e4c3ea2f2317532ded6f9e79d6ad9e038679 (diff) | |
| download | frameworks_base-fc5a3b6cfb85679e82a39730c7154b55b0711a0c.zip frameworks_base-fc5a3b6cfb85679e82a39730c7154b55b0711a0c.tar.gz frameworks_base-fc5a3b6cfb85679e82a39730c7154b55b0711a0c.tar.bz2 | |
Changed transceive on all technologies to "raw", except for Mifare classes.
Change-Id: I3d680e37fec0ab84cdbb70d9fb6fff9527dd76a2
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/nfc/INfcTag.aidl | 2 | ||||
| -rw-r--r-- | core/java/android/nfc/technology/BasicTagTechnology.java | 4 | ||||
| -rw-r--r-- | core/java/android/nfc/technology/MifareClassic.java | 25 | ||||
| -rw-r--r-- | core/java/android/nfc/technology/MifareUltralight.java | 25 | ||||
| -rw-r--r-- | core/java/android/nfc/technology/Ndef.java | 5 | ||||
| -rw-r--r-- | core/java/android/nfc/technology/NdefFormatable.java | 5 |
6 files changed, 63 insertions, 3 deletions
diff --git a/core/java/android/nfc/INfcTag.aidl b/core/java/android/nfc/INfcTag.aidl index f5c79e7..69e5bc7 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 6b281b9..ba8bd55 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 bd20808..defdcf2 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 6681688..58d2645 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 b2e70c9..e76a573 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 3ed37a5..8744876 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(); + } } |
