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     }
相关文章
相关标签/搜索