SDB: separated android, tizen device when being detected
authorshingil.kang <shingil.kang@samsung.com>
Thu, 12 Mar 2015 03:33:20 +0000 (12:33 +0900)
committerDongkyun Yun <dk77.yun@samsung.com>
Tue, 21 Jul 2015 05:15:52 +0000 (14:15 +0900)
Change-Id: I40ffb298efd9121a0ffc33748e4802643bc4a962
Signed-off-by: shingil.kang <shingil.kang@samsung.com>
src/transport_usb.c
src/usb_linux.c

index c20943bcbaeb9d700816d2e66ff95eb13419f76f..4c8b06471f8b2fd18e5bd8d86aba9b7bf6425656 100755 (executable)
@@ -132,6 +132,8 @@ void register_usb_transport(usb_handle *usb, const char *serial)
     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)
 {
     /**
@@ -141,11 +143,12 @@ int is_sdb_interface(int vendor_id, int usb_class, int usb_subclass, int usb_pro
 //            && 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;
 }
 
index c692732c8765629f6f10f0a636ef50d1e5e20e54..25f1bb66e055a450f1097c49cfc63fec03c4dd34 100644 (file)
@@ -185,10 +185,11 @@ int register_device(const char* node, const char* serial) {
             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)) {
@@ -204,15 +205,14 @@ int register_device(const char* node, const char* serial) {
                 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) {
@@ -229,7 +229,6 @@ int register_device(const char* node, const char* serial) {
                         LOG_DEBUG("usb claim failed\n");
                     }
                 }
-                */
 
                 // find in/out endpoint address
                 if ((endpoint1->bEndpointAddress & USB_ENDPOINT_DIR_MASK)