Loading api/current.txt +7 −0 Original line number Original line Diff line number Diff line Loading @@ -12465,6 +12465,7 @@ package android.nfc.tech { method public static android.nfc.tech.IsoDep get(android.nfc.Tag); method public static android.nfc.tech.IsoDep get(android.nfc.Tag); method public byte[] getHiLayerResponse(); method public byte[] getHiLayerResponse(); method public byte[] getHistoricalBytes(); method public byte[] getHistoricalBytes(); method public int getMaxTransceiveLength(); method public void setTimeout(int); method public void setTimeout(int); method public byte[] transceive(byte[]) throws java.io.IOException; method public byte[] transceive(byte[]) throws java.io.IOException; } } Loading @@ -12477,6 +12478,7 @@ package android.nfc.tech { method public static android.nfc.tech.MifareClassic get(android.nfc.Tag); method public static android.nfc.tech.MifareClassic get(android.nfc.Tag); method public int getBlockCount(); method public int getBlockCount(); method public int getBlockCountInSector(int); method public int getBlockCountInSector(int); method public int getMaxTransceiveLength(); method public int getSectorCount(); method public int getSectorCount(); method public int getSize(); method public int getSize(); method public int getType(); method public int getType(); Loading @@ -12503,6 +12505,7 @@ package android.nfc.tech { public final class MifareUltralight extends android.nfc.tech.BasicTagTechnology { public final class MifareUltralight extends android.nfc.tech.BasicTagTechnology { method public static android.nfc.tech.MifareUltralight get(android.nfc.Tag); method public static android.nfc.tech.MifareUltralight get(android.nfc.Tag); method public int getMaxTransceiveLength(); method public int getType(); method public int getType(); method public byte[] readPages(int) throws java.io.IOException; method public byte[] readPages(int) throws java.io.IOException; method public byte[] transceive(byte[]) throws java.io.IOException; method public byte[] transceive(byte[]) throws java.io.IOException; Loading Loading @@ -12539,6 +12542,7 @@ package android.nfc.tech { public final class NfcA extends android.nfc.tech.BasicTagTechnology { public final class NfcA extends android.nfc.tech.BasicTagTechnology { method public static android.nfc.tech.NfcA get(android.nfc.Tag); method public static android.nfc.tech.NfcA get(android.nfc.Tag); method public byte[] getAtqa(); method public byte[] getAtqa(); method public int getMaxTransceiveLength(); method public short getSak(); method public short getSak(); method public byte[] transceive(byte[]) throws java.io.IOException; method public byte[] transceive(byte[]) throws java.io.IOException; } } Loading @@ -12546,6 +12550,7 @@ package android.nfc.tech { public final class NfcB extends android.nfc.tech.BasicTagTechnology { public final class NfcB extends android.nfc.tech.BasicTagTechnology { method public static android.nfc.tech.NfcB get(android.nfc.Tag); method public static android.nfc.tech.NfcB get(android.nfc.Tag); method public byte[] getApplicationData(); method public byte[] getApplicationData(); method public int getMaxTransceiveLength(); method public byte[] getProtocolInfo(); method public byte[] getProtocolInfo(); method public byte[] transceive(byte[]) throws java.io.IOException; method public byte[] transceive(byte[]) throws java.io.IOException; } } Loading @@ -12553,6 +12558,7 @@ package android.nfc.tech { public final class NfcF extends android.nfc.tech.BasicTagTechnology { public final class NfcF extends android.nfc.tech.BasicTagTechnology { method public static android.nfc.tech.NfcF get(android.nfc.Tag); method public static android.nfc.tech.NfcF get(android.nfc.Tag); method public byte[] getManufacturer(); method public byte[] getManufacturer(); method public int getMaxTransceiveLength(); method public byte[] getSystemCode(); method public byte[] getSystemCode(); method public byte[] transceive(byte[]) throws java.io.IOException; method public byte[] transceive(byte[]) throws java.io.IOException; } } Loading @@ -12560,6 +12566,7 @@ package android.nfc.tech { public final class NfcV extends android.nfc.tech.BasicTagTechnology { public final class NfcV extends android.nfc.tech.BasicTagTechnology { method public static android.nfc.tech.NfcV get(android.nfc.Tag); method public static android.nfc.tech.NfcV get(android.nfc.Tag); method public byte getDsfId(); method public byte getDsfId(); method public int getMaxTransceiveLength(); method public byte getResponseFlags(); method public byte getResponseFlags(); method public byte[] transceive(byte[]) throws java.io.IOException; method public byte[] transceive(byte[]) throws java.io.IOException; } } core/java/android/nfc/INfcTag.aidl +2 −0 Original line number Original line Diff line number Diff line Loading @@ -46,4 +46,6 @@ interface INfcTag int setTimeout(int technology, int timeout); int setTimeout(int technology, int timeout); int getTimeout(int technology); int getTimeout(int technology); void resetTimeouts(); void resetTimeouts(); boolean canMakeReadOnly(int ndefType); int getMaxTransceiveLength(int technology); } } core/java/android/nfc/TransceiveResult.java +27 −24 Original line number Original line Diff line number Diff line Loading @@ -19,33 +19,38 @@ package android.nfc; import android.os.Parcel; import android.os.Parcel; import android.os.Parcelable; import android.os.Parcelable; import java.io.IOException; /** /** * Class used to pipe transceive result from the NFC service. * Class used to pipe transceive result from the NFC service. * * * @hide * @hide */ */ public final class TransceiveResult implements Parcelable { public final class TransceiveResult implements Parcelable { private final boolean mTagLost; public static final int RESULT_SUCCESS = 0; private final boolean mSuccess; public static final int RESULT_FAILURE = 1; private final byte[] mResponseData; public static final int RESULT_TAGLOST = 2; public static final int RESULT_EXCEEDED_LENGTH = 3; public TransceiveResult(final boolean success, final boolean tagIsLost, final int mResult; final byte[] data) { final byte[] mResponseData; mSuccess = success; mTagLost = tagIsLost; mResponseData = data; } public boolean isSuccessful() { public TransceiveResult(final int result, final byte[] data) { return mSuccess; mResult = result; } mResponseData = data; public boolean isTagLost() { return mTagLost; } } public byte[] getResponseData() { public byte[] getResponseOrThrow() throws IOException { switch (mResult) { case RESULT_SUCCESS: return mResponseData; return mResponseData; case RESULT_TAGLOST: throw new TagLostException("Tag was lost."); case RESULT_EXCEEDED_LENGTH: throw new IOException("Transceive length exceeds supported maximum"); default: throw new IOException("Transceive failed"); } } } @Override @Override Loading @@ -55,9 +60,8 @@ public final class TransceiveResult implements Parcelable { @Override @Override public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) { dest.writeInt(mSuccess ? 1 : 0); dest.writeInt(mResult); dest.writeInt(mTagLost ? 1 : 0); if (mResult == RESULT_SUCCESS) { if (mSuccess) { dest.writeInt(mResponseData.length); dest.writeInt(mResponseData.length); dest.writeByteArray(mResponseData); dest.writeByteArray(mResponseData); } } Loading @@ -67,18 +71,17 @@ public final class TransceiveResult implements Parcelable { new Parcelable.Creator<TransceiveResult>() { new Parcelable.Creator<TransceiveResult>() { @Override @Override public TransceiveResult createFromParcel(Parcel in) { public TransceiveResult createFromParcel(Parcel in) { boolean success = (in.readInt() == 1) ? true : false; int result = in.readInt(); boolean tagLost = (in.readInt() == 1) ? true : false; byte[] responseData; byte[] responseData; if (success) { if (result == RESULT_SUCCESS) { int responseLength = in.readInt(); int responseLength = in.readInt(); responseData = new byte[responseLength]; responseData = new byte[responseLength]; in.readByteArray(responseData); in.readByteArray(responseData); } else { } else { responseData = null; responseData = null; } } return new TransceiveResult(success, tagLost, responseData); return new TransceiveResult(result, responseData); } } @Override @Override Loading core/java/android/nfc/tech/BasicTagTechnology.java +10 −10 Original line number Original line Diff line number Diff line Loading @@ -129,6 +129,15 @@ import java.io.IOException; } } } } /** Internal getMaxTransceiveLength() */ int getMaxTransceiveLengthInternal() { try { return mTag.getTagService().getMaxTransceiveLength(mSelectedTechnology); } catch (RemoteException e) { Log.e(TAG, "NFC service dead", e); return 0; } } /** Internal transceive */ /** Internal transceive */ /*package*/ byte[] transceive(byte[] data, boolean raw) throws IOException { /*package*/ byte[] transceive(byte[] data, boolean raw) throws IOException { checkConnected(); checkConnected(); Loading @@ -139,16 +148,7 @@ import java.io.IOException; if (result == null) { if (result == null) { throw new IOException("transceive failed"); throw new IOException("transceive failed"); } else { } else { if (result.isSuccessful()) { return result.getResponseOrThrow(); return result.getResponseData(); } else { if (result.isTagLost()) { throw new TagLostException("Tag was lost."); } else { throw new IOException("transceive failed"); } } } } } catch (RemoteException e) { } catch (RemoteException e) { Log.e(TAG, "NFC service dead", e); Log.e(TAG, "NFC service dead", e); Loading core/java/android/nfc/tech/IsoDep.java +11 −0 Original line number Original line Diff line number Diff line Loading @@ -156,6 +156,9 @@ public final class IsoDep extends BasicTagTechnology { * will be automatically fragmented and defragmented by {@link #transceive} if * will be automatically fragmented and defragmented by {@link #transceive} if * it exceeds FSD/FSC limits. * it exceeds FSD/FSC limits. * * * <p>Use {@link #getMaxTransceiveLength} to retrieve the maximum number of bytes * that can be sent with {@link #transceive}. * * <p>This is an I/O operation and will block until complete. It must * <p>This is an I/O operation and will block until complete. It must * not be called from the main application thread. A blocked call will be canceled with * not be called from the main application thread. A blocked call will be canceled with * {@link IOException} if {@link #close} is called from another thread. * {@link IOException} if {@link #close} is called from another thread. Loading @@ -170,4 +173,12 @@ public final class IsoDep extends BasicTagTechnology { public byte[] transceive(byte[] data) throws IOException { public byte[] transceive(byte[] data) throws IOException { return transceive(data, true); return transceive(data, true); } } /** * Return the maximum number of bytes that can be sent with {@link #transceive}. * @return the maximum number of bytes that can be sent with {@link #transceive}. */ public int getMaxTransceiveLength() { return getMaxTransceiveLengthInternal(); } } } Loading
api/current.txt +7 −0 Original line number Original line Diff line number Diff line Loading @@ -12465,6 +12465,7 @@ package android.nfc.tech { method public static android.nfc.tech.IsoDep get(android.nfc.Tag); method public static android.nfc.tech.IsoDep get(android.nfc.Tag); method public byte[] getHiLayerResponse(); method public byte[] getHiLayerResponse(); method public byte[] getHistoricalBytes(); method public byte[] getHistoricalBytes(); method public int getMaxTransceiveLength(); method public void setTimeout(int); method public void setTimeout(int); method public byte[] transceive(byte[]) throws java.io.IOException; method public byte[] transceive(byte[]) throws java.io.IOException; } } Loading @@ -12477,6 +12478,7 @@ package android.nfc.tech { method public static android.nfc.tech.MifareClassic get(android.nfc.Tag); method public static android.nfc.tech.MifareClassic get(android.nfc.Tag); method public int getBlockCount(); method public int getBlockCount(); method public int getBlockCountInSector(int); method public int getBlockCountInSector(int); method public int getMaxTransceiveLength(); method public int getSectorCount(); method public int getSectorCount(); method public int getSize(); method public int getSize(); method public int getType(); method public int getType(); Loading @@ -12503,6 +12505,7 @@ package android.nfc.tech { public final class MifareUltralight extends android.nfc.tech.BasicTagTechnology { public final class MifareUltralight extends android.nfc.tech.BasicTagTechnology { method public static android.nfc.tech.MifareUltralight get(android.nfc.Tag); method public static android.nfc.tech.MifareUltralight get(android.nfc.Tag); method public int getMaxTransceiveLength(); method public int getType(); method public int getType(); method public byte[] readPages(int) throws java.io.IOException; method public byte[] readPages(int) throws java.io.IOException; method public byte[] transceive(byte[]) throws java.io.IOException; method public byte[] transceive(byte[]) throws java.io.IOException; Loading Loading @@ -12539,6 +12542,7 @@ package android.nfc.tech { public final class NfcA extends android.nfc.tech.BasicTagTechnology { public final class NfcA extends android.nfc.tech.BasicTagTechnology { method public static android.nfc.tech.NfcA get(android.nfc.Tag); method public static android.nfc.tech.NfcA get(android.nfc.Tag); method public byte[] getAtqa(); method public byte[] getAtqa(); method public int getMaxTransceiveLength(); method public short getSak(); method public short getSak(); method public byte[] transceive(byte[]) throws java.io.IOException; method public byte[] transceive(byte[]) throws java.io.IOException; } } Loading @@ -12546,6 +12550,7 @@ package android.nfc.tech { public final class NfcB extends android.nfc.tech.BasicTagTechnology { public final class NfcB extends android.nfc.tech.BasicTagTechnology { method public static android.nfc.tech.NfcB get(android.nfc.Tag); method public static android.nfc.tech.NfcB get(android.nfc.Tag); method public byte[] getApplicationData(); method public byte[] getApplicationData(); method public int getMaxTransceiveLength(); method public byte[] getProtocolInfo(); method public byte[] getProtocolInfo(); method public byte[] transceive(byte[]) throws java.io.IOException; method public byte[] transceive(byte[]) throws java.io.IOException; } } Loading @@ -12553,6 +12558,7 @@ package android.nfc.tech { public final class NfcF extends android.nfc.tech.BasicTagTechnology { public final class NfcF extends android.nfc.tech.BasicTagTechnology { method public static android.nfc.tech.NfcF get(android.nfc.Tag); method public static android.nfc.tech.NfcF get(android.nfc.Tag); method public byte[] getManufacturer(); method public byte[] getManufacturer(); method public int getMaxTransceiveLength(); method public byte[] getSystemCode(); method public byte[] getSystemCode(); method public byte[] transceive(byte[]) throws java.io.IOException; method public byte[] transceive(byte[]) throws java.io.IOException; } } Loading @@ -12560,6 +12566,7 @@ package android.nfc.tech { public final class NfcV extends android.nfc.tech.BasicTagTechnology { public final class NfcV extends android.nfc.tech.BasicTagTechnology { method public static android.nfc.tech.NfcV get(android.nfc.Tag); method public static android.nfc.tech.NfcV get(android.nfc.Tag); method public byte getDsfId(); method public byte getDsfId(); method public int getMaxTransceiveLength(); method public byte getResponseFlags(); method public byte getResponseFlags(); method public byte[] transceive(byte[]) throws java.io.IOException; method public byte[] transceive(byte[]) throws java.io.IOException; } }
core/java/android/nfc/INfcTag.aidl +2 −0 Original line number Original line Diff line number Diff line Loading @@ -46,4 +46,6 @@ interface INfcTag int setTimeout(int technology, int timeout); int setTimeout(int technology, int timeout); int getTimeout(int technology); int getTimeout(int technology); void resetTimeouts(); void resetTimeouts(); boolean canMakeReadOnly(int ndefType); int getMaxTransceiveLength(int technology); } }
core/java/android/nfc/TransceiveResult.java +27 −24 Original line number Original line Diff line number Diff line Loading @@ -19,33 +19,38 @@ package android.nfc; import android.os.Parcel; import android.os.Parcel; import android.os.Parcelable; import android.os.Parcelable; import java.io.IOException; /** /** * Class used to pipe transceive result from the NFC service. * Class used to pipe transceive result from the NFC service. * * * @hide * @hide */ */ public final class TransceiveResult implements Parcelable { public final class TransceiveResult implements Parcelable { private final boolean mTagLost; public static final int RESULT_SUCCESS = 0; private final boolean mSuccess; public static final int RESULT_FAILURE = 1; private final byte[] mResponseData; public static final int RESULT_TAGLOST = 2; public static final int RESULT_EXCEEDED_LENGTH = 3; public TransceiveResult(final boolean success, final boolean tagIsLost, final int mResult; final byte[] data) { final byte[] mResponseData; mSuccess = success; mTagLost = tagIsLost; mResponseData = data; } public boolean isSuccessful() { public TransceiveResult(final int result, final byte[] data) { return mSuccess; mResult = result; } mResponseData = data; public boolean isTagLost() { return mTagLost; } } public byte[] getResponseData() { public byte[] getResponseOrThrow() throws IOException { switch (mResult) { case RESULT_SUCCESS: return mResponseData; return mResponseData; case RESULT_TAGLOST: throw new TagLostException("Tag was lost."); case RESULT_EXCEEDED_LENGTH: throw new IOException("Transceive length exceeds supported maximum"); default: throw new IOException("Transceive failed"); } } } @Override @Override Loading @@ -55,9 +60,8 @@ public final class TransceiveResult implements Parcelable { @Override @Override public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) { dest.writeInt(mSuccess ? 1 : 0); dest.writeInt(mResult); dest.writeInt(mTagLost ? 1 : 0); if (mResult == RESULT_SUCCESS) { if (mSuccess) { dest.writeInt(mResponseData.length); dest.writeInt(mResponseData.length); dest.writeByteArray(mResponseData); dest.writeByteArray(mResponseData); } } Loading @@ -67,18 +71,17 @@ public final class TransceiveResult implements Parcelable { new Parcelable.Creator<TransceiveResult>() { new Parcelable.Creator<TransceiveResult>() { @Override @Override public TransceiveResult createFromParcel(Parcel in) { public TransceiveResult createFromParcel(Parcel in) { boolean success = (in.readInt() == 1) ? true : false; int result = in.readInt(); boolean tagLost = (in.readInt() == 1) ? true : false; byte[] responseData; byte[] responseData; if (success) { if (result == RESULT_SUCCESS) { int responseLength = in.readInt(); int responseLength = in.readInt(); responseData = new byte[responseLength]; responseData = new byte[responseLength]; in.readByteArray(responseData); in.readByteArray(responseData); } else { } else { responseData = null; responseData = null; } } return new TransceiveResult(success, tagLost, responseData); return new TransceiveResult(result, responseData); } } @Override @Override Loading
core/java/android/nfc/tech/BasicTagTechnology.java +10 −10 Original line number Original line Diff line number Diff line Loading @@ -129,6 +129,15 @@ import java.io.IOException; } } } } /** Internal getMaxTransceiveLength() */ int getMaxTransceiveLengthInternal() { try { return mTag.getTagService().getMaxTransceiveLength(mSelectedTechnology); } catch (RemoteException e) { Log.e(TAG, "NFC service dead", e); return 0; } } /** Internal transceive */ /** Internal transceive */ /*package*/ byte[] transceive(byte[] data, boolean raw) throws IOException { /*package*/ byte[] transceive(byte[] data, boolean raw) throws IOException { checkConnected(); checkConnected(); Loading @@ -139,16 +148,7 @@ import java.io.IOException; if (result == null) { if (result == null) { throw new IOException("transceive failed"); throw new IOException("transceive failed"); } else { } else { if (result.isSuccessful()) { return result.getResponseOrThrow(); return result.getResponseData(); } else { if (result.isTagLost()) { throw new TagLostException("Tag was lost."); } else { throw new IOException("transceive failed"); } } } } } catch (RemoteException e) { } catch (RemoteException e) { Log.e(TAG, "NFC service dead", e); Log.e(TAG, "NFC service dead", e); Loading
core/java/android/nfc/tech/IsoDep.java +11 −0 Original line number Original line Diff line number Diff line Loading @@ -156,6 +156,9 @@ public final class IsoDep extends BasicTagTechnology { * will be automatically fragmented and defragmented by {@link #transceive} if * will be automatically fragmented and defragmented by {@link #transceive} if * it exceeds FSD/FSC limits. * it exceeds FSD/FSC limits. * * * <p>Use {@link #getMaxTransceiveLength} to retrieve the maximum number of bytes * that can be sent with {@link #transceive}. * * <p>This is an I/O operation and will block until complete. It must * <p>This is an I/O operation and will block until complete. It must * not be called from the main application thread. A blocked call will be canceled with * not be called from the main application thread. A blocked call will be canceled with * {@link IOException} if {@link #close} is called from another thread. * {@link IOException} if {@link #close} is called from another thread. Loading @@ -170,4 +173,12 @@ public final class IsoDep extends BasicTagTechnology { public byte[] transceive(byte[] data) throws IOException { public byte[] transceive(byte[] data) throws IOException { return transceive(data, true); return transceive(data, true); } } /** * Return the maximum number of bytes that can be sent with {@link #transceive}. * @return the maximum number of bytes that can be sent with {@link #transceive}. */ public int getMaxTransceiveLength() { return getMaxTransceiveLengthInternal(); } } }