Skip to content

Commit 30bd284

Browse files
Martijn CoenenAndroid (Google) Code Review
authored andcommitted
Merge "Add API for querying extended length APDU support."
2 parents 1899b73 + fa98cf0 commit 30bd284

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

api/current.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12899,6 +12899,7 @@ package android.nfc.tech {
1289912899
method public byte[] getHistoricalBytes();
1290012900
method public int getMaxTransceiveLength();
1290112901
method public int getTimeout();
12902+
method public boolean isExtendedLengthApduSupported();
1290212903
method public void setTimeout(int);
1290312904
method public byte[] transceive(byte[]) throws java.io.IOException;
1290412905
}

core/java/android/nfc/INfcTag.aidl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ interface INfcTag
4545
void resetTimeouts();
4646
boolean canMakeReadOnly(int ndefType);
4747
int getMaxTransceiveLength(int technology);
48+
boolean getExtendedLengthApdusSupported();
4849
}

core/java/android/nfc/tech/IsoDep.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,27 @@ public byte[] transceive(byte[] data) throws IOException {
179179
public int getMaxTransceiveLength() {
180180
return getMaxTransceiveLengthInternal();
181181
}
182+
183+
/**
184+
* <p>Standard APDUs have a 1-byte length field, allowing a maximum of
185+
* 255 payload bytes, which results in a maximum APDU length of 261 bytes.
186+
*
187+
* <p>Extended length APDUs have a 3-byte length field, allowing 65535
188+
* payload bytes.
189+
*
190+
* <p>Some NFC adapters, like the one used in the Nexus S and the Galaxy Nexus
191+
* do not support extended length APDUs. They are expected to be well-supported
192+
* in the future though. Use this method to check for extended length APDU
193+
* support.
194+
*
195+
* @return whether the NFC adapter on this device supports extended length APDUs.
196+
*/
197+
public boolean isExtendedLengthApduSupported() {
198+
try {
199+
return mTag.getTagService().getExtendedLengthApdusSupported();
200+
} catch (RemoteException e) {
201+
Log.e(TAG, "NFC service dead", e);
202+
return false;
203+
}
204+
}
182205
}

0 commit comments

Comments
 (0)