如何确定许可是否被授予,我找到了一个像这样的串行端口设备:
private void findSerialPortDevice() {
HashMap<String, UsbDevice> usbDevices = usbManager.getDeviceList();
HashMap<String, UsbDevice> usbDevices1 = new HashMap<String, UsbDevice>();
usbDevices1.clear();
if (!usbDevices.isEmpty()) {
boolean keep = true;
for (Map.Entry<String, UsbDevice> entry : usbDevices.entrySet()) {
device = entry.getValue();
int deviceVID = device.getVendorId();
int devicePID = device.getProductId();
if (deviceVID == 1659 && devicePID == 8963) {
requestUserPermission();
keep = false;
if (!keep)
break;
}
}
if (!keep) {
Intent intent = new Intent(ACTION_NO_USB);
sendBroadcast(intent);
}
} else {
Intent intent = new Intent(ACTION_NO_USB);
sendBroadcast(intent);
}
}