diff options
author | Martijn Coenen <maco@google.com> | 2011-06-06 17:06:54 +0200 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2011-06-08 20:00:02 +0200 |
commit | a924973f22aedc580708625e4babb6deabc6b4d3 (patch) | |
tree | e2ce7978e1bcb997d4b98a54fc756cfee2edf976 /core/java/android/nfc/tech | |
parent | 7f86827af44eb5267c8d21f355d109ff71b04f10 (diff) | |
download | frameworks_base-a924973f22aedc580708625e4babb6deabc6b4d3.zip frameworks_base-a924973f22aedc580708625e4babb6deabc6b4d3.tar.gz frameworks_base-a924973f22aedc580708625e4babb6deabc6b4d3.tar.bz2 |
Implement Felica timeout handling (API).
Allows controlling the timeout for transceive on Felica.
Change-Id: I5c62b3ea0e8a16bc006feac6ec759cdb730bc938
Diffstat (limited to 'core/java/android/nfc/tech')
-rw-r--r-- | core/java/android/nfc/tech/BasicTagTechnology.java | 1 | ||||
-rw-r--r-- | core/java/android/nfc/tech/IsoDep.java | 10 | ||||
-rw-r--r-- | core/java/android/nfc/tech/NfcF.java | 25 |
3 files changed, 26 insertions, 10 deletions
diff --git a/core/java/android/nfc/tech/BasicTagTechnology.java b/core/java/android/nfc/tech/BasicTagTechnology.java index 6557ee0..bcb7199 100644 --- a/core/java/android/nfc/tech/BasicTagTechnology.java +++ b/core/java/android/nfc/tech/BasicTagTechnology.java @@ -119,6 +119,7 @@ import java.io.IOException; /* Note that we don't want to physically disconnect the tag, * but just reconnect to it to reset its state */ + mTag.getTagService().resetTimeouts(); mTag.getTagService().reconnect(mTag.getServiceHandle()); } catch (RemoteException e) { Log.e(TAG, "NFC service dead", e); diff --git a/core/java/android/nfc/tech/IsoDep.java b/core/java/android/nfc/tech/IsoDep.java index 9c3074b..38b2bbd 100644 --- a/core/java/android/nfc/tech/IsoDep.java +++ b/core/java/android/nfc/tech/IsoDep.java @@ -96,16 +96,6 @@ public final class IsoDep extends BasicTagTechnology { } } - @Override - public void close() throws IOException { - try { - mTag.getTagService().resetIsoDepTimeout(); - } catch (RemoteException e) { - Log.e(TAG, "NFC service dead", e); - } - super.close(); - } - /** * Return the ISO-DEP historical bytes for {@link NfcA} tags. * <p>Does not cause any RF activity and does not block. diff --git a/core/java/android/nfc/tech/NfcF.java b/core/java/android/nfc/tech/NfcF.java index e0ebbe8..250c9b3 100644 --- a/core/java/android/nfc/tech/NfcF.java +++ b/core/java/android/nfc/tech/NfcF.java @@ -19,6 +19,7 @@ package android.nfc.tech; import android.nfc.Tag; import android.os.Bundle; import android.os.RemoteException; +import android.util.Log; import java.io.IOException; @@ -33,6 +34,8 @@ import java.io.IOException; * require the {@link android.Manifest.permission#NFC} permission. */ public final class NfcF extends BasicTagTechnology { + private static final String TAG = "NFC"; + /** @hide */ public static final String EXTRA_SC = "systemcode"; /** @hide */ @@ -111,4 +114,26 @@ public final class NfcF extends BasicTagTechnology { public byte[] transceive(byte[] data) throws IOException { return transceive(data, true); } + + /** + * 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. + * <p>Setting a longer timeout may be useful when performing + * transactions that require a long processing time on the tag + * such as key generation. + * + * <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 { + mTag.getTagService().setFelicaTimeout(timeout); + } catch (RemoteException e) { + Log.e(TAG, "NFC service dead", e); + } + } } |