1616
1717package android .nfc ;
1818
19+ import android .nfc .tech .IsoDep ;
20+ import android .nfc .tech .MifareClassic ;
21+ import android .nfc .tech .MifareUltralight ;
22+ import android .nfc .tech .Ndef ;
23+ import android .nfc .tech .NdefFormatable ;
24+ import android .nfc .tech .NfcA ;
25+ import android .nfc .tech .NfcB ;
26+ import android .nfc .tech .NfcF ;
27+ import android .nfc .tech .NfcV ;
1928import android .nfc .tech .TagTechnology ;
2029import android .os .Bundle ;
2130import android .os .Parcel ;
4958public class Tag implements Parcelable {
5059 /*package*/ final byte [] mId ;
5160 /*package*/ final int [] mTechList ;
61+ /*package*/ final String [] mTechStringList ;
5262 /*package*/ final Bundle [] mTechExtras ;
5363 /*package*/ final int mServiceHandle ; // for use by NFC service, 0 indicates a mock
5464 /*package*/ final INfcTag mTagService ;
@@ -66,6 +76,7 @@ public Tag(byte[] id, int[] techList, Bundle[] techListExtras, int serviceHandle
6676 }
6777 mId = id ;
6878 mTechList = Arrays .copyOf (techList , techList .length );
79+ mTechStringList = generateTechStringList (techList );
6980 // Ensure mTechExtras is as long as mTechList
7081 mTechExtras = Arrays .copyOf (techListExtras , techList .length );
7182 mServiceHandle = serviceHandle ;
@@ -88,6 +99,45 @@ public static Tag createMockTag(byte[] id, int[] techList, Bundle[] techListExtr
8899 return new Tag (id , techList , techListExtras , 0 , null );
89100 }
90101
102+ private String [] generateTechStringList (int [] techList ) {
103+ final int size = techList .length ;
104+ String [] strings = new String [size ];
105+ for (int i = 0 ; i < size ; i ++) {
106+ switch (techList [i ]) {
107+ case TagTechnology .ISO_DEP :
108+ strings [i ] = IsoDep .class .getName ();
109+ break ;
110+ case TagTechnology .MIFARE_CLASSIC :
111+ strings [i ] = MifareClassic .class .getName ();
112+ break ;
113+ case TagTechnology .MIFARE_ULTRALIGHT :
114+ strings [i ] = MifareUltralight .class .getName ();
115+ break ;
116+ case TagTechnology .NDEF :
117+ strings [i ] = Ndef .class .getName ();
118+ break ;
119+ case TagTechnology .NDEF_FORMATABLE :
120+ strings [i ] = NdefFormatable .class .getName ();
121+ break ;
122+ case TagTechnology .NFC_A :
123+ strings [i ] = NfcA .class .getName ();
124+ break ;
125+ case TagTechnology .NFC_B :
126+ strings [i ] = NfcB .class .getName ();
127+ break ;
128+ case TagTechnology .NFC_F :
129+ strings [i ] = NfcF .class .getName ();
130+ break ;
131+ case TagTechnology .NFC_V :
132+ strings [i ] = NfcV .class .getName ();
133+ break ;
134+ default :
135+ throw new IllegalArgumentException ("Unknown tech type " + techList [i ]);
136+ }
137+ }
138+ return strings ;
139+ }
140+
91141 /**
92142 * For use by NfcService only.
93143 * @hide
@@ -110,13 +160,12 @@ public byte[] getId() {
110160 * Returns technologies present in the tag that this implementation understands,
111161 * or a zero length array if there are no supported technologies on this tag.
112162 *
113- * The elements of the list are guaranteed be one of the constants defined in
114- * {@link TagTechnology}.
163+ * The elements of the list are the names of the classes implementing the technology.
115164 *
116165 * The ordering of the returned array is undefined and should not be relied upon.
117166 */
118- public int [] getTechnologyList () {
119- return Arrays . copyOf ( mTechList , mTechList . length ) ;
167+ public String [] getTechList () {
168+ return mTechStringList ;
120169 }
121170
122171 /** @hide */
0 commit comments