sdb: do not init usb protocol is the profile is TV 21/50721/3 accepted/tizen/mobile/20151117.005522 accepted/tizen/tv/20151117.005534 accepted/tizen/wearable/20151117.005548 submit/tizen/20151116.102124 submit/tizen/20151116.102135 submit/tizen_common/20151229.142028 submit/tizen_common/20151229.144031 submit/tizen_common/20151229.154718
authortaeyoung <ty317.kim@samsung.com>
Fri, 30 Oct 2015 08:57:28 +0000 (17:57 +0900)
committertaeyoung <ty317.kim@samsung.com>
Mon, 16 Nov 2015 09:02:47 +0000 (18:02 +0900)
- In the TV target, there is no usb connection for sdb.
  Thus usb protocol init operation should be removed

Change-Id: I4d2d6cd631d39468ab283eb47d8502ad04f7aa45
Signed-off-by: taeyoung <ty317.kim@samsung.com>
packaging/sdbd_tcp.service
src/sdb.c
src/sdb.h
src/usb_funcfs_client.c

index 15b4c8a..4ded27c 100644 (file)
@@ -8,4 +8,4 @@ Environment=DISPLAY=:0
 PIDFile=/tmp/.sdbd.pid
 RemainAfterExit=yes
 SmackProcessLabel=User
-ExecStart=/usr/sbin/sdbd --listen=26101
+ExecStart=/usr/sbin/sdbd --listen-port=26101
index 44a2144..8b9f7cc 100644 (file)
--- a/src/sdb.c
+++ b/src/sdb.c
@@ -1166,9 +1166,44 @@ static void init_sdk_requirements() {
 }
 #endif /* !SDB_HOST */
 
+static void get_plugin_capability(void)
+{
+       int len;
+       char *usb_state;
+       char *sock_state;
+
+       if (is_emulator())
+               usb_state = SDBD_CAP_RET_DISABLED;
+       else
+               usb_state = SDBD_CAP_RET_ENABLED;
+
+       sock_state = SDBD_CAP_RET_ENABLED;
+
+       len = sizeof(g_capabilities.usbproto_support);
+       snprintf(g_capabilities.usbproto_support, len,
+                       "%s", usb_state);
+
+       len = sizeof(g_capabilities.sockproto_support);
+       snprintf(g_capabilities.sockproto_support, len,
+                       "%s", sock_state);
+}
+
+static int is_support_usbproto()
+{
+       return (!strncmp(g_capabilities.usbproto_support,
+                               SDBD_CAP_RET_ENABLED, strlen(SDBD_CAP_RET_ENABLED)));
+}
+
+static int is_support_sockproto()
+{
+       return (!strncmp(g_capabilities.sockproto_support,
+                               SDBD_CAP_RET_ENABLED, strlen(SDBD_CAP_RET_ENABLED)));
+}
+
 int sdb_main(int is_daemon, int server_port)
 {
 #if !SDB_HOST
+    get_plugin_capability();
     init_drop_privileges();
     init_sdk_requirements();
     umask(000);
@@ -1241,34 +1276,37 @@ int sdb_main(int is_daemon, int server_port)
         }
     }
 
-    if (!is_emulator()) {
-        /* choose the usb gadget backend */
-        if (access(USB_NODE_FILE, F_OK) == 0) {
-            /* legacy kernel-based sdb gadget */
-            usb_init =    &linux_usb_init;
-            usb_cleanup = &linux_usb_cleanup;
-            usb_write =   &linux_usb_write;
-            usb_read =    &linux_usb_read;
-            usb_close =   &linux_usb_close;
-            usb_kick =    &linux_usb_kick;
-        } else {
-            /* functionfs based gadget */
-            usb_init =    &ffs_usb_init;
-            usb_cleanup = &ffs_usb_cleanup;
-            usb_write =   &ffs_usb_write;
-            usb_read =    &ffs_usb_read;
-            usb_close =   &ffs_usb_close;
-            usb_kick =    &ffs_usb_kick;
-        }
-        // listen on USB
-        usb_init();
-    }
-
-    /* by default don't listen on local transport but
-     * listen if suitable command line argument has been provided */
-    if (sdbd_commandline_args.sdbd_port >= 0) {
-        local_init(sdbd_commandline_args.sdbd_port);
-    }
+       if (is_support_usbproto()) {
+           if (!is_emulator()) {
+               /* choose the usb gadget backend */
+               if (access(USB_NODE_FILE, F_OK) == 0) {
+                   /* legacy kernel-based sdb gadget */
+                   usb_init =    &linux_usb_init;
+                   usb_cleanup = &linux_usb_cleanup;
+                   usb_write =   &linux_usb_write;
+                   usb_read =    &linux_usb_read;
+                   usb_close =   &linux_usb_close;
+                   usb_kick =    &linux_usb_kick;
+               } else {
+                   /* functionfs based gadget */
+                   usb_init =    &ffs_usb_init;
+                   usb_cleanup = &ffs_usb_cleanup;
+                   usb_write =   &ffs_usb_write;
+                   usb_read =    &ffs_usb_read;
+                   usb_close =   &ffs_usb_close;
+                   usb_kick =    &ffs_usb_kick;
+               }
+               // listen on USB
+               usb_init();
+           }
+       }
+
+       if (is_support_sockproto()) {
+               /* by default don't listen on local transport but
+                * listen if suitable command line argument has been provided */
+               if (sdbd_commandline_args.sdbd_port >= 0)
+                       local_init(sdbd_commandline_args.sdbd_port);
+       }
 
 #if 0 /* tizen specific */
     D("sdb_main(): pre init_jdwp()\n");
index 923fdec..da25ab1 100644 (file)
--- a/src/sdb.h
+++ b/src/sdb.h
@@ -228,6 +228,15 @@ struct alistener
     adisconnect  disconnect;
 };
 
+#define SDBD_CAP_RET_ENABLED  "enabled"
+#define SDBD_CAP_RET_DISABLED "disabled"
+#define CAPBUF_ITEMSIZE 32
+typedef struct platform_capabilities
+{
+       char usbproto_support[CAPBUF_ITEMSIZE];     // enabled or disabled
+       char sockproto_support[CAPBUF_ITEMSIZE];    // enabled or disabled
+} pcap;
+pcap g_capabilities;
 
 void print_packet(const char *label, apacket *p);
 
index af9fd2b..dd2abf6 100644 (file)
@@ -475,7 +475,7 @@ void ffs_usb_init()
 
     h = calloc(1, sizeof(usb_handle));
     if (autoconfig(h) < 0) {
-        fatal_errno("[ can't recognize usb FunctionFS bulk device ]\n");
+        perror("[ can't recognize usb FunctionFS bulk device ]\n");
         free(h);
         return;
     }