public UsbDeviceAssert hasDeviceId(int id) { isNotNull(); int actualId = actual.getDeviceId(); assertThat(actualId) // .overridingErrorMessage("Expected device id <%s> but was <%s>.", id, actualId) // .isEqualTo(id); return this; }
@Override public boolean equals(Object obj) { UsbDeviceStatus usbDeviceStatus= (UsbDeviceStatus) obj; return usbDeviceStatus.usbDevice.getDeviceId() == usbDevice.getDeviceId(); } }
public int getDeviceId(){ return device.getDeviceId(); }
private String getRootId(UsbDevice usbDevice) { return ROOT_ID_USB + Integer.toString(usbDevice.getDeviceId()); }
@Override public String toString() { return String.format("<%s device_name=%s device_id=%s port_number=%s>", getClass().getSimpleName(), mDevice.getDeviceName(), mDevice.getDeviceId(), mPortNumber); }
@Override public String toString() { return String.format("<%s device_name=%s device_id=%s port_number=%s>", getClass().getSimpleName(), mDevice.getDeviceName(), mDevice.getDeviceId(), mPortNumber); }
@Override public String toString() { return String.format("<%s device_name=%s device_id=%s port_number=%s>", getClass().getSimpleName(), mDevice.getDeviceName(), mDevice.getDeviceId(), mPortNumber); }
UsbManager usbManager = (UsbManager) getSystemService(USB_SERVICE); HashMap<String, UsbDevice> devicelist = usbManager.getDeviceList(); Iterator<UsbDevice> deviceIterator = devicelist.values().iterator(); while(deviceIterator.hasNext()) { UsbDevice usbDevice = deviceIterator.next(); Log.i(Log_Tag, "Model : " +usbDevice.getDeviceName()); Log.i(Log_Tag, "Id : " +usbDevice.getDeviceId()); }
@Override public String toString() { return String.format("<%s device_name=%s device_id=%s port_number=%s>", getClass().getSimpleName(), mDevice.getDeviceName(), mDevice.getDeviceId(), mPortNumber); }
public UsbDeviceAssert hasDeviceId(int id) { isNotNull(); int actualId = actual.getDeviceId(); assertThat(actualId) // .overridingErrorMessage("Expected device id <%s> but was <%s>.", id, actualId) // .isEqualTo(id); return this; }
/** * Delete HVC-P Device. * @param device device */ public void removeUSBDevice(final UsbDevice device) { HVCCameraInfo camera = mServices.remove("" + device.getDeviceId() + "_" + device.getProductId() + "_" + device.getVendorId()); if (camera != null) { // デバイスとの接続切断を通知. notifyOnDisconnected(camera); } }
@Override public void onReceive(Context context, Intent intent) { if (intent == null) { return; } String action = intent.getAction(); if (BuildConfig.DEBUG) { Log.d(TAG, "action:" + action); } UsbDevice device = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) { HVCCameraInfo camera = new HVCCameraInfo("" + device.getDeviceId() + "_" + device.getProductId() + "_" + device.getVendorId(), "HVC-P:" + "" + device.getDeviceId() + "_" + device.getProductId() + "_" + device.getVendorId()); mServices.put(camera.getID(), camera); // デバイスとの接続完了を通知. notifyOnConnected(camera); HVCManager.INSTANCE.init(context); if (BuildConfig.DEBUG) { Log.d(TAG, "device:true:" + device.getDeviceId()); } } else { if (BuildConfig.DEBUG) { Log.d(TAG, "device:false"); } } } };
public boolean disconnectDevice(UsbDevice usbDevice){ Optional<UsbSerialDevice> optionalDevice = Stream.of(serialDevices) .filter(p -> usbDevice.getDeviceId() == p.getDeviceId()) .findSingle(); if(optionalDevice.isPresent()){ UsbSerialDevice disconnectedDevice = optionalDevice.get(); disconnectedDevice.syncClose(); serialDevices = Utils.removeIf(serialDevices, p -> usbDevice.getDeviceId() == p.getDeviceId()); return true; } return false; }
@NonNull @Override public Info getDeviceInfo() { if (cachedInfo != null) { return cachedInfo; } UsbDevice usbDevice = null; for (final MidiInputDevice midiInputDevice : transmitters.keySet()) { usbDevice = midiInputDevice.getUsbDevice(); break; } if (usbDevice == null) { for (final MidiOutputDevice midiOutputDevice : receivers.keySet()) { usbDevice = midiOutputDevice.getUsbDevice(); break; } } if (usbDevice == null) { // XXX returns `null` information return cachedInfo = new Info("(null)", "(null)", "(null)", "(null)"); } return cachedInfo = new Info(usbDevice.getDeviceName(), // String.format("vendorId: %x, productId: %x", usbDevice.getVendorId(), usbDevice.getProductId()), // "deviceId:" + usbDevice.getDeviceId(), // usbDevice.getDeviceName()); }