TagTechnology.java revision d88e9aa575eb3a9d20cdb0e8918d54993e1ce1e0
1/* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.nfc.tech; 18 19import android.nfc.Tag; 20 21import java.io.IOException; 22 23public interface TagTechnology { 24 /** 25 * This technology is an instance of {@link NfcA}. 26 * <p>Support for this technology type is mandatory. 27 * @hide 28 */ 29 public static final int NFC_A = 1; 30 31 /** 32 * This technology is an instance of {@link NfcB}. 33 * <p>Support for this technology type is mandatory. 34 * @hide 35 */ 36 public static final int NFC_B = 2; 37 38 /** 39 * This technology is an instance of {@link IsoDep}. 40 * <p>Support for this technology type is mandatory. 41 * @hide 42 */ 43 public static final int ISO_DEP = 3; 44 45 /** 46 * This technology is an instance of {@link NfcF}. 47 * <p>Support for this technology type is mandatory. 48 * @hide 49 */ 50 public static final int NFC_F = 4; 51 52 /** 53 * This technology is an instance of {@link NfcV}. 54 * <p>Support for this technology type is mandatory. 55 * @hide 56 */ 57 public static final int NFC_V = 5; 58 59 /** 60 * This technology is an instance of {@link Ndef}. 61 * <p>Support for this technology type is mandatory. 62 * @hide 63 */ 64 public static final int NDEF = 6; 65 66 /** 67 * This technology is an instance of {@link NdefFormatable}. 68 * <p>Support for this technology type is mandatory. 69 * @hide 70 */ 71 public static final int NDEF_FORMATABLE = 7; 72 73 /** 74 * This technology is an instance of {@link MifareClassic}. 75 * <p>Support for this technology type is optional. If a stack doesn't support this technology 76 * type tags using it must still be discovered and present the lower level radio interface 77 * technologies in use. 78 * @hide 79 */ 80 public static final int MIFARE_CLASSIC = 8; 81 82 /** 83 * This technology is an instance of {@link MifareUltralight}. 84 * <p>Support for this technology type is optional. If a stack doesn't support this technology 85 * type tags using it must still be discovered and present the lower level radio interface 86 * technologies in use. 87 * @hide 88 */ 89 public static final int MIFARE_ULTRALIGHT = 9; 90 91 /** 92 * Get the {@link Tag} object this technology came from. 93 */ 94 public Tag getTag(); 95 96 /** 97 * Opens a connection to the {@link Tag} enabling interactive commands. The command set 98 * varies by the technology type. 99 * 100 * <p>This method blocks until the connection has been established. 101 * 102 * <p>A call to {@link #close} from another thread will cancel a blocked call and cause an 103 * IOException to be thrown on the thread that is blocked. 104 * 105 * @see #reconnect() 106 * @see #close() 107 * @throws IOException if the target is lost, or connect canceled 108 */ 109 public void connect() throws IOException; 110 111 /** 112 * Re-connect to the {@link Tag} associated with this connection. Reconnecting to a tag can be 113 * used to reset the state of the tag itself. 114 * 115 * <p>This method blocks until the connection is re-established. 116 * 117 * <p>A call to {@link #close} from another thread will cancel a blocked call and cause an 118 * IOException to be thrown on the thread that is blocked. 119 * 120 * @see #connect() 121 * @see #close() 122 * @throws IOException 123 */ 124 public void reconnect() throws IOException; 125 126 /** 127 * Closes the connection to the {@link Tag}. This call is non-blocking and causes all blocking 128 * operations such as {@link #connect} to be canceled and immediately throw 129 * {@link java.io.IOException} on the thread that is blocked. 130 * 131 * <p> 132 * Once this method is called, this object cannot be re-used and should be discarded. Further 133 * calls to {@link #connect} will fail. 134 * 135 * @see #connect() 136 * @see #reconnect() 137 */ 138 public void close(); 139} 140