public UsbDeviceAssert hasDeviceProtocol(int protocol) { isNotNull(); int actualProtocol = actual.getDeviceProtocol(); assertThat(actualProtocol) // .overridingErrorMessage("Expected device protocol <%s> but was <%s>.", protocol, actualProtocol) // .isEqualTo(protocol); return this; }
public UsbDeviceAssert hasDeviceProtocol(int protocol) { isNotNull(); int actualProtocol = actual.getDeviceProtocol(); assertThat(actualProtocol) // .overridingErrorMessage("Expected device protocol <%s> but was <%s>.", protocol, actualProtocol) // .isEqualTo(protocol); return this; }
if (UsbManager.ACTION_USB_DEVICE_DETACHED.equals(action) && device.getDeviceProtocol() ==1) { Toast.makeText(context, "监听到usb摄像头变动1"+device.getDeviceProtocol(), Toast.LENGTH_LONG).show(); usbcameraConnect = false; closeCamera(0); } else if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(action) && device.getDeviceProtocol()==1) { Toast.makeText(context, "监听到usb摄像头变动0"+device.getDeviceProtocol(), Toast.LENGTH_LONG).show(); try { Thread.sleep(500);
static public boolean isG4Connected(Context c){ UsbManager manager = (UsbManager) c.getSystemService(Context.USB_SERVICE); HashMap<String, UsbDevice> deviceList = manager.getDeviceList(); Log.i("USB DEVICES = ", deviceList.toString()); Iterator<UsbDevice> deviceIterator = deviceList.values().iterator(); Log.i("USB DEVICES = ", String.valueOf(deviceList.size())); while(deviceIterator.hasNext()){ UsbDevice device = deviceIterator.next(); if (device.getVendorId() == 8867 && device.getProductId() == 71 && device.getDeviceClass() == 2 && device.getDeviceSubclass() ==0 && device.getDeviceProtocol() == 0){ Log.i("CALIBRATION-CHECK-IN: ", "Dexcom Found!"); return true; } } return false; }
static public boolean isG4Connected(Context c){ UsbManager manager = (UsbManager) c.getSystemService(Context.USB_SERVICE); HashMap<String, UsbDevice> deviceList = manager.getDeviceList(); Log.i("USB DEVICES = ", deviceList.toString()); Iterator<UsbDevice> deviceIterator = deviceList.values().iterator(); Log.i("USB DEVICES = ", String.valueOf(deviceList.size())); while(deviceIterator.hasNext()){ UsbDevice device = deviceIterator.next(); if (device.getVendorId() == 8867 && device.getProductId() == 71 && device.getDeviceClass() == 2 && device.getDeviceSubclass() ==0 && device.getDeviceProtocol() == 0){ Log.i("CALIBRATION-CHECK-IN: ", "Dexcom Found!"); return true; } } return false; }
public UsbDevice findDexcom() { Log.i("CALIBRATION-CHECK-IN: ", "Searching for dexcom"); mUsbManager = (UsbManager) getApplicationContext().getSystemService(Context.USB_SERVICE); Log.i("USB MANAGER = ", mUsbManager.toString()); HashMap<String, UsbDevice> deviceList = mUsbManager.getDeviceList(); Log.i("USB DEVICES = ", deviceList.toString()); Iterator<UsbDevice> deviceIterator = deviceList.values().iterator(); Log.i("USB DEVICES = ", String.valueOf(deviceList.size())); while(deviceIterator.hasNext()){ UsbDevice device = deviceIterator.next(); if (device.getVendorId() == 8867 && device.getProductId() == 71 && device.getDeviceClass() == 2 && device.getDeviceSubclass() ==0 && device.getDeviceProtocol() == 0){ dexcom = device; Log.i("CALIBRATION-CHECK-IN: ", "Dexcom Found!"); return device; } else { Log.w("CALIBRATION-CHECK-IN: ", "that was not a dexcom (I dont think)"); } } return null; }
public UsbDevice findDexcom() { Log.i("CALIBRATION-CHECK-IN: ", "Searching for dexcom"); mUsbManager = (UsbManager) getApplicationContext().getSystemService(Context.USB_SERVICE); Log.i("USB MANAGER = ", mUsbManager.toString()); HashMap<String, UsbDevice> deviceList = mUsbManager.getDeviceList(); Log.i("USB DEVICES = ", deviceList.toString()); Iterator<UsbDevice> deviceIterator = deviceList.values().iterator(); Log.i("USB DEVICES = ", String.valueOf(deviceList.size())); while(deviceIterator.hasNext()){ UsbDevice device = deviceIterator.next(); if (device.getVendorId() == 8867 && device.getProductId() == 71 && device.getDeviceClass() == 2 && device.getDeviceSubclass() ==0 && device.getDeviceProtocol() == 0){ dexcom = device; Log.i("CALIBRATION-CHECK-IN: ", "Dexcom Found!"); return device; } else { Log.w("CALIBRATION-CHECK-IN: ", "that was not a dexcom (I dont think)"); } } return null; }
/** * 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(); }
Log.i(logTag,"constructor: device protocol: " + usbDevice.getDeviceProtocol()); Log.i(logTag,"constructor: device class: " + usbDevice.getDeviceClass() + " subclass: " + usbDevice.getDeviceSubclass());
if (matches(device.getDeviceClass(), device.getDeviceSubclass(), device.getDeviceProtocol())) { return true;