public UsbInterfaceAssert hasInterfaceSubclass(int subclass) { isNotNull(); int actualSubclass = actual.getInterfaceSubclass(); Assertions.assertThat(actualSubclass) // .overridingErrorMessage("Expected interface subclass <%s> but was <%s>.", subclass, actualSubclass) // .isEqualTo(subclass); return this; } }
public UsbInterfaceAssert hasInterfaceSubclass(int subclass) { isNotNull(); int actualSubclass = actual.getInterfaceSubclass(); Assertions.assertThat(actualSubclass) // .overridingErrorMessage("Expected interface subclass <%s> but was <%s>.", subclass, actualSubclass) // .isEqualTo(subclass); return this; } }
/** * 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);
+ " subclass: " + usbInterface.getInterfaceSubclass()); 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;