获取 FileDescriptor
// get FileDescriptor by Android USB Host API
UsbManager manager = (UsbManager) mContext.getSystemService(Context.USB_SERVICE);
final String ACTION_USB_PERMISSION = "com.android.example.USB_PERMISSION";
HashMap deviceList = manager.getDeviceList();
Iterator deviceIterator = deviceList.values().iterator();
PendingIntent mPermissionIntent = PendingIntent.getBroadcast(mContext, 0,
new Intent(ACTION_USB_PERMISSION), 0);
IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
mContext.registerReceiver(mUsbReceiver, filter);
int fd = -1;
while(deviceIterator.hasNext()){
UsbDevice device = deviceIterator.next();
Log.i(TAG, device.getDeviceName() + " " + Integer.toHexString(device.getVendorId()) +
" " + Integer.toHexString(device.ge