android ccid開發筆記1

CCID:CCID(USB Chip/Smart Card Interface Devices-USB芯片智能卡接口設備)標準是由幾大國際級IT企業共同制定的一個標準,它提供了一種智能卡讀寫設備與主機或其它嵌入式主機實現相互通信的可能。api

開發中碰到幾個方法不知道是什麼意思..看了api後明白了.spa

intf.getInterfaceClass();code

intf.getInterfaceSubclass();blog

intf.getInterfaceProtocol();接口

上面三個方法的返回值都是int類型.ip

getInterfaceClass();表示獲取智能卡的設備id,具體能夠看UsbConstants類.開發

getInterfaceSubclass();表示獲取子類碼.get

getInterfaceProtocol();得到協議碼.CCID的協議碼是00h.class

代碼片斷以下:方法

 1 /**
 2      * 找設備接口
 3      */
 4     private void findInterface() {
 5         if (myUsbDevice != null) {
 6             Log.d(TAG, "interfaceCounts : " + myUsbDevice.getInterfaceCount());
 7             for (int i = 0; i < myUsbDevice.getInterfaceCount(); i++) {
 8                 UsbInterface intf = myUsbDevice.getInterface(i);
 9                 Log.d(TAG,
10                         "intf.getInterfaceClass() = "
11                                 + intf.getInterfaceClass());
12                 Log.d(TAG,
13                         "intf.getInterfaceSubclass() = "
14                                 + intf.getInterfaceSubclass());
15                 Log.d(TAG,
16                         "intf.getInterfaceProtocol() = "
17                                 + intf.getInterfaceProtocol());
18                 if (intf.getInterfaceClass() == 3
19                         && intf.getInterfaceSubclass() == 0
20                         && intf.getInterfaceProtocol() == 0) {
21                     myInterface = intf;
22                     Log.d(TAG, "找到個人設備接口");
23                 }
24                 break;
25             }
26         }
27     }
相關文章
相關標籤/搜索