am 46848574: Merge "NFC API updates."
* commit '468485747970d9842d94e1d292fe4cced701cad2': NFC API updates.
This commit is contained in:
@@ -12411,6 +12411,7 @@ package android.nfc {
|
||||
public final class NdefRecord implements android.os.Parcelable {
|
||||
ctor public NdefRecord(short, byte[], byte[], byte[]);
|
||||
ctor public NdefRecord(byte[]) throws android.nfc.FormatException;
|
||||
method public static android.nfc.NdefRecord createApplicationRecord(java.lang.String);
|
||||
method public static android.nfc.NdefRecord createUri(android.net.Uri);
|
||||
method public static android.nfc.NdefRecord createUri(java.lang.String);
|
||||
method public int describeContents();
|
||||
@@ -12445,9 +12446,9 @@ package android.nfc {
|
||||
method public static android.nfc.NfcAdapter getDefaultAdapter(android.content.Context);
|
||||
method public static deprecated android.nfc.NfcAdapter getDefaultAdapter();
|
||||
method public boolean isEnabled();
|
||||
method public void setNdefPushMessage(android.nfc.NdefMessage, android.app.Activity...);
|
||||
method public void setNdefPushMessageCallback(android.nfc.NfcAdapter.CreateNdefMessageCallback, android.app.Activity...);
|
||||
method public void setOnNdefPushCompleteCallback(android.nfc.NfcAdapter.OnNdefPushCompleteCallback, android.app.Activity...);
|
||||
method public void setNdefPushMessage(android.nfc.NdefMessage, android.app.Activity, android.app.Activity...);
|
||||
method public void setNdefPushMessageCallback(android.nfc.NfcAdapter.CreateNdefMessageCallback, android.app.Activity, android.app.Activity...);
|
||||
method public void setOnNdefPushCompleteCallback(android.nfc.NfcAdapter.OnNdefPushCompleteCallback, android.app.Activity, android.app.Activity...);
|
||||
field public static final java.lang.String ACTION_NDEF_DISCOVERED = "android.nfc.action.NDEF_DISCOVERED";
|
||||
field public static final java.lang.String ACTION_TAG_DISCOVERED = "android.nfc.action.TAG_DISCOVERED";
|
||||
field public static final java.lang.String ACTION_TECH_DISCOVERED = "android.nfc.action.TECH_DISCOVERED";
|
||||
@@ -12501,6 +12502,7 @@ package android.nfc.tech {
|
||||
method public byte[] getHiLayerResponse();
|
||||
method public byte[] getHistoricalBytes();
|
||||
method public int getMaxTransceiveLength();
|
||||
method public int getTimeout();
|
||||
method public void setTimeout(int);
|
||||
method public byte[] transceive(byte[]) throws java.io.IOException;
|
||||
}
|
||||
@@ -12516,11 +12518,13 @@ package android.nfc.tech {
|
||||
method public int getMaxTransceiveLength();
|
||||
method public int getSectorCount();
|
||||
method public int getSize();
|
||||
method public int getTimeout();
|
||||
method public int getType();
|
||||
method public void increment(int, int) throws java.io.IOException;
|
||||
method public byte[] readBlock(int) throws java.io.IOException;
|
||||
method public void restore(int) throws java.io.IOException;
|
||||
method public int sectorToBlock(int);
|
||||
method public void setTimeout(int);
|
||||
method public byte[] transceive(byte[]) throws java.io.IOException;
|
||||
method public void transfer(int) throws java.io.IOException;
|
||||
method public void writeBlock(int, byte[]) throws java.io.IOException;
|
||||
@@ -12541,8 +12545,10 @@ package android.nfc.tech {
|
||||
public final class MifareUltralight extends android.nfc.tech.BasicTagTechnology {
|
||||
method public static android.nfc.tech.MifareUltralight get(android.nfc.Tag);
|
||||
method public int getMaxTransceiveLength();
|
||||
method public int getTimeout();
|
||||
method public int getType();
|
||||
method public byte[] readPages(int) throws java.io.IOException;
|
||||
method public void setTimeout(int);
|
||||
method public byte[] transceive(byte[]) throws java.io.IOException;
|
||||
method public void writePage(int, byte[]) throws java.io.IOException;
|
||||
field public static final int PAGE_SIZE = 4; // 0x4
|
||||
@@ -12579,6 +12585,8 @@ package android.nfc.tech {
|
||||
method public byte[] getAtqa();
|
||||
method public int getMaxTransceiveLength();
|
||||
method public short getSak();
|
||||
method public int getTimeout();
|
||||
method public void setTimeout(int);
|
||||
method public byte[] transceive(byte[]) throws java.io.IOException;
|
||||
}
|
||||
|
||||
@@ -12595,6 +12603,8 @@ package android.nfc.tech {
|
||||
method public byte[] getManufacturer();
|
||||
method public int getMaxTransceiveLength();
|
||||
method public byte[] getSystemCode();
|
||||
method public int getTimeout();
|
||||
method public void setTimeout(int);
|
||||
method public byte[] transceive(byte[]) throws java.io.IOException;
|
||||
}
|
||||
|
||||
|
||||
@@ -152,8 +152,6 @@ public final class NdefRecord implements Parcelable {
|
||||
* RTD_ANDROID_APP records.
|
||||
* @hide
|
||||
*/
|
||||
// TODO unhide for ICS
|
||||
// TODO recheck docs
|
||||
public static final byte[] RTD_ANDROID_APP = "android.com:pkg".getBytes();
|
||||
|
||||
private static final byte FLAG_MB = (byte) 0x80;
|
||||
@@ -352,21 +350,29 @@ public final class NdefRecord implements Parcelable {
|
||||
/**
|
||||
* Creates an Android application NDEF record.
|
||||
* <p>
|
||||
* This record indicates to other Android devices the package
|
||||
* that should be used to handle the rest of the NDEF message.
|
||||
* You can embed this record anywhere into your NDEF message
|
||||
* to ensure that the intended package receives the message.
|
||||
* <p>
|
||||
* When an Android device dispatches an {@link NdefMessage}
|
||||
* containing one or more Android application records,
|
||||
* the applications contained in those records will be the
|
||||
* preferred target for the NDEF_DISCOVERED intent, in
|
||||
* the order in which they appear in the {@link NdefMessage}.
|
||||
* This dispatch behavior was first added to Android in
|
||||
* Ice Cream Sandwich.
|
||||
* <p>
|
||||
* If none of the applications are installed on the device,
|
||||
* a Market link will be opened to the first application.
|
||||
* <p>
|
||||
* Note that Android application records do not overrule
|
||||
* applications that have called {@link NfcAdapter#enableForegroundDispatch}.
|
||||
* @hide
|
||||
* applications that have called
|
||||
* {@link NfcAdapter#enableForegroundDispatch}.
|
||||
*
|
||||
* @param packageName Android package name
|
||||
* @return Android application NDEF record
|
||||
*/
|
||||
// TODO unhide for ICS
|
||||
// TODO recheck javadoc - should mention this works from ICS only
|
||||
public static NdefRecord createApplicationRecord(String packageName) {
|
||||
return new NdefRecord(TNF_EXTERNAL_TYPE, RTD_ANDROID_APP, new byte[] {},
|
||||
packageName.getBytes(Charsets.US_ASCII));
|
||||
|
||||
@@ -507,16 +507,24 @@ public final class NfcAdapter {
|
||||
* <p>Pass a null NDEF message to disable foreground NDEF push in the
|
||||
* specified activities.
|
||||
*
|
||||
* <p>One or more activities must be specified.
|
||||
*
|
||||
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
|
||||
*
|
||||
* @param message NDEF message to push over NFC, or null to disable
|
||||
* @param activities one or more {@link Activity} to enable for NDEF push
|
||||
* @param activity an activity to enable for NDEF push (at least one is required)
|
||||
* @param activities zero or more additional activities to enable for NDEF Push
|
||||
*/
|
||||
public void setNdefPushMessage(NdefMessage message, Activity ... activities) {
|
||||
if (activities.length == 0) {
|
||||
throw new NullPointerException("Must specificy one or more activities");
|
||||
public void setNdefPushMessage(NdefMessage message, Activity activity,
|
||||
Activity ... activities) {
|
||||
if (activity == null) {
|
||||
throw new NullPointerException("activity cannot be null");
|
||||
}
|
||||
mNfcActivityManager.setNdefPushMessage(activity, message);
|
||||
for (Activity a : activities) {
|
||||
if (a == null) {
|
||||
throw new NullPointerException("activities cannot contain null");
|
||||
}
|
||||
mNfcActivityManager.setNdefPushMessage(a, message);
|
||||
}
|
||||
}
|
||||
@@ -536,17 +544,24 @@ public final class NfcAdapter {
|
||||
* <p>Pass a null callback to disable the callback in the
|
||||
* specified activities.
|
||||
*
|
||||
* <p>One or more activities must be specified.
|
||||
*
|
||||
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
|
||||
*
|
||||
* @param callback callback, or null to disable
|
||||
* @param activities one or more {@link Activity} to enable for NDEF push
|
||||
* @param activity an activity to enable for NDEF push (at least one is required)
|
||||
* @param activities zero or more additional activities to enable for NDEF Push
|
||||
*/
|
||||
public void setNdefPushMessageCallback(CreateNdefMessageCallback callback,
|
||||
public void setNdefPushMessageCallback(CreateNdefMessageCallback callback, Activity activity,
|
||||
Activity ... activities) {
|
||||
if (activities.length == 0) {
|
||||
throw new NullPointerException("Must specificy one or more activities");
|
||||
if (activity == null) {
|
||||
throw new NullPointerException("activity cannot be null");
|
||||
}
|
||||
mNfcActivityManager.setNdefPushMessageCallback(activity, callback);
|
||||
for (Activity a : activities) {
|
||||
if (a == null) {
|
||||
throw new NullPointerException("activities cannot contain null");
|
||||
}
|
||||
mNfcActivityManager.setNdefPushMessageCallback(a, callback);
|
||||
}
|
||||
}
|
||||
@@ -558,17 +573,24 @@ public final class NfcAdapter {
|
||||
* can only occur when one of the specified activities is in resumed
|
||||
* (foreground) state.
|
||||
*
|
||||
* <p>One or more activities must be specified.
|
||||
*
|
||||
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
|
||||
*
|
||||
* @param callback callback, or null to disable
|
||||
* @param activities one or more {@link Activity} to enable the callback
|
||||
* @param activity an activity to enable the callback (at least one is required)
|
||||
* @param activities zero or more additional activities to enable to callback
|
||||
*/
|
||||
public void setOnNdefPushCompleteCallback(OnNdefPushCompleteCallback callback,
|
||||
Activity ... activities) {
|
||||
if (activities.length == 0) {
|
||||
throw new NullPointerException("Must specificy one or more activities");
|
||||
Activity activity, Activity ... activities) {
|
||||
if (activity == null) {
|
||||
throw new NullPointerException("activity cannot be null");
|
||||
}
|
||||
mNfcActivityManager.setOnNdefPushCompleteCallback(activity, callback);
|
||||
for (Activity a : activities) {
|
||||
if (a == null) {
|
||||
throw new NullPointerException("activities cannot contain null");
|
||||
}
|
||||
mNfcActivityManager.setOnNdefPushCompleteCallback(a, callback);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,14 +101,12 @@ public final class IsoDep extends BasicTagTechnology {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the currently set timeout of {@link #transceive} in milliseconds.
|
||||
* Get the current timeout for {@link #transceive} in milliseconds.
|
||||
*
|
||||
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
|
||||
*
|
||||
* @return timeout value in milliseconds
|
||||
* @hide
|
||||
*/
|
||||
// TODO Unhide for ICS
|
||||
public int getTimeout() {
|
||||
try {
|
||||
return mTag.getTagService().getTimeout(TagTechnology.ISO_DEP);
|
||||
|
||||
@@ -584,9 +584,11 @@ public final class MifareClassic extends BasicTagTechnology {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the timeout of {@link #transceive} in milliseconds.
|
||||
* <p>The timeout only applies to MifareUltralight {@link #transceive},
|
||||
* Set the {@link #transceive} timeout in milliseconds.
|
||||
*
|
||||
* <p>The timeout only applies to {@link #transceive} on this object,
|
||||
* and is reset to a default value when {@link #close} is called.
|
||||
*
|
||||
* <p>Setting a longer timeout may be useful when performing
|
||||
* transactions that require a long processing time on the tag
|
||||
* such as key generation.
|
||||
@@ -594,9 +596,7 @@ public final class MifareClassic extends BasicTagTechnology {
|
||||
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
|
||||
*
|
||||
* @param timeout timeout value in milliseconds
|
||||
* @hide
|
||||
*/
|
||||
// TODO Unhide for ICS
|
||||
public void setTimeout(int timeout) {
|
||||
try {
|
||||
int err = mTag.getTagService().setTimeout(TagTechnology.MIFARE_CLASSIC, timeout);
|
||||
@@ -609,14 +609,12 @@ public final class MifareClassic extends BasicTagTechnology {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the currently set timeout of {@link #transceive} in milliseconds.
|
||||
* Get the current {@link #transceive} timeout in milliseconds.
|
||||
*
|
||||
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
|
||||
*
|
||||
* @return timeout value in milliseconds
|
||||
* @hide
|
||||
*/
|
||||
// TODO Unhide for ICS
|
||||
public int getTimeout() {
|
||||
try {
|
||||
return mTag.getTagService().getTimeout(TagTechnology.MIFARE_CLASSIC);
|
||||
|
||||
@@ -224,9 +224,11 @@ public final class MifareUltralight extends BasicTagTechnology {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the timeout of {@link #transceive} in milliseconds.
|
||||
* <p>The timeout only applies to MifareUltralight {@link #transceive},
|
||||
* Set the {@link #transceive} timeout in milliseconds.
|
||||
*
|
||||
* <p>The timeout only applies to {@link #transceive} on this object,
|
||||
* and is reset to a default value when {@link #close} is called.
|
||||
*
|
||||
* <p>Setting a longer timeout may be useful when performing
|
||||
* transactions that require a long processing time on the tag
|
||||
* such as key generation.
|
||||
@@ -234,9 +236,7 @@ public final class MifareUltralight extends BasicTagTechnology {
|
||||
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
|
||||
*
|
||||
* @param timeout timeout value in milliseconds
|
||||
* @hide
|
||||
*/
|
||||
// TODO Unhide for ICS
|
||||
public void setTimeout(int timeout) {
|
||||
try {
|
||||
int err = mTag.getTagService().setTimeout(
|
||||
@@ -250,14 +250,12 @@ public final class MifareUltralight extends BasicTagTechnology {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the currently set timeout of {@link #transceive} in milliseconds.
|
||||
* Get the current {@link #transceive} timeout in milliseconds.
|
||||
*
|
||||
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
|
||||
*
|
||||
* @return timeout value in milliseconds
|
||||
* @hide
|
||||
*/
|
||||
// TODO Unhide for ICS
|
||||
public int getTimeout() {
|
||||
try {
|
||||
return mTag.getTagService().getTimeout(TagTechnology.MIFARE_ULTRALIGHT);
|
||||
|
||||
@@ -129,9 +129,11 @@ public final class NfcA extends BasicTagTechnology {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the timeout of {@link #transceive} in milliseconds.
|
||||
* <p>The timeout only applies to NfcA {@link #transceive}, and is
|
||||
* reset to a default value when {@link #close} is called.
|
||||
* Set the {@link #transceive} timeout in milliseconds.
|
||||
*
|
||||
* <p>The timeout only applies to {@link #transceive} on this object,
|
||||
* and is reset to a default value when {@link #close} is called.
|
||||
*
|
||||
* <p>Setting a longer timeout may be useful when performing
|
||||
* transactions that require a long processing time on the tag
|
||||
* such as key generation.
|
||||
@@ -139,9 +141,7 @@ public final class NfcA extends BasicTagTechnology {
|
||||
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
|
||||
*
|
||||
* @param timeout timeout value in milliseconds
|
||||
* @hide
|
||||
*/
|
||||
// TODO Unhide for ICS
|
||||
public void setTimeout(int timeout) {
|
||||
try {
|
||||
int err = mTag.getTagService().setTimeout(TagTechnology.NFC_A, timeout);
|
||||
@@ -154,14 +154,12 @@ public final class NfcA extends BasicTagTechnology {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the currently set timeout of {@link #transceive} in milliseconds.
|
||||
* Get the current {@link #transceive} timeout in milliseconds.
|
||||
*
|
||||
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
|
||||
*
|
||||
* @return timeout value in milliseconds
|
||||
* @hide
|
||||
*/
|
||||
// TODO Unhide for ICS
|
||||
public int getTimeout() {
|
||||
try {
|
||||
return mTag.getTagService().getTimeout(TagTechnology.NFC_A);
|
||||
|
||||
@@ -128,9 +128,11 @@ public final class NfcF extends BasicTagTechnology {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the timeout of {@link #transceive} in milliseconds.
|
||||
* <p>The timeout only applies to NfcF {@link #transceive}, and is
|
||||
* reset to a default value when {@link #close} is called.
|
||||
* Set the {@link #transceive} timeout in milliseconds.
|
||||
*
|
||||
* <p>The timeout only applies to {@link #transceive} on this object,
|
||||
* and is reset to a default value when {@link #close} is called.
|
||||
*
|
||||
* <p>Setting a longer timeout may be useful when performing
|
||||
* transactions that require a long processing time on the tag
|
||||
* such as key generation.
|
||||
@@ -138,9 +140,7 @@ public final class NfcF extends BasicTagTechnology {
|
||||
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
|
||||
*
|
||||
* @param timeout timeout value in milliseconds
|
||||
* @hide
|
||||
*/
|
||||
// TODO Unhide for ICS
|
||||
public void setTimeout(int timeout) {
|
||||
try {
|
||||
int err = mTag.getTagService().setTimeout(TagTechnology.NFC_F, timeout);
|
||||
@@ -153,14 +153,12 @@ public final class NfcF extends BasicTagTechnology {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the currently set timeout of {@link #transceive} in milliseconds.
|
||||
* Get the current {@link #transceive} timeout in milliseconds.
|
||||
*
|
||||
* <p class="note">Requires the {@link android.Manifest.permission#NFC} permission.
|
||||
*
|
||||
* @return timeout value in milliseconds
|
||||
* @hide
|
||||
*/
|
||||
// TODO Unhide for ICS
|
||||
public int getTimeout() {
|
||||
try {
|
||||
return mTag.getTagService().getTimeout(TagTechnology.NFC_F);
|
||||
|
||||
Reference in New Issue
Block a user