|
|
@ -181,6 +181,7 @@ public final class USBMonitor { |
|
|
|
mPermissionIntent = PendingIntent.getBroadcast(context, 0, new Intent(ACTION_USB_PERMISSION), 0); |
|
|
|
final IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); |
|
|
|
// ACTION_USB_DEVICE_ATTACHED never comes on some devices so it should not be added here
|
|
|
|
filter.addAction(ACTION_USB_DEVICE_ATTACHED); |
|
|
|
filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED); |
|
|
|
context.registerReceiver(mUsbReceiver, filter); |
|
|
|
} |
|
|
@ -311,7 +312,15 @@ public final class USBMonitor { |
|
|
|
final HashMap<String, UsbDevice> deviceList = mUsbManager.getDeviceList(); |
|
|
|
// store those devices info before matching filter xml file
|
|
|
|
String fileName = Environment.getExternalStorageDirectory()+ "/USBCamera/failed_devices.txt"; |
|
|
|
|
|
|
|
File logFile = new File(fileName); |
|
|
|
if(! logFile.exists()) { |
|
|
|
try { |
|
|
|
logFile.createNewFile(); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
FileWriter fw = null; |
|
|
|
PrintWriter pw = null; |
|
|
|
final List<UsbDevice> result = new ArrayList<UsbDevice>(); |
|
|
|