code: public boolean hasPermissionForPackage(UsbDevice device, String packageName) {
      List<UsbDevice> usbDevices = grantedPermissions.get(packageName);
      return usbDevices != null && usbDevices.contains(device);
    }
docs: Returns true if the given package has permission to access the device.