am fc5a3b6c: Changed transceive on all technologies to "raw", except for Mifare classes.

* commit 'fc5a3b6cfb85679e82a39730c7154b55b0711a0c':
  Changed transceive on all technologies to "raw", except for Mifare classes.
This commit is contained in:
Martijn Coenen
2010-12-10 20:40:34 -08:00
committed by Android Git Automerger
6 changed files with 63 additions and 3 deletions

View File

@ -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);

View File

@ -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) {

View File

@ -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");
}
}
}

View File

@ -70,6 +70,31 @@ public final class MifareUltralight extends BasicTagTechnology {
return transceive(blockread_cmd);
}
/**
* 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
*/

View File

@ -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();
}
}

View File

@ -89,4 +89,9 @@ public final class NdefFormatable extends BasicTagTechnology {
attemptDeadServiceRecovery(e);
}
}
@Override
public byte[] transceive(byte[] data) {
throw new UnsupportedOperationException();
}
}