android ccid開發筆記1,androidccid
CCID:CCID(USB Chip/Smart Card Interface Devices-USB晶片智慧卡介面裝置)標準是由幾大國際級IT企業共同制定的一個標準,它提供了一種智慧卡讀寫裝置與主機或其它嵌入式主機實現相互連訊的可能。
開發中碰到幾個方法不知道是什麼意思..看了api後明白了.
intf.getInterfaceClass();
intf.getInterfaceSubclass();
intf.getInterfaceProtocol();
上面三個方法的傳回值都是int類型.
getInterfaceClass();表示擷取智慧卡的裝置id,具體可以看UsbConstants類.
getInterfaceSubclass();表示擷取子類碼.
getInterfaceProtocol();獲得協議碼.CCID的協議碼是00h.
程式碼片段如下:
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() == 319 && intf.getInterfaceSubclass() == 020 && intf.getInterfaceProtocol() == 0) {21 myInterface = intf;22 Log.d(TAG, "找到我的裝置介面");23 }24 break;25 }26 }27 }