Loading core/java/android/nfc/Tag.java +4 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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"); Loading core/java/android/nfc/technology/MifareUltralight.java 0 → 100644 +81 −0 Original line number Diff line number Diff line /* * 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); */ } core/java/android/nfc/technology/TagTechnology.java +1 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading
core/java/android/nfc/Tag.java +4 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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"); Loading
core/java/android/nfc/technology/MifareUltralight.java 0 → 100644 +81 −0 Original line number Diff line number Diff line /* * 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); */ }
core/java/android/nfc/technology/TagTechnology.java +1 −1 Original line number Diff line number Diff line Loading @@ -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; Loading