diff options
| author | Martijn Coenen <martijn.coenen@nxp.com> | 2010-12-13 12:31:23 -0800 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2010-12-13 12:31:23 -0800 |
| commit | 4e656372bd89a9b6e75ef01861b6224f83b055d0 (patch) | |
| tree | 87bf4e84c17934dbfde8938b0444007d5ddbf248 /core/java | |
| parent | 8efdf6459e5822a506952569f323d35c589cbc5e (diff) | |
| parent | 2019f53396f5b45a307cc4b24123eb19b9a5246f (diff) | |
| download | frameworks_base-4e656372bd89a9b6e75ef01861b6224f83b055d0.zip frameworks_base-4e656372bd89a9b6e75ef01861b6224f83b055d0.tar.gz frameworks_base-4e656372bd89a9b6e75ef01861b6224f83b055d0.tar.bz2 | |
am 2019f533: am fc5a3b6c: Changed transceive on all technologies to "raw", except for Mifare classes.
* commit '2019f53396f5b45a307cc4b24123eb19b9a5246f':
Changed transceive on all technologies to "raw", except for Mifare classes.
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(); + } } |
