From 20e62c9f1466ace5771e244f03a995dc0939b11b Mon Sep 17 00:00:00 2001 From: Martijn Coenen Date: Wed, 20 Jul 2011 16:06:34 +0200 Subject: Support for getTimeout() (API). Bug: 4492175 Change-Id: Ibc9a1b78d8c0992f47664d33760e0ce8dca67c64 --- core/java/android/nfc/INfcTag.aidl | 1 + core/java/android/nfc/tech/IsoDep.java | 18 ++++++++++++++++++ core/java/android/nfc/tech/MifareClassic.java | 18 ++++++++++++++++++ core/java/android/nfc/tech/MifareUltralight.java | 18 ++++++++++++++++++ core/java/android/nfc/tech/NfcA.java | 18 ++++++++++++++++++ core/java/android/nfc/tech/NfcF.java | 18 ++++++++++++++++++ 6 files changed, 91 insertions(+) diff --git a/core/java/android/nfc/INfcTag.aidl b/core/java/android/nfc/INfcTag.aidl index aa5937ee9deb..7bdefe7b0eb7 100644 --- a/core/java/android/nfc/INfcTag.aidl +++ b/core/java/android/nfc/INfcTag.aidl @@ -44,5 +44,6 @@ interface INfcTag Tag rediscover(int nativehandle); int setTimeout(int technology, int timeout); + int getTimeout(int technology); void resetTimeouts(); } diff --git a/core/java/android/nfc/tech/IsoDep.java b/core/java/android/nfc/tech/IsoDep.java index d02086ffcf1f..0672a4eba281 100644 --- a/core/java/android/nfc/tech/IsoDep.java +++ b/core/java/android/nfc/tech/IsoDep.java @@ -100,6 +100,24 @@ public final class IsoDep extends BasicTagTechnology { } } + /** + * Gets the currently set timeout of {@link #transceive} in milliseconds. + * + *

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. *

Does not cause any RF activity and does not block. diff --git a/core/java/android/nfc/tech/MifareClassic.java b/core/java/android/nfc/tech/MifareClassic.java index 5cafe5ba6126..93e7cbddec94 100644 --- a/core/java/android/nfc/tech/MifareClassic.java +++ b/core/java/android/nfc/tech/MifareClassic.java @@ -597,6 +597,24 @@ public final class MifareClassic extends BasicTagTechnology { } } + /** + * Gets the currently set timeout of {@link #transceive} in milliseconds. + * + *

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, diff --git a/core/java/android/nfc/tech/MifareUltralight.java b/core/java/android/nfc/tech/MifareUltralight.java index 3d4cdd1a8dff..ca74ebe521c9 100644 --- a/core/java/android/nfc/tech/MifareUltralight.java +++ b/core/java/android/nfc/tech/MifareUltralight.java @@ -238,6 +238,24 @@ public final class MifareUltralight extends BasicTagTechnology { } } + /** + * Gets the currently set timeout of {@link #transceive} in milliseconds. + * + *

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. diff --git a/core/java/android/nfc/tech/NfcA.java b/core/java/android/nfc/tech/NfcA.java index 08095e6cb163..bd1f95af63ec 100644 --- a/core/java/android/nfc/tech/NfcA.java +++ b/core/java/android/nfc/tech/NfcA.java @@ -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. + * + *

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; + } + } } diff --git a/core/java/android/nfc/tech/NfcF.java b/core/java/android/nfc/tech/NfcF.java index 85abf89e6dfd..7b25a72231b9 100644 --- a/core/java/android/nfc/tech/NfcF.java +++ b/core/java/android/nfc/tech/NfcF.java @@ -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. + * + *

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; + } + } } -- cgit v1.2.3-59-g8ed1b