Revert "Add protocol to get the platform type of target."
authorSangJin Kim <sangjin3.kim@samsung.com>
Thu, 16 Jun 2016 08:37:12 +0000 (17:37 +0900)
committershingil.kang <shingil.kang@samsung.com>
Thu, 16 Jun 2016 09:11:53 +0000 (18:11 +0900)
This reverts commit ad69a055bb6b19bfdae2e5aa9f9203c1fe72c45f.

Change-Id: I9712dfe0d0a198cf3a7e7c4290dfccc82aed1b64
Signed-off-by: Shingil Kang <shingil.kang@samsung.com>
src/common_modules.h
src/sdb_usb.h
src/sockets.c
src/transport.c
src/transport.h
src/transport_local.c
src/transport_usb.c
src/usb_darwin.c
src/usb_linux.c
src/usb_windows.c

index 68a7ee74e3412b42534d1ee261a44a4bba5a974d..876366093f11e94b9a7910f53946d7ce24b46282 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "linkedlist.h"
 #include "fdevent.h"
+#include "sdb_usb.h"
 #include "fdevent.h"
 
 #define MAX_PAYLOAD_V1  (4*1024)
@@ -104,15 +105,6 @@ typedef enum transport_type {
 //kTransportRemoteDevCon
 } transport_type;
 
-typedef enum platform_type {
-    PLATFORM_UNKNOWN,
-    PLATFORM_TIZEN,
-    PLATFORM_ANDROID,
-} platform_type;
-
-#define PLATFORM_STR_UNKNOWN "unknown"
-#define PLATFORM_STR_TIZEN "tizen"
-#define PLATFORM_STR_ANDROID "android"
 
 struct transport {
        LIST_NODE* node;
@@ -210,8 +202,6 @@ struct atransport
        int suspended;
        char host[20];
        char *device_name;
-
-       platform_type platform;
 };
 
 
index cb02e652b73761c8605a6f7339886222fb5d0283..db62e725760f93cde5055978599a65d09e107ab4 100755 (executable)
@@ -4,7 +4,6 @@
 
 
 #include <limits.h>
-#include "common_modules.h"
 extern int g_only_detect_tizen_device;
 
 // should bo implements for each os type
@@ -20,7 +19,7 @@ int     sdb_usb_read(usb_handle *h, void *data, int len);
 int     sdb_usb_close(usb_handle *h);
 void    sdb_usb_kick(usb_handle *h);
 
-platform_type     get_platform_type(int vendor_id, int usb_class, int usb_subclass, int usb_protocol);
+int     is_sdb_interface(int vendor_id, int usb_class, int usb_subclass, int usb_protocol);
 int     is_device_registered(const char *node_path);
 void*   usb_poll_thread(void* sleep_msec);
 void    kick_disconnected_devices();
index 983ef18e9693a2446c98ecae3f32048aae5196b1..90265d43583a0030c9fe2fce30d02385e5603356 100755 (executable)
@@ -831,12 +831,6 @@ sendfail:
         sendokmsg(socket->fd, state);
         return 0;
     }
-    else if(!strncmp(service, "get-platform", strlen("get-platform"))) {
-        const char *platform_type = platform_type_name(t);
-        sendokmsg(socket->fd, platform_type);
-        return 0;
-    }
-
 #ifdef MAKE_DEBUG
     else if(!strncmp(service, "send-packet", strlen("send-packet"))) {
         char data[MAX_PAYLOAD_V1] = {'1', };
@@ -1182,6 +1176,7 @@ static int handle_host_request(char *service, SDB_SOCKET* socket)
        sdb_write(socket->fd, "OKAY", 4);
        exit(0);
    }
+
     return -1;
 }
 
index e408eaa9fabb4fbdf65440a99e2ed4adcff0e1d7..0224f912cbefd041652c6224b55e80903e2213f2 100755 (executable)
@@ -1019,21 +1019,6 @@ const char *connection_state_name(TRANSPORT *t)
     return STATE_UNKNOWN;
 }
 
-const char *platform_type_name(TRANSPORT *t)
-{
-    if(t != NULL) {
-        int state = t->platform;
-
-        if(state == PLATFORM_TIZEN) {
-            return PLATFORM_STR_TIZEN;
-        }
-        if(state == PLATFORM_ANDROID) {
-            return PLATFORM_STR_ANDROID;
-        }
-    }
-    return PLATFORM_STR_UNKNOWN;
-}
-
 PACKET *get_apacket(void)
 {
     PACKET *p = malloc(sizeof(PACKET));
index b29b920693765c9459a61d9b9ea04e02e263d957..af3c11987bbf08455ff959b70109a529ce004f59 100755 (executable)
@@ -61,7 +61,7 @@ const char *connection_state_name(TRANSPORT *t);
 PACKET *get_apacket(void);
 void put_apacket(void *p);
 void register_socket_transport(int s, const char *serial, char* host, int port, transport_type ttype, const char *device_name);
-void register_usb_transport(usb_handle *usb, const char *serial, platform_type platform);
+void register_usb_transport(usb_handle *usb, const char *serial);
 int register_device_con_transport(int s, const char *serial);
 void send_cmd(unsigned arg0, unsigned arg1, unsigned cmd, char* data, TRANSPORT* t);
 void close_usb_devices();
index 2100533b65ffd90b7d5fba8eacbcdc66266a2e40..5e4502c0eea4f830eefa4eea1b3efc1f65440804 100755 (executable)
@@ -254,7 +254,6 @@ void register_socket_transport(int s, const char *serial, char* host, int port,
     t->sdb_port = port;
     t->suspended = 0;
     t->type = ttype;
-    t->platform = PLATFORM_TIZEN;
     //TODO REMOTE_DEVICE_CONNECT
 //    t->remote_cnxn_socket = NULL;
 
index a89ed052b32960e3224433b5209b3ec97e005e4b..5491421f64104ec38433223052cbd0eb6c04bf0b 100755 (executable)
@@ -23,7 +23,6 @@
 #include "utils.h"
 #define  TRACE_TAG  TRACE_TRANSPORT
 #include "sdb_usb.h"
-#include "common_modules.h"
 #include "transport.h"
 
 static int remote_read(TRANSPORT* t, void* data, int len)
@@ -99,7 +98,7 @@ static int get_connected_device_count(transport_type type)
     return cnt;
 }
 
-void register_usb_transport(usb_handle *usb, const char *serial, platform_type platform)
+void register_usb_transport(usb_handle *usb, const char *serial)
 {
     TRANSPORT *t = calloc(1, sizeof(TRANSPORT));
     char device_name[256];
@@ -119,7 +118,6 @@ void register_usb_transport(usb_handle *usb, const char *serial, platform_type p
     t->req = 0;
     t->res = 0;
     t->suspended = 0;
-    t->platform = platform;
 
     if(serial) {
         t->serial = strdup(serial);
@@ -133,27 +131,29 @@ void register_usb_transport(usb_handle *usb, const char *serial, platform_type p
     t->device_name = strdup(device_name);
 }
 
-/* get the platform type of usb device.
-*  returns PLATFORM_TIZEN if tizen device, PLATFORM_ANDROID if android device.
-*  otherwise, returns PLATFORM_UNKNOWN.
-*/
-platform_type get_platform_type(int vendor_id, int usb_class, int usb_subclass, int usb_protocol)
+// 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)
 {
     /**
      * TODO: find easy way to add usb devices vendors
      */
+//    if (vendor_id == VENDOR_ID_SAMSUNG && usb_class == SDB_INTERFACE_CLASS && usb_subclass == SDB_INTERFACE_SUBCLASS
+//            && usb_protocol == SDB_INTERFACE_PROTOCOL) {
+//        return 1;
+//    }
     if ( usb_class == SDB_INTERFACE_CLASS ) {
         if ( usb_subclass == SDB_INTERFACE_SUBCLASS && usb_protocol == SDB_INTERFACE_PROTOCOL )
-            return PLATFORM_TIZEN;
+            return 1;
         if (g_only_detect_tizen_device) {
             D("only detect tizen device !\n");
-            return PLATFORM_UNKNOWN;
+            return 0;
         } else {
             if (usb_subclass == ADB_INTERFACE_SUBCLASS && usb_protocol == ADB_INTERFACE_PROTOCOL)
-                return PLATFORM_ANDROID;
+                return 2;
         }
     }
-    return PLATFORM_UNKNOWN;
+    return 0;
 }
 
 void close_usb_devices()
index 6dcef3822762601ebc735d20a87e877573859ee5..20456acd61604e29e1dcff8044b7a00159e3bb90 100755 (executable)
@@ -132,7 +132,7 @@ kern_return_t getUSBSerial(IOUSBDeviceInterface182 **dev, UInt8 string_id, char
     return kr;
 }
 
-void register_usb(IOUSBDeviceInterface182 **dev, usb_handle *handle, platform_type platform) {
+void register_usb(IOUSBDeviceInterface182 **dev, usb_handle *handle) {
     IOReturn ior;
     kern_return_t kr;
     UInt8 serialIndex;
@@ -150,7 +150,7 @@ void register_usb(IOUSBDeviceInterface182 **dev, usb_handle *handle, platform_ty
         LOG_ERROR("couldn't get usb serial\n");
     }
 
-    register_usb_transport(handle, serial, platform);
+    register_usb_transport(handle, serial);
 
     // Register for an interest notification of this device being removed.
     // Pass the reference to our private data as the refCon for the notification.
@@ -173,13 +173,12 @@ UInt8 find_sdb_interface_by_looping_configuration(IOUSBDeviceInterface182 **dev,
     kern_return_t kr;
     UInt8 totalConfigNum = 0;
     UInt8 configNum;
-    platform_type platform;
 
     // find SDB interface in current configuration
-    ior = FindSDBInterface(dev, handle, &platform);
+    ior = FindSDBInterface(dev, handle);
     if (!ior) {
         LOG_DEBUG("found tizen device and register usb transport.........\n");
-        register_usb(dev, handle, platform);
+        register_usb(dev, handle);
         return 0;
     }
 
@@ -224,11 +223,11 @@ UInt8 find_sdb_interface_by_looping_configuration(IOUSBDeviceInterface182 **dev,
             } else {
                 LOG_DEBUG("set configuration to %d\n", sdb_configuration);
                 // find SDB interface in configuration
-                if (FindSDBInterface(dev, handle, &platform) != 0)
+                if (FindSDBInterface(dev, handle) != 0)
                     continue;
                 else {
                     LOG_DEBUG("found SDB interface in configuration: %d\n", sdb_configuration);
-                    register_usb(dev, handle, platform);
+                    register_usb(dev, handle);
                     kr = (*dev)->USBDeviceClose(dev);
                     return 0;
                 }
@@ -240,7 +239,7 @@ UInt8 find_sdb_interface_by_looping_configuration(IOUSBDeviceInterface182 **dev,
 }
 
 IOReturn FindSDBInterface(IOUSBDeviceInterface **device,
-        usb_handle* handle, platform_type* platform_type_ptr) {
+        usb_handle* handle) {
     IOReturn kr = -1;
     IOUSBFindInterfaceRequest request;
     io_iterator_t iterator;
@@ -308,13 +307,10 @@ IOReturn FindSDBInterface(IOUSBDeviceInterface **device,
                 interfaceClass, interfaceSubClass, intfProtocol);
 
         //Check if interface is sdb interface
-        platform_type platform_type_temp = get_platform_type(VENDOR_ID_SAMSUNG, interfaceClass, interfaceSubClass, intfProtocol);
-        if (platform_type_temp == PLATFORM_UNKNOWN) {
+        if (!is_sdb_interface(VENDOR_ID_SAMSUNG, interfaceClass, interfaceSubClass, intfProtocol)) {
             LOG_DEBUG("it is not sdb interface\n");
             (*interface)->Release(interface);
             continue;
-        } else {
-            *platform_type_ptr = platform_type_temp;
         }
 
         // get number of end points
index 005f222907922a49e0d0f2d5c11a630c1392a019..7d48558a0bd63981b2f0a5281bf9d05a262722e1 100644 (file)
@@ -193,11 +193,11 @@ int register_device(const char* node, const char* serial) {
             struct usb_interface_descriptor* usb_interface =
                     (struct usb_interface_descriptor *) desc_current_ptr;
 
-            platform_type platform= get_platform_type(usb_dev->idVendor,
-                                usb_interface->bInterfaceClass,
-                                usb_interface->bInterfaceSubClass,
-                                usb_interface->bInterfaceProtocol);
-            if ((platform != PLATFORM_UNKNOWN)
+            int device_type;
+            if ((device_type = is_sdb_interface(usb_dev->idVendor,
+                    usb_interface->bInterfaceClass,
+                    usb_interface->bInterfaceSubClass,
+                    usb_interface->bInterfaceProtocol))
                     && (USB_DT_INTERFACE_SIZE == bLength
                             && USB_DT_INTERFACE == bType
                             && 2 == usb_interface->bNumEndpoints)) {
@@ -213,7 +213,7 @@ int register_device(const char* node, const char* serial) {
                 unsigned char endpoint_out;
                 unsigned char interface = usb_interface->bInterfaceNumber;
 
-                if(platform == PLATFORM_ANDROID) {
+                if(device_type == 2) {
                                        int bConfigurationValue = 2;
                                        int n = ioctl(fd, USBDEVFS_SETCONFIGURATION,
                                                                                                &bConfigurationValue);
@@ -284,7 +284,7 @@ int register_device(const char* node, const char* serial) {
                     LOG_DEBUG("-register new device (in: %04x, out: %04x) from %s\n", usb->end_point[0], usb->end_point[1], node);
 
                     is_registered = 1;
-                    register_usb_transport(usb, usb_serial, platform);
+                    register_usb_transport(usb, usb_serial);
                     sdb_mutex_unlock(&usb_lock, "usb register unlocked");
                 }
                 desc_current_ptr += endpoint2->bLength;
index abff3c0effb1009b1ed61ec0ba06f75d376aff9a..b6731657ec11bc031d7aa1627d0398185d0ab4f2 100644 (file)
@@ -71,7 +71,7 @@ struct usb_handle {
     UCHAR end_point[2];
     unsigned int zero_mask;
 };
-usb_handle *usb_open(const char *device_path, platform_type *platform);
+usb_handle *usb_open(const char *device_path);
 int win_usb_close(usb_handle *dev);
 int usb_get_string_simple(usb_handle *dev, int index, char *buf, size_t buflen);
 void *device_poll_thread(void* unused);
@@ -161,7 +161,7 @@ int is_device_registered(const char *node_path)
     return r;
 }
 
-usb_handle *usb_open(const char *device_path, platform_type *platform_type_ptr) {
+usb_handle *usb_open(const char *device_path) {
     // Allocate storage for handles
     usb_handle* usb = calloc(1, sizeof(usb_handle));
     s_strncpy(usb->unique_node_path, device_path, sizeof(usb->unique_node_path));
@@ -208,11 +208,9 @@ usb_handle *usb_open(const char *device_path, platform_type *platform_type_ptr)
         return NULL;
     }
 
-    platform_type platform_type_temp = get_platform_type(usb_device_descriptor.idVendor, usb_interface_descriptor.bInterfaceClass, usb_interface_descriptor.bInterfaceSubClass, usb_interface_descriptor.bInterfaceProtocol);
-    if (platform_type_temp == PLATFORM_UNKNOWN) {
+    if (!is_sdb_interface(usb_device_descriptor.idVendor, usb_interface_descriptor.bInterfaceClass, usb_interface_descriptor.bInterfaceSubClass,
+            usb_interface_descriptor.bInterfaceProtocol)) {
         return NULL;
-    } else {
-        *platform_type_ptr = platform_type_temp;
     }
     UCHAR endpoint_index = 0;
 
@@ -373,14 +371,13 @@ int usb_find_devices(GUID deviceClassID) {
         SAFE_FREE(detailData);
 
         if (!is_device_registered(devicePath)) {
-            platform_type platform;
-            struct usb_handle *hnd = usb_open(devicePath, &platform);
+            struct usb_handle *hnd = usb_open(devicePath);
             if (hnd != NULL) {
                 char serial[MAX_SERIAL_NAME]={0,};
                 if (get_serial_number(hnd, serial, sizeof(serial)) > 0) {
                     LOG_DEBUG("register usb for: %s\n", serial);
                     if (register_device(hnd)) {
-                        register_usb_transport(hnd, serial, platform);
+                        register_usb_transport(hnd, serial);
                     } else {
                         LOG_DEBUG("fail to register usb\n");
                         win_usb_close(hnd);