Guest User

Untitled

a guest
May 20th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. BroadcastReceiver mUsbReceiver = new BroadcastReceiver() {
  2. public void onReceive(Context context, Intent intent) {
  3. String action = intent.getAction();
  4.  
  5. Log.d(TAG, " onReceive " + action );
  6.  
  7. if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(action)) {
  8. UsbDevice device = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
  9. UsbInterface intf = findAdbInterface(device);
  10. if (intf != null) {
  11. log("Found adb interface " + intf);
  12. Log.d(TAG, "Found adb interface " + intf);
  13. setAdbInterface(device, intf);
  14. }
  15. } else if (UsbManager.ACTION_USB_DEVICE_DETACHED.equals(action)) {
  16. UsbDevice device = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
  17. String deviceName = device.getDeviceName();
  18. if (mDevice != null && mDevice.equals(deviceName)) {
  19. log("adb interface removed");
  20. Log.d(TAG, "adb removed interface " );
  21. setAdbInterface(null, null);
  22. }
  23. }
  24. }
  25. };
Add Comment
Please, Sign In to add comment