Merge "Support for getTimeout() (API)."

This commit is contained in:
Martijn Coenen
2011-07-21 00:32:11 -07:00
committed by Android (Google) Code Review
6 changed files with 91 additions and 0 deletions

View File

@@ -44,5 +44,6 @@ interface INfcTag
Tag rediscover(int nativehandle);
int setTimeout(int technology, int timeout);
int getTimeout(int technology);
void resetTimeouts();
}

View File

@@ -100,6 +100,24 @@ public final class IsoDep extends BasicTagTechnology {
}
}
/**
* Gets the currently set timeout of {@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);
} catch (RemoteException e) {
Log.e(TAG, "NFC service dead", e);
return 0;
}
}
/**
* Return the ISO-DEP historical bytes for {@link NfcA} tags.
* <p>Does not cause any RF activity and does not block.

View File

@@ -597,6 +597,24 @@ public final class MifareClassic extends BasicTagTechnology {
}
}
/**
* Gets the currently set timeout of {@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.MIFARE_CLASSIC);
} catch (RemoteException e) {
Log.e(TAG, "NFC service dead", e);
return 0;
}
}
private static void validateSector(int sector) {
// Do not be too strict on upper bounds checking, since some cards
// have more addressable memory than they report. For example,

View File

@@ -238,6 +238,24 @@ public final class MifareUltralight extends BasicTagTechnology {
}
}
/**
* Gets the currently set timeout of {@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.MIFARE_ULTRALIGHT);
} catch (RemoteException e) {
Log.e(TAG, "NFC service dead", e);
return 0;
}
}
private static void validatePageIndex(int pageIndex) {
// Do not be too strict on upper bounds checking, since some cards
// may have more addressable memory than they report.

View File

@@ -141,4 +141,22 @@ public final class NfcA extends BasicTagTechnology {
Log.e(TAG, "NFC service dead", e);
}
}
/**
* Gets the currently set timeout of {@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.NFC_A);
} catch (RemoteException e) {
Log.e(TAG, "NFC service dead", e);
return 0;
}
}
}

View File

@@ -140,4 +140,22 @@ public final class NfcF extends BasicTagTechnology {
Log.e(TAG, "NFC service dead", e);
}
}
/**
* Gets the currently set timeout of {@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.NFC_F);
} catch (RemoteException e) {
Log.e(TAG, "NFC service dead", e);
return 0;
}
}
}