public UsbInterfaceAssert hasInterfaceClass(int interfaceClass) { isNotNull(); int actualInterfaceClass = actual.getInterfaceClass(); Assertions.assertThat(actualInterfaceClass) // .overridingErrorMessage("Expected interface class <%s> but was <%s>.", interfaceClass, actualInterfaceClass) // .isEqualTo(interfaceClass); return this; }
public UsbInterfaceAssert hasInterfaceClass(int interfaceClass) { isNotNull(); int actualInterfaceClass = actual.getInterfaceClass(); Assertions.assertThat(actualInterfaceClass) // .overridingErrorMessage("Expected interface class <%s> but was <%s>.", interfaceClass, actualInterfaceClass) // .isEqualTo(interfaceClass); return this; }
private static int findFirstCDC(UsbDevice device) { int interfaceCount = device.getInterfaceCount(); for (int iIndex = 0; iIndex < interfaceCount; ++iIndex) { if (device.getInterface(iIndex).getInterfaceClass() == UsbConstants.USB_CLASS_CDC_DATA) { return iIndex; } } Log.i(CLASS_ID, "There is no CDC class interface"); return -1; }
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; }
/** * Enumerate the endpoints and interfaces on the connected device. * * @param device Device to query. * @return String description of the device configuration. */ public static String readDevice(UsbDevice device) { StringBuilder sb = new StringBuilder(); sb.append("Device Name: " + device.getDeviceName() + "\n"); sb.append(String.format( "Device Class: %s -> Subclass: 0x%02x -> Protocol: 0x%02x\n", nameForClass(device.getDeviceClass()), device.getDeviceSubclass(), device.getDeviceProtocol())); for (int i = 0; i < device.getInterfaceCount(); i++) { UsbInterface intf = device.getInterface(i); sb.append(String.format(Locale.US, "-- Interface %d Class: %s -> Subclass: 0x%02x -> Protocol: 0x%02x\n", intf.getId(), nameForClass(intf.getInterfaceClass()), intf.getInterfaceSubclass(), intf.getInterfaceProtocol())); sb.append(String.format(Locale.US, " -- Endpoint Count: %d\n", intf.getEndpointCount())); } return sb.toString(); }
/** * Tests to see if a {@link android.hardware.usb.UsbDevice} * supports the PTP protocol (typically used by digital cameras) * * @param device the device to test * @return true if the device is a PTP device. */ static public boolean isCamera(UsbDevice device) { int count = device.getInterfaceCount(); for (int i = 0; i < count; i++) { UsbInterface intf = device.getInterface(i); if (intf.getInterfaceClass() == UsbConstants.USB_CLASS_STILL_IMAGE && intf.getInterfaceSubclass() == 1 && intf.getInterfaceProtocol() == 1) { return true; } } return false; }
if (usbInterface.getInterfaceClass() == 1 && usbInterface.getInterfaceSubclass() == 3) { for (int endpointIndex = 0; endpointIndex < endpointCount; endpointIndex++) { UsbEndpoint endpoint = usbInterface.getEndpoint(endpointIndex);
Log.i(logTag,"constructor: [interface 0] interface class: " + usbInterface.getInterfaceClass()); Log.i(logTag,"constructor: [interface 0] endpoint count: " + usbInterface.getEndpointCount());
for (int i = 0; i < count; i++) { UsbInterface intf = device.getInterface(i); if (matches(intf.getInterfaceClass(), intf.getInterfaceSubclass(), intf.getInterfaceProtocol())) { return true;
if (iFace != null) { final TableLayout bottomTable = viewHolder.getBottomTable(); final String usbClass = UsbConstantResolver.resolveUsbClass((iFace.getInterfaceClass()));
Log.i(TAG," Interface index: " + index); Log.i(TAG," Interface ID: " + mUsbInterface.getId()); Log.i(TAG," Inteface class: " + mUsbInterface.getInterfaceClass()); Log.i(TAG," Interface protocol: " + mUsbInterface.getInterfaceProtocol()); Log.i(TAG," Endpoint count: " + mUsbInterface.getEndpointCount());