public UsbInterfaceAssert hasInterfaceProtocol(int protocol) { isNotNull(); int actualProtocol = actual.getInterfaceProtocol(); Assertions.assertThat(actualProtocol) // .overridingErrorMessage("Expected interface protocol <%s> but was <%s>.", protocol, actualProtocol) // .isEqualTo(protocol); return this; }
public UsbInterfaceAssert hasInterfaceProtocol(int protocol) { isNotNull(); int actualProtocol = actual.getInterfaceProtocol(); Assertions.assertThat(actualProtocol) // .overridingErrorMessage("Expected interface protocol <%s> but was <%s>.", protocol, actualProtocol) // .isEqualTo(protocol); 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; }
Log.i(logTag,"constructor: [interface 0] interface protocol: " + usbInterface.getInterfaceProtocol() + " subclass: " + usbInterface.getInterfaceSubclass()); Log.i(logTag,"constructor: [interface 0] interface class: " + usbInterface.getInterfaceClass());
for (int i = 0; i < count; i++) { UsbInterface intf = device.getInterface(i); if (matches(intf.getInterfaceClass(), intf.getInterfaceSubclass(), intf.getInterfaceProtocol())) { return true;
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());