Merge "Add API for querying extended length APDU support."

This commit is contained in:
Martijn Coenen
2012-04-04 11:19:08 -07:00
committed by Android (Google) Code Review
3 changed files with 25 additions and 0 deletions

View File

@@ -12899,6 +12899,7 @@ package android.nfc.tech {
method public byte[] getHistoricalBytes();
method public int getMaxTransceiveLength();
method public int getTimeout();
method public boolean isExtendedLengthApduSupported();
method public void setTimeout(int);
method public byte[] transceive(byte[]) throws java.io.IOException;
}

View File

@@ -45,4 +45,5 @@ interface INfcTag
void resetTimeouts();
boolean canMakeReadOnly(int ndefType);
int getMaxTransceiveLength(int technology);
boolean getExtendedLengthApdusSupported();
}

View File

@@ -179,4 +179,27 @@ public final class IsoDep extends BasicTagTechnology {
public int getMaxTransceiveLength() {
return getMaxTransceiveLengthInternal();
}
/**
* <p>Standard APDUs have a 1-byte length field, allowing a maximum of
* 255 payload bytes, which results in a maximum APDU length of 261 bytes.
*
* <p>Extended length APDUs have a 3-byte length field, allowing 65535
* payload bytes.
*
* <p>Some NFC adapters, like the one used in the Nexus S and the Galaxy Nexus
* do not support extended length APDUs. They are expected to be well-supported
* in the future though. Use this method to check for extended length APDU
* support.
*
* @return whether the NFC adapter on this device supports extended length APDUs.
*/
public boolean isExtendedLengthApduSupported() {
try {
return mTag.getTagService().getExtendedLengthApdusSupported();
} catch (RemoteException e) {
Log.e(TAG, "NFC service dead", e);
return false;
}
}
}