t->device_name = strdup(device_name);
}
+// check if device is tizen or android device.
+// return 1 if tizen device, return 2 if android device
int is_sdb_interface(int vendor_id, int usb_class, int usb_subclass, int usb_protocol)
{
/**
// && usb_protocol == SDB_INTERFACE_PROTOCOL) {
// return 1;
// }
-
- if ( usb_class == SDB_INTERFACE_CLASS && (usb_protocol == ADB_INTERFACE_PROTOCOL || usb_protocol == SDB_INTERFACE_PROTOCOL)) {
+ if ( usb_class == SDB_INTERFACE_CLASS ) {
+ if ( usb_subclass == SDB_INTERFACE_SUBCLASS && usb_protocol == SDB_INTERFACE_PROTOCOL )
return 1;
- }
-
+ else if ( usb_subclass == ADB_INTERFACE_SUBCLASS && usb_protocol == ADB_INTERFACE_PROTOCOL)
+ return 2;
+ }
return 0;
}
struct usb_interface_descriptor* usb_interface =
(struct usb_interface_descriptor *) desc_current_ptr;
- if (is_sdb_interface(usb_dev->idVendor,
+ int device_type;
+ if ((device_type = is_sdb_interface(usb_dev->idVendor,
usb_interface->bInterfaceClass,
usb_interface->bInterfaceSubClass,
- usb_interface->bInterfaceProtocol)
+ usb_interface->bInterfaceProtocol))
&& (USB_DT_INTERFACE_SIZE == bLength
&& USB_DT_INTERFACE == bType
&& 2 == usb_interface->bNumEndpoints)) {
unsigned char endpoint_out;
unsigned char interface = usb_interface->bInterfaceNumber;
- int bConfigurationValue = 2;
- int n = ioctl(fd, USBDEVFS_SETCONFIGURATION,
- &bConfigurationValue);
- if (n != 0) {
- LOG_DEBUG("check kernel is supporting %dth configuration\n", bConfigurationValue);
- }
- /*
- // TODO: removed!
- {
+ if(device_type == 2) {
+ int bConfigurationValue = 2;
+ int n = ioctl(fd, USBDEVFS_SETCONFIGURATION,
+ &bConfigurationValue);
+ if (n != 0) {
+ LOG_DEBUG("check kernel is supporting %dth configuration\n", bConfigurationValue);
+ }
+ } else {
int bConfigurationValue = 2;
int n = ioctl(fd, USBDEVFS_RESET);
if (n != 0) {
LOG_DEBUG("usb claim failed\n");
}
}
- */
// find in/out endpoint address
if ((endpoint1->bEndpointAddress & USB_ENDPOINT_DIR_MASK)