(UsbDevice device)
| 289 | } |
| 290 | |
| 291 | private synchronized void addAvailable(UsbDevice device) { |
| 292 | if (!isSupported(device)) |
| 293 | return; |
| 294 | |
| 295 | final int n = device.getInterfaceCount(); |
| 296 | final UsbDeviceInterface[] existing = new UsbDeviceInterface[n]; |
| 297 | |
| 298 | /* just in case there are old versions of this device in the list |
| 299 | (shouldn't happen, but who knows), update them */ |
| 300 | for (Iterator<UsbDeviceInterface> iter = interfaces.iterator(); |
| 301 | iter.hasNext();) { |
| 302 | UsbDeviceInterface iface = iter.next(); |
| 303 | if (!iface.isDevice(device)) |
| 304 | continue; |
| 305 | |
| 306 | if (iface.iface < n) { |
| 307 | /* update the existing instance */ |
| 308 | existing[iface.iface] = iface; |
| 309 | iface.onConnect(device); |
| 310 | } else { |
| 311 | /* this interface index doesn't exist anymore, remove it */ |
| 312 | iface.onDisconnect(); |
| 313 | iter.remove(); |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | for (int iface=0; iface < n; iface++) { |
| 318 | if (existing[iface] != null) |
| 319 | /* still exists */ |
| 320 | continue; |
| 321 | |
| 322 | int iclass = device.getInterface(iface).getInterfaceClass(); |
| 323 | if (iclass == UsbConstants.USB_CLASS_VENDOR_SPEC || iclass == UsbConstants.USB_CLASS_CDC_DATA) { |
| 324 | UsbDeviceInterface deviface = new UsbDeviceInterface(device, iface); |
| 325 | interfaces.add(deviface); |
| 326 | broadcastDetectedDeviceInterface(deviface); |
| 327 | } |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | private synchronized UsbDeviceInterface getAvailable(String id) { |
| 332 | for (UsbDeviceInterface i : interfaces) |
no test coverage detected