TagTechnology.java revision 4e21e1d21a877cce4db5ec8c5786604cc10f2d7e
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     * Returns the technology type for this tag connection.
93     * @hide
94     */
95    public int getTechnologyId();
96
97    /**
98     * Get the {@link Tag} object this technology came from.
99     */
100    public Tag getTag();
101
102    /**
103     * Opens a connection to the {@link Tag} enabling interactive commands. The command set
104     * varies by the technology type.
105     *
106     * <p>This method blocks until the connection has been established.
107     *
108     * <p>A call to {@link #close} from another thread will cancel a blocked call and cause an
109     * IOException to be thrown on the thread that is blocked.
110     *
111     * @see #reconnect()
112     * @see #close()
113     * @throws IOException if the target is lost, or connect canceled
114     */
115    public void connect() throws IOException;
116
117    /**
118     * Re-connect to the {@link Tag} associated with this connection. Reconnecting to a tag can be
119     * used to reset the state of the tag itself.
120     *
121     * <p>This method blocks until the connection is re-established.
122     *
123     * <p>A call to {@link #close} from another thread will cancel a blocked call and cause an
124     * IOException to be thrown on the thread that is blocked.
125     *
126     * @see #connect()
127     * @see #close()
128     * @throws IOException
129     */
130    public void reconnect() throws IOException;
131
132    /**
133     * Closes the connection to the {@link Tag}. This call is non-blocking and causes all blocking
134     * operations such as {@link #connect} to be canceled and immediately throw
135     * {@link java.io.IOException} on the thread that is blocked.
136     *
137     * <p>
138     * Once this method is called, this object cannot be re-used and should be discarded. Further
139     * calls to {@link #connect} will fail.
140     *
141     * @see #connect()
142     * @see #reconnect()
143     */
144    public void close();
145}
146