• android ccid开发笔记1


    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() == 3
    19                         && intf.getInterfaceSubclass() == 0
    20                         && intf.getInterfaceProtocol() == 0) {
    21                     myInterface = intf;
    22                     Log.d(TAG, "找到我的设备接口");
    23                 }
    24                 break;
    25             }
    26         }
    27     }
  • 相关阅读:
    文件上传案例_Socket_测试
    Linux的小整理(入门)
    full stack 第一天
    基础考题 试题
    shell语法
    网络管理
    图像类
    定时储存
    网络管理
    磁盘管理
  • 原文地址:https://www.cnblogs.com/qwhg/p/4958274.html
Copyright © 2020-2023  润新知