Java Code Examples for android.hardware.usb.UsbDevice#getDeviceClass()
The following examples show how to use
android.hardware.usb.UsbDevice#getDeviceClass() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SyncingService.java From xDrip with GNU General Public License v3.0 | 6 votes |
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; }
Example 2
Source File: SyncingService.java From xDrip with GNU General Public License v3.0 | 6 votes |
public UsbDevice findDexcom() { Log.w("CALIBRATION-CHECK-IN: ", "Searching for dexcom"); mUsbManager = (UsbManager) getApplicationContext().getSystemService(Context.USB_SERVICE); Log.w("USB MANAGER = ", mUsbManager.toString()); HashMap<String, UsbDevice> deviceList = mUsbManager.getDeviceList(); Log.w("USB DEVICES = ", deviceList.toString()); Iterator<UsbDevice> deviceIterator = deviceList.values().iterator(); Log.w("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.w("CALIBRATION-CHECK-IN: ", "Dexcom Found!"); return device; } else { Log.w("CALIBRATION-CHECK-IN: ", "that was not a dexcom (I dont think)"); } } return null; }
Example 3
Source File: SyncingService.java From xDrip with GNU General Public License v3.0 | 6 votes |
static public boolean isG4Connected(Context c){ UsbManager manager = (UsbManager) c.getSystemService(Context.USB_SERVICE); HashMap<String, UsbDevice> deviceList = manager.getDeviceList(); Log.w("USB DEVICES = ", deviceList.toString()); Iterator<UsbDevice> deviceIterator = deviceList.values().iterator(); Log.w("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.w("CALIBRATION-CHECK-IN: ", "Dexcom Found!"); return true; } } return false; }
Example 4
Source File: SyncingService.java From xDrip-Experimental with GNU General Public License v3.0 | 6 votes |
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; }
Example 5
Source File: SyncingService.java From xDrip-Experimental with GNU General Public License v3.0 | 6 votes |
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; }
Example 6
Source File: SyncingService.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
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; }
Example 7
Source File: SyncingService.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
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; }
Example 8
Source File: SyncingService.java From xDrip with GNU General Public License v3.0 | 6 votes |
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; }
Example 9
Source File: DeviceFilter.java From libcommon with Apache License 2.0 | 5 votes |
@SuppressLint("NewApi") public DeviceFilter(@NonNull final UsbDevice device, final boolean isExclude) { mVendorId = device.getVendorId(); mProductId = device.getProductId(); mClass = device.getDeviceClass(); mSubclass = device.getDeviceSubclass(); mProtocol = device.getDeviceProtocol(); // getInterfaceCountは内部配列のlengthを返すので負にはならないはずだけど年のために下限を0にする final int count = Math.max(device.getInterfaceCount(), 0); mIntfClass = new int[count]; mIntfSubClass = new int[count]; mIntfProtocol = new int[count]; for (int i = 0; i < count; i++) { final UsbInterface intf = device.getInterface(i); mIntfClass[i] = intf.getInterfaceClass(); mIntfSubClass[i] = intf.getInterfaceSubclass(); mIntfProtocol[i] = intf.getInterfaceProtocol(); } if (BuildCheck.isLollipop()) { mManufacturerName = device.getManufacturerName(); mProductName = device.getProductName(); mSerialNumber = device.getSerialNumber(); } else { mManufacturerName = null; mProductName = null; mSerialNumber = null; } this.isExclude = isExclude; }
Example 10
Source File: UsbUtils.java From FireFiles with Apache License 2.0 | 5 votes |
private static String nameForClass(UsbDevice usbDevice) { int classType = usbDevice.getDeviceClass(); switch (classType) { case UsbConstants.USB_CLASS_AUDIO: return "Audio"; case UsbConstants.USB_CLASS_CDC_DATA: return "CDC Control"; case UsbConstants.USB_CLASS_COMM: return "Communications"; case UsbConstants.USB_CLASS_CONTENT_SEC: return "Content Security"; case UsbConstants.USB_CLASS_CSCID: return "Content Smart Card"; case UsbConstants.USB_CLASS_HID: return "Human Interface Device"; case UsbConstants.USB_CLASS_HUB: return "Hub"; case UsbConstants.USB_CLASS_MASS_STORAGE: return "Mass Storage"; case UsbConstants.USB_CLASS_MISC: return "Wireless Miscellaneous"; case UsbConstants.USB_CLASS_PHYSICA: return "Physical"; case UsbConstants.USB_CLASS_PRINTER: return "Printer"; case UsbConstants.USB_CLASS_STILL_IMAGE: return "Still Image"; case UsbConstants.USB_CLASS_VENDOR_SPEC: return String.format("Vendor Specific 0x%02x", classType); case UsbConstants.USB_CLASS_VIDEO: return "Video"; case UsbConstants.USB_CLASS_WIRELESS_CONTROLLER: return "Wireless Controller"; default: return ""; } }
Example 11
Source File: DeviceFilter.java From UVCCameraZxing with Apache License 2.0 | 5 votes |
public DeviceFilter(final UsbDevice device) { mVendorId = device.getVendorId(); mProductId = device.getProductId(); mClass = device.getDeviceClass(); mSubclass = device.getDeviceSubclass(); mProtocol = device.getDeviceProtocol(); mManufacturerName = null; // device.getManufacturerName(); mProductName = null; // device.getProductName(); mSerialNumber = null; // device.getSerialNumber(); /* Log.i(TAG, String.format("vendorId=0x%04x,productId=0x%04x,class=0x%02x,subclass=0x%02x,protocol=0x%02x", mVendorId, mProductId, mClass, mSubclass, mProtocol)); */ }
Example 12
Source File: DeviceFilter.java From DeviceConnect-Android with MIT License | 5 votes |
public DeviceFilter(final UsbDevice device, final boolean isExclude) { mVendorId = device.getVendorId(); mProductId = device.getProductId(); mClass = device.getDeviceClass(); mSubclass = device.getDeviceSubclass(); mProtocol = device.getDeviceProtocol(); mManufacturerName = null; // device.getManufacturerName(); mProductName = null; // device.getProductName(); mSerialNumber = null; // device.getSerialNumber(); this.isExclude = isExclude; /* Log.i(TAG, String.format("vendorId=0x%04x,productId=0x%04x,class=0x%02x,subclass=0x%02x,protocol=0x%02x", mVendorId, mProductId, mClass, mSubclass, mProtocol)); */ }
Example 13
Source File: DeviceFilter.java From AndroidUSBCamera with Apache License 2.0 | 5 votes |
public DeviceFilter(final UsbDevice device, final boolean isExclude) { mVendorId = device.getVendorId(); mProductId = device.getProductId(); mClass = device.getDeviceClass(); mSubclass = device.getDeviceSubclass(); mProtocol = device.getDeviceProtocol(); mManufacturerName = null; // device.getManufacturerName(); mProductName = null; // device.getProductName(); mSerialNumber = null; // device.getSerialNumber(); this.isExclude = isExclude; /* Log.i(TAG, String.format("vendorId=0x%04x,productId=0x%04x,class=0x%02x,subclass=0x%02x,protocol=0x%02x", mVendorId, mProductId, mClass, mSubclass, mProtocol)); */ }
Example 14
Source File: UsbUtils.java From FireFiles with Apache License 2.0 | 5 votes |
private static String nameForClass(UsbDevice usbDevice) { int classType = usbDevice.getDeviceClass(); switch (classType) { case UsbConstants.USB_CLASS_AUDIO: return "Audio"; case UsbConstants.USB_CLASS_CDC_DATA: return "CDC Control"; case UsbConstants.USB_CLASS_COMM: return "Communications"; case UsbConstants.USB_CLASS_CONTENT_SEC: return "Content Security"; case UsbConstants.USB_CLASS_CSCID: return "Content Smart Card"; case UsbConstants.USB_CLASS_HID: return "Human Interface Device"; case UsbConstants.USB_CLASS_HUB: return "Hub"; case UsbConstants.USB_CLASS_MASS_STORAGE: return "Mass Storage"; case UsbConstants.USB_CLASS_MISC: return "Wireless Miscellaneous"; case UsbConstants.USB_CLASS_PHYSICA: return "Physical"; case UsbConstants.USB_CLASS_PRINTER: return "Printer"; case UsbConstants.USB_CLASS_STILL_IMAGE: return "Still Image"; case UsbConstants.USB_CLASS_VENDOR_SPEC: return String.format("Vendor Specific 0x%02x", classType); case UsbConstants.USB_CLASS_VIDEO: return "Video"; case UsbConstants.USB_CLASS_WIRELESS_CONTROLLER: return "Wireless Controller"; default: return ""; } }
Example 15
Source File: UsbUtils.java From FireFiles with Apache License 2.0 | 5 votes |
private static String nameForClass(UsbDevice usbDevice) { int classType = usbDevice.getDeviceClass(); switch (classType) { case UsbConstants.USB_CLASS_AUDIO: return "Audio"; case UsbConstants.USB_CLASS_CDC_DATA: return "CDC Control"; case UsbConstants.USB_CLASS_COMM: return "Communications"; case UsbConstants.USB_CLASS_CONTENT_SEC: return "Content Security"; case UsbConstants.USB_CLASS_CSCID: return "Content Smart Card"; case UsbConstants.USB_CLASS_HID: return "Human Interface Device"; case UsbConstants.USB_CLASS_HUB: return "Hub"; case UsbConstants.USB_CLASS_MASS_STORAGE: return "Mass Storage"; case UsbConstants.USB_CLASS_MISC: return "Wireless Miscellaneous"; case UsbConstants.USB_CLASS_PHYSICA: return "Physical"; case UsbConstants.USB_CLASS_PRINTER: return "Printer"; case UsbConstants.USB_CLASS_STILL_IMAGE: return "Still Image"; case UsbConstants.USB_CLASS_VENDOR_SPEC: return String.format("Vendor Specific 0x%02x", classType); case UsbConstants.USB_CLASS_VIDEO: return "Video"; case UsbConstants.USB_CLASS_WIRELESS_CONTROLLER: return "Wireless Controller"; default: return ""; } }
Example 16
Source File: DeviceFilter.java From libcommon with Apache License 2.0 | 4 votes |
@Override public boolean equals(final Object obj) { // can't compare if we have wildcard strings if (mVendorId == -1 || mProductId == -1 || mClass == -1 || mSubclass == -1 || mProtocol == -1) { return false; } if (obj instanceof DeviceFilter) { final DeviceFilter filter = (DeviceFilter) obj; if (filter.mVendorId != mVendorId || filter.mProductId != mProductId || filter.mClass != mClass || filter.mSubclass != mSubclass || filter.mProtocol != mProtocol) { return false; } if ((filter.mManufacturerName != null && mManufacturerName == null) || (filter.mManufacturerName == null && mManufacturerName != null) || (filter.mProductName != null && mProductName == null) || (filter.mProductName == null && mProductName != null) || (filter.mSerialNumber != null && mSerialNumber == null) || (filter.mSerialNumber == null && mSerialNumber != null)) { return false; } if ((filter.mManufacturerName != null && mManufacturerName != null && !mManufacturerName .equals(filter.mManufacturerName)) || (filter.mProductName != null && mProductName != null && !mProductName .equals(filter.mProductName)) || (filter.mSerialNumber != null && mSerialNumber != null && !mSerialNumber .equals(filter.mSerialNumber))) { return false; } return (filter.isExclude != isExclude); } if (obj instanceof UsbDevice) { final UsbDevice device = (UsbDevice) obj; if (isExclude || (device.getVendorId() != mVendorId) || (device.getProductId() != mProductId) || (device.getDeviceClass() != mClass) || (device.getDeviceSubclass() != mSubclass) || (device.getDeviceProtocol() != mProtocol) ) { return false; } /* if ((mManufacturerName != null && device.getManufacturerName() == null) || (mManufacturerName == null && device .getManufacturerName() != null) || (mProductName != null && device.getProductName() == null) || (mProductName == null && device.getProductName() != null) || (mSerialNumber != null && device.getSerialNumber() == null) || (mSerialNumber == null && device.getSerialNumber() != null)) { return (false); } */ /* if ((device.getManufacturerName() != null && !mManufacturerName .equals(device.getManufacturerName())) || (device.getProductName() != null && !mProductName .equals(device.getProductName())) || (device.getSerialNumber() != null && !mSerialNumber .equals(device.getSerialNumber()))) { return (false); } */ return true; } return false; }
Example 17
Source File: DeviceFilter.java From UVCCameraZxing with Apache License 2.0 | 4 votes |
@Override public boolean equals(final Object obj) { // can't compare if we have wildcard strings if (mVendorId == -1 || mProductId == -1 || mClass == -1 || mSubclass == -1 || mProtocol == -1) { return false; } if (obj instanceof DeviceFilter) { final DeviceFilter filter = (DeviceFilter) obj; if (filter.mVendorId != mVendorId || filter.mProductId != mProductId || filter.mClass != mClass || filter.mSubclass != mSubclass || filter.mProtocol != mProtocol) { return (false); } if ((filter.mManufacturerName != null && mManufacturerName == null) || (filter.mManufacturerName == null && mManufacturerName != null) || (filter.mProductName != null && mProductName == null) || (filter.mProductName == null && mProductName != null) || (filter.mSerialNumber != null && mSerialNumber == null) || (filter.mSerialNumber == null && mSerialNumber != null)) { return (false); } if ((filter.mManufacturerName != null && mManufacturerName != null && !mManufacturerName .equals(filter.mManufacturerName)) || (filter.mProductName != null && mProductName != null && !mProductName .equals(filter.mProductName)) || (filter.mSerialNumber != null && mSerialNumber != null && !mSerialNumber .equals(filter.mSerialNumber))) { return (false); } return (true); } if (obj instanceof UsbDevice) { final UsbDevice device = (UsbDevice) obj; if (device.getVendorId() != mVendorId || device.getProductId() != mProductId || device.getDeviceClass() != mClass || device.getDeviceSubclass() != mSubclass || device.getDeviceProtocol() != mProtocol) { return (false); } /* if ((mManufacturerName != null && device.getManufacturerName() == null) || (mManufacturerName == null && device .getManufacturerName() != null) || (mProductName != null && device.getProductName() == null) || (mProductName == null && device.getProductName() != null) || (mSerialNumber != null && device.getSerialNumber() == null) || (mSerialNumber == null && device.getSerialNumber() != null)) { return (false); } */ /* if ((device.getManufacturerName() != null && !mManufacturerName .equals(device.getManufacturerName())) || (device.getProductName() != null && !mProductName .equals(device.getProductName())) || (device.getSerialNumber() != null && !mSerialNumber .equals(device.getSerialNumber()))) { return (false); } */ return true; } return false; }
Example 18
Source File: DeviceFilter.java From DeviceConnect-Android with MIT License | 4 votes |
@Override public boolean equals(final Object obj) { // can't compare if we have wildcard strings if (mVendorId == -1 || mProductId == -1 || mClass == -1 || mSubclass == -1 || mProtocol == -1) { return false; } if (obj instanceof DeviceFilter) { final DeviceFilter filter = (DeviceFilter) obj; if (filter.mVendorId != mVendorId || filter.mProductId != mProductId || filter.mClass != mClass || filter.mSubclass != mSubclass || filter.mProtocol != mProtocol) { return false; } if ((filter.mManufacturerName != null && mManufacturerName == null) || (filter.mManufacturerName == null && mManufacturerName != null) || (filter.mProductName != null && mProductName == null) || (filter.mProductName == null && mProductName != null) || (filter.mSerialNumber != null && mSerialNumber == null) || (filter.mSerialNumber == null && mSerialNumber != null)) { return false; } if ((filter.mManufacturerName != null && mManufacturerName != null && !mManufacturerName .equals(filter.mManufacturerName)) || (filter.mProductName != null && mProductName != null && !mProductName .equals(filter.mProductName)) || (filter.mSerialNumber != null && mSerialNumber != null && !mSerialNumber .equals(filter.mSerialNumber))) { return false; } return (filter.isExclude != isExclude); } if (obj instanceof UsbDevice) { final UsbDevice device = (UsbDevice) obj; if (isExclude || (device.getVendorId() != mVendorId) || (device.getProductId() != mProductId) || (device.getDeviceClass() != mClass) || (device.getDeviceSubclass() != mSubclass) || (device.getDeviceProtocol() != mProtocol) ) { return false; } /* if ((mManufacturerName != null && device.getManufacturerName() == null) || (mManufacturerName == null && device .getManufacturerName() != null) || (mProductName != null && device.getProductName() == null) || (mProductName == null && device.getProductName() != null) || (mSerialNumber != null && device.getSerialNumber() == null) || (mSerialNumber == null && device.getSerialNumber() != null)) { return (false); } */ /* if ((device.getManufacturerName() != null && !mManufacturerName .equals(device.getManufacturerName())) || (device.getProductName() != null && !mProductName .equals(device.getProductName())) || (device.getSerialNumber() != null && !mSerialNumber .equals(device.getSerialNumber()))) { return (false); } */ return true; } return false; }
Example 19
Source File: DeviceFilter.java From AndroidUSBCamera with Apache License 2.0 | 4 votes |
@Override public boolean equals(final Object obj) { // can't compare if we have wildcard strings if (mVendorId == -1 || mProductId == -1 || mClass == -1 || mSubclass == -1 || mProtocol == -1) { return false; } if (obj instanceof DeviceFilter) { final DeviceFilter filter = (DeviceFilter) obj; if (filter.mVendorId != mVendorId || filter.mProductId != mProductId || filter.mClass != mClass || filter.mSubclass != mSubclass || filter.mProtocol != mProtocol) { return false; } if ((filter.mManufacturerName != null && mManufacturerName == null) || (filter.mManufacturerName == null && mManufacturerName != null) || (filter.mProductName != null && mProductName == null) || (filter.mProductName == null && mProductName != null) || (filter.mSerialNumber != null && mSerialNumber == null) || (filter.mSerialNumber == null && mSerialNumber != null)) { return false; } if ((filter.mManufacturerName != null && mManufacturerName != null && !mManufacturerName .equals(filter.mManufacturerName)) || (filter.mProductName != null && mProductName != null && !mProductName .equals(filter.mProductName)) || (filter.mSerialNumber != null && mSerialNumber != null && !mSerialNumber .equals(filter.mSerialNumber))) { return false; } return (filter.isExclude != isExclude); } if (obj instanceof UsbDevice) { final UsbDevice device = (UsbDevice) obj; if (isExclude || (device.getVendorId() != mVendorId) || (device.getProductId() != mProductId) || (device.getDeviceClass() != mClass) || (device.getDeviceSubclass() != mSubclass) || (device.getDeviceProtocol() != mProtocol) ) { return false; } /* if ((mManufacturerName != null && device.getManufacturerName() == null) || (mManufacturerName == null && device .getManufacturerName() != null) || (mProductName != null && device.getProductName() == null) || (mProductName == null && device.getProductName() != null) || (mSerialNumber != null && device.getSerialNumber() == null) || (mSerialNumber == null && device.getSerialNumber() != null)) { return (false); } */ /* if ((device.getManufacturerName() != null && !mManufacturerName .equals(device.getManufacturerName())) || (device.getProductName() != null && !mProductName .equals(device.getProductName())) || (device.getSerialNumber() != null && !mSerialNumber .equals(device.getSerialNumber()))) { return (false); } */ return true; } return false; }
Example 20
Source File: UsbIpService.java From USBIPServerForAndroid with GNU General Public License v3.0 | 4 votes |
private UsbDeviceInfo getInfoForDevice(UsbDevice dev, UsbDeviceConnection devConn) { UsbDeviceInfo info = new UsbDeviceInfo(); UsbIpDevice ipDev = new UsbIpDevice(); ipDev.path = dev.getDeviceName(); ipDev.busnum = deviceIdToBusNum(dev.getDeviceId()); ipDev.devnum = deviceIdToDevNum(dev.getDeviceId()); ipDev.busid = String.format("%d-%d", ipDev.busnum, ipDev.devnum); ipDev.idVendor = (short) dev.getVendorId(); ipDev.idProduct = (short) dev.getProductId(); ipDev.bcdDevice = -1; ipDev.bDeviceClass = (byte) dev.getDeviceClass(); ipDev.bDeviceSubClass = (byte) dev.getDeviceSubclass(); ipDev.bDeviceProtocol = (byte) dev.getDeviceProtocol(); ipDev.bConfigurationValue = 0; ipDev.bNumConfigurations = 1; ipDev.bNumInterfaces = (byte) dev.getInterfaceCount(); info.dev = ipDev; info.interfaces = new UsbIpInterface[ipDev.bNumInterfaces]; for (int i = 0; i < ipDev.bNumInterfaces; i++) { info.interfaces[i] = new UsbIpInterface(); UsbInterface iface = dev.getInterface(i); info.interfaces[i].bInterfaceClass = (byte) iface.getInterfaceClass(); info.interfaces[i].bInterfaceSubClass = (byte) iface.getInterfaceSubclass(); info.interfaces[i].bInterfaceProtocol = (byte) iface.getInterfaceProtocol(); } AttachedDeviceContext context = connections.get(dev.getDeviceId()); UsbDeviceDescriptor devDesc = null; if (context != null) { // Since we're attached already, we can directly query the USB descriptors // to fill some information that Android's USB API doesn't expose devDesc = UsbControlHelper.readDeviceDescriptor(context.devConn); ipDev.bcdDevice = devDesc.bcdDevice; ipDev.bNumConfigurations = devDesc.bNumConfigurations; } ipDev.speed = detectSpeed(dev, devDesc); return info; }