diff options
author | Jeff Hamilton <jham@android.com> | 2010-12-02 09:16:22 -0600 |
---|---|---|
committer | Jeff Hamilton <jham@android.com> | 2010-12-10 22:48:16 -0600 |
commit | 641dd62155fd2eeddd93b2036154b13c05b70ba2 (patch) | |
tree | f2fdd98c347ac4f8e46afbef36863efe2d7fe075 | |
parent | b79173f6602359d00a1a89f4d6505a44d461d796 (diff) | |
download | frameworks_base-641dd62155fd2eeddd93b2036154b13c05b70ba2.zip frameworks_base-641dd62155fd2eeddd93b2036154b13c05b70ba2.tar.gz frameworks_base-641dd62155fd2eeddd93b2036154b13c05b70ba2.tar.bz2 |
First pass at advanced NFC tag dispatching APIs and other cleanup.
Change-Id: I022fcd481274a2f68d93218026e77551cfae8cae
-rw-r--r-- | core/java/android/nfc/INfcTag.aidl | 8 | ||||
-rw-r--r-- | core/java/android/nfc/NfcAdapter.java | 26 | ||||
-rw-r--r-- | core/java/android/nfc/technology/Ndef.java | 7 | ||||
-rw-r--r-- | core/java/android/nfc/technology/NdefFormatable.java | 2 | ||||
-rw-r--r-- | core/java/android/nfc/technology/TagTechnology.java | 22 |
5 files changed, 40 insertions, 25 deletions
diff --git a/core/java/android/nfc/INfcTag.aidl b/core/java/android/nfc/INfcTag.aidl index 852ab5e..0f96d6b 100644 --- a/core/java/android/nfc/INfcTag.aidl +++ b/core/java/android/nfc/INfcTag.aidl @@ -34,9 +34,9 @@ interface INfcTag int getLastError(int nativeHandle); - NdefMessage read(int nativeHandle); - int write(int nativeHandle, in NdefMessage msg); - int makeReadOnly(int nativeHandle); - int getModeHint(int nativeHandle); + NdefMessage ndefRead(int nativeHandle); + int ndefWrite(int nativeHandle, in NdefMessage msg); + int ndefMakeReadOnly(int nativeHandle); + boolean ndefIsWritable(int nativeHandle); int formatNdef(int nativeHandle, in byte[] key); } diff --git a/core/java/android/nfc/NfcAdapter.java b/core/java/android/nfc/NfcAdapter.java index d71fdd5..758c8a0 100644 --- a/core/java/android/nfc/NfcAdapter.java +++ b/core/java/android/nfc/NfcAdapter.java @@ -37,6 +37,32 @@ public final class NfcAdapter { private static final String TAG = "NFC"; /** + * Intent to start an activity when a tag with NDEF payload is discovered. + * If the tag has and NDEF payload this intent is started before + * {@link #ACTION_TECHNOLOGY_DISCOVERED}. + * + * If any activities respond to this intent neither + * {@link #ACTION_TECHNOLOGY_DISCOVERED} or {@link #ACTION_TAG_DISCOVERED} will be started. + * @hide + */ + @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) + public static final String ACTION_NDEF_DISCOVERED = "android.nfc.action.NDEF_DISCOVERED"; + + /** + * Intent to started when a tag is discovered. The data URI is formated as + * {@code vnd.android.nfc://tag/} with the path having a directory entry for each technology + * in the {@link Tag#getTechnologyList()} is ascending order. + * + * This intent is started after {@link #ACTION_NDEF_DISCOVERED} and before + * {@link #ACTION_TAG_DISCOVERED} + * + * If any activities respond to this intent {@link #ACTION_TAG_DISCOVERED} will not be started. + * @hide + */ + @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) + public static final String ACTION_TECHNOLOGY_DISCOVERED = "android.nfc.action.TECH_DISCOVERED"; + + /** * Intent to start an activity when a tag is discovered. */ @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) diff --git a/core/java/android/nfc/technology/Ndef.java b/core/java/android/nfc/technology/Ndef.java index e76a573..aa3f04b 100644 --- a/core/java/android/nfc/technology/Ndef.java +++ b/core/java/android/nfc/technology/Ndef.java @@ -79,7 +79,7 @@ public final class Ndef extends BasicTagTechnology { public NdefMessage getNdefMessage() throws IOException, FormatException { try { int serviceHandle = mTag.getServiceHandle(); - NdefMessage msg = mTagService.read(serviceHandle); + NdefMessage msg = mTagService.ndefRead(serviceHandle); if (msg == null) { int errorCode = mTagService.getLastError(serviceHandle); switch (errorCode) { @@ -119,7 +119,6 @@ public final class Ndef extends BasicTagTechnology { * Provides a hint on whether writes are likely to succeed. * <p>Requires {@link android.Manifest.permission#NFC} permission. * @return true if write is likely to succeed - * @throws IOException if the target is lost or connection closed */ public boolean isWritable() { return (mCardState == NDEF_MODE_READ_WRITE); @@ -132,7 +131,7 @@ public final class Ndef extends BasicTagTechnology { */ public void writeNdefMessage(NdefMessage msg) throws IOException, FormatException { try { - int errorCode = mTagService.write(mTag.getServiceHandle(), msg); + int errorCode = mTagService.ndefWrite(mTag.getServiceHandle(), msg); switch (errorCode) { case ErrorCodes.SUCCESS: break; @@ -169,7 +168,7 @@ public final class Ndef extends BasicTagTechnology { */ public boolean makeReadonly() throws IOException { try { - int errorCode = mTagService.makeReadOnly(mTag.getServiceHandle()); + int errorCode = mTagService.ndefMakeReadOnly(mTag.getServiceHandle()); switch (errorCode) { case ErrorCodes.SUCCESS: return true; diff --git a/core/java/android/nfc/technology/NdefFormatable.java b/core/java/android/nfc/technology/NdefFormatable.java index 8744876..05fd67c 100644 --- a/core/java/android/nfc/technology/NdefFormatable.java +++ b/core/java/android/nfc/technology/NdefFormatable.java @@ -73,7 +73,7 @@ public final class NdefFormatable extends BasicTagTechnology { // Should not happen throw new IOException(); } - errorCode = mTagService.write(serviceHandle, firstMessage); + errorCode = mTagService.ndefWrite(serviceHandle, firstMessage); switch (errorCode) { case ErrorCodes.SUCCESS: break; diff --git a/core/java/android/nfc/technology/TagTechnology.java b/core/java/android/nfc/technology/TagTechnology.java index 4704f2b..bef1cc4 100644 --- a/core/java/android/nfc/technology/TagTechnology.java +++ b/core/java/android/nfc/technology/TagTechnology.java @@ -39,42 +39,32 @@ public interface TagTechnology { /** * This object is an instance of {@link NfcF} */ - public static final int NFC_F = 11; + public static final int NFC_F = 4; /** * This object is an instance of {@link NfcV} */ - public static final int NFC_V = 21; + public static final int NFC_V = 5; /** * This object is an instance of {@link Ndef} */ - public static final int NDEF = 101; + public static final int NDEF = 6; /** * This object is an instance of {@link NdefFormatable} */ - public static final int NDEF_FORMATABLE = 110; + public static final int NDEF_FORMATABLE = 7; /** * This object is an instance of {@link MifareClassic} */ - public static final int MIFARE_CLASSIC = 200; - - /** - * A Mifare Classic tag with NDEF data - */ - public static final int MIFARE_CLASSIC_NDEF = 201; + public static final int MIFARE_CLASSIC = 8; /** * This object is an instance of {@link MifareUltralight} */ - public static final int MIFARE_ULTRALIGHT = 202; - - /** - * A Mifare DESFire tag - */ - public static final int MIFARE_DESFIRE = 203; + public static final int MIFARE_ULTRALIGHT = 9; /** * Returns the technology type for this tag connection. |