summaryrefslogtreecommitdiffstats
path: root/core/java/android/nfc/tech
diff options
context:
space:
mode:
authorJeff Hamilton <jham@android.com>2011-01-24 14:53:00 -0600
committerJeff Hamilton <jham@android.com>2011-01-25 16:32:26 -0600
commitd88e9aa575eb3a9d20cdb0e8918d54993e1ce1e0 (patch)
treeb18543fc387045158b4ea3ea6b2ada7f12b0b092 /core/java/android/nfc/tech
parent5e81a6e21e9977acd9dfafaf030bf51c8572a98f (diff)
downloadframeworks_base-d88e9aa575eb3a9d20cdb0e8918d54993e1ce1e0.zip
frameworks_base-d88e9aa575eb3a9d20cdb0e8918d54993e1ce1e0.tar.gz
frameworks_base-d88e9aa575eb3a9d20cdb0e8918d54993e1ce1e0.tar.bz2
Use classnames instead of ints for NFC techs.
This makes the system more flexible and allows adding new technology types without having to update the API. Change-Id: Iaee6b633965e501a70e8afc3f1d54d9d94a4d05a
Diffstat (limited to 'core/java/android/nfc/tech')
-rw-r--r--core/java/android/nfc/tech/BasicTagTechnology.java33
-rw-r--r--core/java/android/nfc/tech/Ndef.java2
-rw-r--r--core/java/android/nfc/tech/TagTechnology.java6
3 files changed, 7 insertions, 34 deletions
diff --git a/core/java/android/nfc/tech/BasicTagTechnology.java b/core/java/android/nfc/tech/BasicTagTechnology.java
index a909631..e635f21 100644
--- a/core/java/android/nfc/tech/BasicTagTechnology.java
+++ b/core/java/android/nfc/tech/BasicTagTechnology.java
@@ -36,28 +36,10 @@ import java.io.IOException;
/*package*/ int mSelectedTechnology;
BasicTagTechnology(Tag tag, int tech) throws RemoteException {
- int[] techList = tag.getTechnologyList();
- int i;
-
- // Check target validity
- for (i = 0; i < techList.length; i++) {
- if (tech == techList[i]) {
- break;
- }
- }
- if (i >= techList.length) {
- // Technology not found
- throw new IllegalArgumentException("Technology " + tech + " not present on tag " + tag);
- }
-
mTag = tag;
mSelectedTechnology = tech;
}
- BasicTagTechnology(Tag tag) throws RemoteException {
- this(tag, tag.getTechnologyList()[0]);
- }
-
@Override
public Tag getTag() {
return mTag;
@@ -65,17 +47,12 @@ import java.io.IOException;
/** Internal helper to throw IllegalStateException if the technology isn't connected */
void checkConnected() {
- if ((mTag.getConnectedTechnology() != getTechnologyId()) ||
+ if ((mTag.getConnectedTechnology() != mSelectedTechnology) ||
(mTag.getConnectedTechnology() == -1)) {
throw new IllegalStateException("Call connect() first!");
}
}
- @Override
- public int getTechnologyId() {
- return mSelectedTechnology;
- }
-
/**
* Helper to indicate if {@link #connect} has succeeded.
* <p>
@@ -101,11 +78,12 @@ import java.io.IOException;
@Override
public void connect() throws IOException {
try {
- int errorCode = mTag.getTagService().connect(mTag.getServiceHandle(), getTechnologyId());
+ int errorCode = mTag.getTagService().connect(mTag.getServiceHandle(),
+ mSelectedTechnology);
if (errorCode == ErrorCodes.SUCCESS) {
// Store this in the tag object
- mTag.setConnectedTechnology(getTechnologyId());
+ mTag.setConnectedTechnology(mSelectedTechnology);
mIsConnected = true;
} else {
throw new IOException();
@@ -158,7 +136,8 @@ import java.io.IOException;
checkConnected();
try {
- TransceiveResult result = mTag.getTagService().transceive(mTag.getServiceHandle(), data, raw);
+ TransceiveResult result = mTag.getTagService().transceive(mTag.getServiceHandle(),
+ data, raw);
if (result == null) {
throw new IOException("transceive failed");
} else {
diff --git a/core/java/android/nfc/tech/Ndef.java b/core/java/android/nfc/tech/Ndef.java
index 03f2184..c6804f9 100644
--- a/core/java/android/nfc/tech/Ndef.java
+++ b/core/java/android/nfc/tech/Ndef.java
@@ -31,7 +31,7 @@ import java.io.IOException;
/**
* A high-level connection to a {@link Tag} using one of the NFC type 1, 2, 3, or 4 technologies
* to interact with NDEF data. MiFare Classic cards that present NDEF data may also be used
- * via this class. To determine the exact technology being used call {@link #getTechnologyId()}
+ * via this class. To determine the exact technology being used call {@link #getType()}
*
* <p>You can acquire this kind of connection with {@link #get}.
*
diff --git a/core/java/android/nfc/tech/TagTechnology.java b/core/java/android/nfc/tech/TagTechnology.java
index 1331bae..aebb3e8 100644
--- a/core/java/android/nfc/tech/TagTechnology.java
+++ b/core/java/android/nfc/tech/TagTechnology.java
@@ -89,12 +89,6 @@ public interface TagTechnology {
public static final int MIFARE_ULTRALIGHT = 9;
/**
- * Returns the technology type for this tag connection.
- * @hide
- */
- public int getTechnologyId();
-
- /**
* Get the {@link Tag} object this technology came from.
*/
public Tag getTag();