mirror of
				https://github.com/mik3y/usb-serial-for-android
				synced 2025-10-31 02:17:23 +00:00 
			
		
		
		
	Add ProbeDevice.
This commit is contained in:
		
							parent
							
								
									66eec6c870
								
							
						
					
					
						commit
						9c577949b0
					
				| @ -67,6 +67,22 @@ public class UsbSerialProber { | ||||
|         final List<UsbSerialDriver> result = new ArrayList<UsbSerialDriver>(); | ||||
| 
 | ||||
|         for (final UsbDevice usbDevice : usbManager.getDeviceList().values()) { | ||||
|             final UsbSerialDriver driver = probeDevice(usbDevice); | ||||
|             if (driver != null) { | ||||
|                 result.add(driver); | ||||
|             } | ||||
|         } | ||||
|         return result; | ||||
|     } | ||||
|      | ||||
|     /** | ||||
|      * Probes a single device for a compatible driver. | ||||
|      *  | ||||
|      * @param usbDevice the usb device to probe | ||||
|      * @return a new {@link UsbSerialDriver} compatible with this device, or | ||||
|      *         {@code null} if none available. | ||||
|      */ | ||||
|     public UsbSerialDriver probeDevice(final UsbDevice usbDevice) { | ||||
|         final int vendorId = usbDevice.getVendorId(); | ||||
|         final int productId = usbDevice.getProductId(); | ||||
| 
 | ||||
| @ -89,10 +105,9 @@ public class UsbSerialProber { | ||||
|             } catch (InvocationTargetException e) { | ||||
|                 throw new RuntimeException(e); | ||||
|             } | ||||
|                 result.add(driver); | ||||
|             return driver; | ||||
|         } | ||||
|         } | ||||
|         return result; | ||||
|         return null; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user