diff options
author | Martijn Coenen <maco@google.com> | 2011-08-19 14:11:24 +0200 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2011-08-26 10:53:49 -0700 |
commit | bf6e5d1655d5ad524a8ec007413c7011ed969df8 (patch) | |
tree | dd430bd3bc1ab6a29611772b61d987bf3078278c /src/com/android/nfc/NfcService.java | |
parent | a8c503840d56eb615d65f2e707bd2decad0015b9 (diff) | |
download | packages_apps_nfc-bf6e5d1655d5ad524a8ec007413c7011ed969df8.zip packages_apps_nfc-bf6e5d1655d5ad524a8ec007413c7011ed969df8.tar.gz packages_apps_nfc-bf6e5d1655d5ad524a8ec007413c7011ed969df8.tar.bz2 |
Support for getMaxTransceiveLength() API.
Maximum transceive length is enforced in calls to transceive.
Change-Id: I94a4f16283e5fd5df9143b02e52c16f868b1c3ab
Diffstat (limited to 'src/com/android/nfc/NfcService.java')
-rwxr-xr-x | src/com/android/nfc/NfcService.java | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java index 705a82a..1568b27 100755 --- a/src/com/android/nfc/NfcService.java +++ b/src/com/android/nfc/NfcService.java @@ -890,13 +890,21 @@ public class NfcService extends Application implements DeviceHostListener { /* find the tag in the hmap */ tag = (TagEndpoint) findObject(nativeHandle); if (tag != null) { + // Check if length is within limits + if (data.length > getMaxTransceiveLength(tag.getConnectedTechnology())) { + return new TransceiveResult(TransceiveResult.RESULT_EXCEEDED_LENGTH, null); + } int[] targetLost = new int[1]; response = tag.transceive(data, raw, targetLost); - TransceiveResult transResult = new TransceiveResult( - (response != null) ? true : false, - (targetLost[0] == 1) ? true : false, - response); - return transResult; + int result; + if (response != null) { + result = TransceiveResult.RESULT_SUCCESS; + } else if (targetLost[0] == 1) { + result = TransceiveResult.RESULT_TAGLOST; + } else { + result = TransceiveResult.RESULT_FAILURE; + } + return new TransceiveResult(result, response); } return null; } @@ -1070,6 +1078,20 @@ public class NfcService extends Application implements DeviceHostListener { mDeviceHost.resetTimeouts(); } + + @Override + public boolean canMakeReadOnly(int ndefType) throws RemoteException { + mContext.enforceCallingOrSelfPermission(NFC_PERM, NFC_PERM_ERROR); + + return mDeviceHost.canMakeReadOnly(ndefType); + } + + @Override + public int getMaxTransceiveLength(int tech) throws RemoteException { + mContext.enforceCallingOrSelfPermission(NFC_PERM, NFC_PERM_ERROR); + + return mDeviceHost.getMaxTransceiveLength(tech); + } }; private void _nfcEeClose(boolean checkPid, int callingPid) throws IOException { |