TagTechnology.java revision 3fcedf77286a078ebd7ac8c082365bd80703dfdc
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.Closeable; 22import java.io.IOException; 23 24public interface TagTechnology extends Closeable { 25 /** 26 * This technology is an instance of {@link NfcA}. 27 * <p>Support for this technology type is mandatory. 28 * @hide 29 */ 30 public static final int NFC_A = 1; 31 32 /** 33 * This technology is an instance of {@link NfcB}. 34 * <p>Support for this technology type is mandatory. 35 * @hide 36 */ 37 public static final int NFC_B = 2; 38 39 /** 40 * This technology is an instance of {@link IsoDep}. 41 * <p>Support for this technology type is mandatory. 42 * @hide 43 */ 44 public static final int ISO_DEP = 3; 45 46 /** 47 * This technology is an instance of {@link NfcF}. 48 * <p>Support for this technology type is mandatory. 49 * @hide 50 */ 51 public static final int NFC_F = 4; 52 53 /** 54 * This technology is an instance of {@link NfcV}. 55 * <p>Support for this technology type is mandatory. 56 * @hide 57 */ 58 public static final int NFC_V = 5; 59 60 /** 61 * This technology is an instance of {@link Ndef}. 62 * <p>Support for this technology type is mandatory. 63 * @hide 64 */ 65 public static final int NDEF = 6; 66 67 /** 68 * This technology is an instance of {@link NdefFormatable}. 69 * <p>Support for this technology type is mandatory. 70 * @hide 71 */ 72 public static final int NDEF_FORMATABLE = 7; 73 74 /** 75 * This technology is an instance of {@link MifareClassic}. 76 * <p>Support for this technology type is optional. If a stack doesn't support this technology 77 * type tags using it must still be discovered and present the lower level radio interface 78 * technologies in use. 79 * @hide 80 */ 81 public static final int MIFARE_CLASSIC = 8; 82 83 /** 84 * This technology is an instance of {@link MifareUltralight}. 85 * <p>Support for this technology type is optional. If a stack doesn't support this technology 86 * type tags using it must still be discovered and present the lower level radio interface 87 * technologies in use. 88 * @hide 89 */ 90 public static final int MIFARE_ULTRALIGHT = 9; 91 92 /** 93 * Get the {@link Tag} object this technology came from. 94 */ 95 public Tag getTag(); 96 97 /** 98 * Opens a connection to the {@link Tag} enabling interactive commands. The command set 99 * varies by the technology type. 100 * 101 * <p>This method blocks until the connection has been established. 102 * 103 * <p>A call to {@link #close} from another thread will cancel a blocked call and cause an 104 * IOException to be thrown on the thread that is blocked. 105 * 106 * @see #reconnect() 107 * @see #close() 108 * @throws IOException if the target is lost, or connect canceled 109 */ 110 public void connect() throws IOException; 111 112 /** 113 * Re-connect to the {@link Tag} associated with this connection. Reconnecting to a tag can be 114 * used to reset the state of the tag itself. 115 * 116 * <p>This method blocks until the connection is re-established. 117 * 118 * <p>A call to {@link #close} from another thread will cancel a blocked call and cause an 119 * IOException to be thrown on the thread that is blocked. 120 * 121 * @see #connect() 122 * @see #close() 123 * @throws IOException 124 */ 125 public void reconnect() throws IOException; 126 127 /** 128 * Closes the connection to the {@link Tag}. This call is non-blocking and causes all blocking 129 * operations such as {@link #connect} to be canceled and immediately throw 130 * {@link java.io.IOException} on the thread that is blocked. 131 * 132 * <p> 133 * Once this method is called, this object cannot be re-used and should be discarded. Further 134 * calls to {@link #connect} will fail. 135 * 136 * @see #connect() 137 * @see #reconnect() 138 */ 139 public void close() throws IOException; 140} 141