public static boolean isCdcDevice(UsbDevice device) {
   int iIndex = device.getInterfaceCount();
   for (int i = 0; i <= iIndex - 1; i++) {
     UsbInterface iface = device.getInterface(i);
     if (iface.getInterfaceClass() == UsbConstants.USB_CLASS_CDC_DATA) return true;
   }
   return false;
 }
예제 #2
0
  private boolean isCSCID(UsbDevice device) {
    if (device.getDeviceClass() == UsbConstants.USB_CLASS_CSCID) return true;

    int count = device.getInterfaceCount();
    for (int i = 0; i < count; i++) {
      UsbInterface iface = device.getInterface(i);
      if (iface == null) {
        Log.d(TAG, "isCSCID null interface");
        continue;
      }

      Log.d(TAG, "isCSCID iface class:" + iface.getInterfaceClass());

      if (iface.getInterfaceClass() == UsbConstants.USB_CLASS_CSCID) {
        return true;
      }
    }

    return false;
  }
 // searches for an adb interface on the given USB device
 private static UsbInterface findAdbInterface(UsbDevice device) {
   Log.d(TAG, "findAdbInterface " + device);
   int count = device.getInterfaceCount();
   for (int i = 0; i < count; i++) {
     UsbInterface intf = device.getInterface(i);
     if (intf.getInterfaceClass() == 255
         && intf.getInterfaceSubclass() == 66
         && intf.getInterfaceProtocol() == 1) {
       return intf;
     }
   }
   return null;
 }