summaryrefslogtreecommitdiffstats
path: root/core/java/android/nfc
diff options
context:
space:
mode:
authorJan Brands <jan.r.brands@nxp.com>2010-12-03 23:45:03 +0100
committerJan Brands <jan.r.brands@nxp.com>2010-12-03 23:45:03 +0100
commit2fe24e3e14cce791e89c93ddc23e28af5c2c90cc (patch)
tree0b69877bb396987ef8f107d6b00f2fec59f415ba /core/java/android/nfc
parent609b3e429a2b74d141c9c30b21403beacb23ca03 (diff)
downloadframeworks_base-2fe24e3e14cce791e89c93ddc23e28af5c2c90cc.zip
frameworks_base-2fe24e3e14cce791e89c93ddc23e28af5c2c90cc.tar.gz
frameworks_base-2fe24e3e14cce791e89c93ddc23e28af5c2c90cc.tar.bz2
First implementation of MifareUltralight
Change-Id: I77818ddc89b529c17fc41d6c0850688365c6b770
Diffstat (limited to 'core/java/android/nfc')
-rw-r--r--core/java/android/nfc/Tag.java4
-rw-r--r--core/java/android/nfc/technology/MifareUltralight.java81
-rw-r--r--core/java/android/nfc/technology/TagTechnology.java2
3 files changed, 86 insertions, 1 deletions
diff --git a/core/java/android/nfc/Tag.java b/core/java/android/nfc/Tag.java
index 938e6a7..4d9e635 100644
--- a/core/java/android/nfc/Tag.java
+++ b/core/java/android/nfc/Tag.java
@@ -18,6 +18,7 @@ package android.nfc;
import android.nfc.technology.IsoDep;
import android.nfc.technology.MifareClassic;
+import android.nfc.technology.MifareUltralight;
import android.nfc.technology.NfcV;
import android.nfc.technology.Ndef;
import android.nfc.technology.NfcA;
@@ -160,6 +161,9 @@ public class Tag implements Parcelable {
case TagTechnology.MIFARE_CLASSIC: {
return new MifareClassic(adapter, this, extras);
}
+ case TagTechnology.MIFARE_ULTRALIGHT: {
+ return new MifareUltralight(adapter, this, extras);
+ }
default: {
throw new UnsupportedOperationException("Tech " + tech + " not supported");
diff --git a/core/java/android/nfc/technology/MifareUltralight.java b/core/java/android/nfc/technology/MifareUltralight.java
new file mode 100644
index 0000000..dd1dae9
--- /dev/null
+++ b/core/java/android/nfc/technology/MifareUltralight.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.nfc.technology;
+
+import android.nfc.NfcAdapter;
+import android.nfc.Tag;
+import android.os.Bundle;
+import android.os.RemoteException;
+
+import java.io.IOException;
+
+/**
+ * Concrete class for TagTechnology.MIFARE_ULTRALIGHT
+ *
+ * Mifare classic has n sectors, with varying sizes, although
+ * they are at least the same pattern for any one mifare classic
+ * product. Each sector has two keys. Authentication with the correct
+ * key is needed before access to any sector.
+ *
+ * Each sector has k blocks.
+ * Block size is constant across the whole mifare classic family.
+ */
+public final class MifareUltralight extends BasicTagTechnology {
+ public static final int TYPE_ULTRALIGHT = 1;
+ public static final int TYPE_ULTRALIGHT_C = 2;
+ public static final int TYPE_UNKNOWN = 10;
+
+ private static final int NXP_MANUFACTURER_ID = 0x04;
+
+ private int mType;
+
+ public MifareUltralight(NfcAdapter adapter, Tag tag, Bundle extras) throws RemoteException {
+ super(adapter, tag, TagTechnology.MIFARE_ULTRALIGHT);
+
+ // Check if this could actually be a Mifare
+ NfcA a = (NfcA) tag.getTechnology(TagTechnology.NFC_A);
+
+ mType = TYPE_UNKNOWN;
+
+ if( a.getSak() == 0x00 && tag.getId()[0] == NXP_MANUFACTURER_ID ) {
+ // could be UL or UL-C
+ mType = TYPE_ULTRALIGHT;
+ }
+ }
+
+ public int getType() {
+ return mType;
+ }
+
+ // Methods that require connect()
+ /**
+ * @throws IOException
+ */
+ public byte[] readBlock(int block) throws IOException {
+ byte[] blockread_cmd = { 0x30, (byte)block }; // phHal_eMifareRead
+ return transceive(blockread_cmd);
+ }
+
+ /**
+ * @throws IOException
+ */
+/*
+ public byte[] readOTP();
+ public void writePage(int block, byte[] data);
+ public void writeBlock(int block, byte[] data);
+*/
+}
diff --git a/core/java/android/nfc/technology/TagTechnology.java b/core/java/android/nfc/technology/TagTechnology.java
index c6c65e8..2b4f74c 100644
--- a/core/java/android/nfc/technology/TagTechnology.java
+++ b/core/java/android/nfc/technology/TagTechnology.java
@@ -77,7 +77,7 @@ public interface TagTechnology {
public static final int MIFARE_CLASSIC_NDEF = 201;
/**
- * A Mifare Ultralight tag
+ * This object is an instance of {@link MifareUltralight}
*/
public static final int MIFARE_ULTRALIGHT = 202;