Revert "Add the appcmd protocol for product extended routine."
[sdk/target/sdbd.git] / src / sdb.h
index 9cef525..5d7bd94 100644 (file)
--- a/src/sdb.h
+++ b/src/sdb.h
@@ -23,7 +23,6 @@
 
 #include "transport.h"  /* readx(), writex() */
 #include "fdevent.h"
-#include "sdbd_plugin.h"
 #if !SDB_HOST
 #include "commandline_sdbd.h"
 #endif
@@ -240,11 +239,12 @@ typedef struct platform_info {
 
 #define ENABLED "enabled"
 #define DISABLED "disabled"
-#define CPUARCH_ARMV6 "armv6"
-#define CPUARCH_ARMV7 "armv7"
-#define CPUARCH_X86 "x86"
 #define CAPBUF_SIZE 4096
 #define CAPBUF_ITEMSIZE 32
+#define CAPBUF_L_ITEMSIZE 256
+#define CAPBUF_LL_ITEMSIZE PATH_MAX
+#define SDBD_CAP_VERSION_MAJOR 1
+#define SDBD_CAP_VERSION_MINOR 0
 typedef struct platform_capabilities
 {
     char secure_protocol[CAPBUF_ITEMSIZE];      // enabled or disabled
@@ -257,23 +257,22 @@ typedef struct platform_capabilities
     char usbproto_support[CAPBUF_ITEMSIZE];     // enabled or disabled
     char sockproto_support[CAPBUF_ITEMSIZE];    // enabled or disabled
 
+    char log_enable[CAPBUF_ITEMSIZE];    // enabled or disabled
+    char log_path[CAPBUF_LL_ITEMSIZE];    // path of sdbd log
+
     char cpu_arch[CAPBUF_ITEMSIZE];             // cpu architecture (ex. x86)
     char profile_name[CAPBUF_ITEMSIZE];         // profile name (ex. mobile)
     char vendor_name[CAPBUF_ITEMSIZE];          // vendor name (ex. Tizen)
+    char sdk_toolpath[CAPBUF_L_ITEMSIZE];       // sdk tool path
+    char can_launch[CAPBUF_L_ITEMSIZE];         // target name
 
     char platform_version[CAPBUF_ITEMSIZE];     // platform version (ex. 2.3.0)
     char product_version[CAPBUF_ITEMSIZE];      // product version (ex. 1.0)
     char sdbd_version[CAPBUF_ITEMSIZE];         // sdbd version
     char sdbd_plugin_version[CAPBUF_ITEMSIZE];  // sdbd plugin version
+    char sdbd_cap_version[CAPBUF_ITEMSIZE];     // capability version
 } pcap;
-pcap g_capabilities;
-
-#define SDBD_PLUGIN_PATH    "/usr/lib/libsdbd_plugin.so"
-#define SDBD_PLUGIN_INTF    "sdbd_plugin_cmd_proc"
-typedef int (*SDBD_PLUGIN_CMD_PROC_PTR)(const char*, const char*, sdbd_plugin_param);
-extern SDBD_PLUGIN_CMD_PROC_PTR sdbd_plugin_cmd_proc;
-int request_plugin_cmd(const char* cmd, const char* in_buf, char *out_buf, unsigned int out_len);
-int request_plugin_verification(const char* cmd, const char* in_buf);
+extern pcap g_capabilities;
 
 void print_packet(const char *label, apacket *p);
 
@@ -309,6 +308,7 @@ void init_transport_registration(void);
 int  list_transports(char *buf, size_t  bufsize);
 void update_transports(void);
 void broadcast_transport(apacket *p);
+int get_connected_count(transport_type type);
 
 asocket*  create_device_tracker(void);
 
@@ -373,26 +373,31 @@ void log_service(int fd, void *cookie);
 void remount_service(int fd, void *cookie);
 char * get_log_file_path(const char * log_name);
 
-int rootshell_mode; // 0: developer, 1: root
-int booting_done; // 0: platform booting is in progess 1: platform booting is done
+extern int rootshell_mode; // 0: sdk user, 1: root
+extern int booting_done; // 0: platform booting is in progess 1: platform booting is done
+
+// 1 if locked, 0 if unlocked
+extern int is_pwlocked;
 
 // This is the users and groups config for the platform
 
 #define SID_ROOT        0    /* traditional unix root user */
-#define SID_TTY         5    /* group for /dev/ptmx */
-#define SID_APP         tzplatform_getuid(TZ_USER_NAME) /* application */
-#define SID_DEVELOPER   tzplatform_getuid(TZ_SDK_USER_NAME) /* developer with SDK */
-#define GID_DEVELOPER   100 /* developer will be member of users with SDK */
-#define SID_APP_LOGGING 6509
-#define SID_SYS_LOGGING 6527
-#define SID_INPUT       1004
 
+#define SDK_USER_NAME   tzplatform_getenv(TZ_SDK_USER_NAME)
+#define SDK_TOOL_PATH   tzplatform_getenv(TZ_SDK_TOOLS)
+#define STATIC_SDK_USER_ID      5001
+#define STATIC_SDK_GROUP_ID     100
+#define STATIC_SDK_HOME_DIR     "/home/owner"
+extern uid_t g_sdk_user_id;
+extern gid_t g_sdk_group_id;
+extern char* g_sdk_home_dir;
+extern char* g_sdk_home_dir_env;
 #endif
 
-int is_pwlocked(void);
 int should_drop_privileges(void);
-int set_developer_privileges();
+int set_sdk_user_privileges();
 void set_root_privileges();
+void send_device_status();
 
 int get_emulator_forward_port(void);
 int get_emulator_name(char str[], int str_size);
@@ -407,86 +412,6 @@ void put_apacket(apacket *p);
 int check_header(apacket *p);
 int check_data(apacket *p);
 
-/* define SDB_TRACE to 1 to enable tracing support, or 0 to disable it */
-
-#define  SDB_TRACE    1
-
-/* IMPORTANT: if you change the following list, don't
- * forget to update the corresponding 'tags' table in
- * the sdb_trace_init() function implemented in sdb.c
- */
-typedef enum {
-    TRACE_SDB = 0,
-    TRACE_SOCKETS,
-    TRACE_PACKETS,
-    TRACE_TRANSPORT,
-    TRACE_RWX,
-    TRACE_USB,
-    TRACE_SYNC,
-    TRACE_SYSDEPS,
-    TRACE_JDWP,
-    TRACE_SERVICES,
-    TRACE_PROPERTIES,
-    TRACE_SDKTOOLS
-} SdbTrace;
-
-#if SDB_TRACE
-
-#if !SDB_HOST
-/*
- * When running inside the emulator, guest's sdbd can connect to 'sdb-debug'
- * qemud service that can display sdb trace messages (on condition that emulator
- * has been started with '-debug sdb' option).
- */
-
-/* Delivers a trace message to the emulator via QEMU pipe. */
-void sdb_qemu_trace(const char* fmt, ...);
-/* Macro to use to send SDB trace messages to the emulator. */
-#define DQ(...)    sdb_qemu_trace(__VA_ARGS__)
-#else
-#define DQ(...) ((void)0)
-#endif  /* !SDB_HOST */
-
-  extern int     sdb_trace_mask;
-  extern unsigned char    sdb_trace_output_count;
-  void    sdb_trace_init(void);
-
-#  define SDB_TRACING  ((sdb_trace_mask & (1 << TRACE_TAG)) != 0)
-
-  /* you must define TRACE_TAG before using this macro */
-#  define  D(...)                                      \
-        do {                                           \
-            if (SDB_TRACING) {                         \
-                int save_errno = errno;                \
-                sdb_mutex_lock(&D_lock);               \
-                fprintf(stderr, "%s::%s():",           \
-                        __FILE__, __FUNCTION__);       \
-                errno = save_errno;                    \
-                fprintf(stderr, __VA_ARGS__ );         \
-                fflush(stderr);                        \
-                sdb_mutex_unlock(&D_lock);             \
-                errno = save_errno;                    \
-           }                                           \
-        } while (0)
-#  define  DR(...)                                     \
-        do {                                           \
-            if (SDB_TRACING) {                         \
-                int save_errno = errno;                \
-                sdb_mutex_lock(&D_lock);               \
-                errno = save_errno;                    \
-                fprintf(stderr, __VA_ARGS__ );         \
-                fflush(stderr);                        \
-                sdb_mutex_unlock(&D_lock);             \
-                errno = save_errno;                    \
-           }                                           \
-        } while (0)
-#else
-#  define  D(...)          ((void)0)
-#  define  DR(...)         ((void)0)
-#  define  SDB_TRACING     0
-#endif
-
-
 #if !TRACE_PACKETS
 #define print_packet(tag,p) do {} while (0)
 #endif
@@ -519,7 +444,7 @@ int  local_connect_arbitrary_ports(int console_port, int sdb_port, const char *d
 void usb_init();
 void usb_cleanup();
 int usb_write(usb_handle *h, const void *data, int len);
-int usb_read(usb_handle *h, void *data, int len);
+int usb_read(usb_handle *h, void *data, size_t len);
 int usb_close(usb_handle *h);
 void usb_kick(usb_handle *h);
 #else
@@ -527,7 +452,7 @@ void usb_kick(usb_handle *h);
 extern void (*usb_init)();
 extern void (*usb_cleanup)();
 extern int (*usb_write)(usb_handle *h, const void *data, int len);
-extern int (*usb_read)(usb_handle *h, void *data, int len);
+extern int (*usb_read)(usb_handle *h, void *data, size_t len);
 extern int (*usb_close)(usb_handle *h);
 extern void (*usb_kick)(usb_handle *h);
 
@@ -535,7 +460,7 @@ extern void (*usb_kick)(usb_handle *h);
 void ffs_usb_init();
 void ffs_usb_cleanup();
 int ffs_usb_write(usb_handle *h, const void *data, int len);
-int ffs_usb_read(usb_handle *h, void *data, int len);
+int ffs_usb_read(usb_handle *h, void *data, size_t len);
 int ffs_usb_close(usb_handle *h);
 void ffs_usb_kick(usb_handle *h);
 
@@ -543,7 +468,7 @@ void ffs_usb_kick(usb_handle *h);
 void linux_usb_init();
 void linux_usb_cleanup();
 int linux_usb_write(usb_handle *h, const void *data, int len);
-int linux_usb_read(usb_handle *h, void *data, unsigned len);
+int linux_usb_read(usb_handle *h, void *data, size_t len);
 int linux_usb_close(usb_handle *h);
 void linux_usb_kick(usb_handle *h);
 
@@ -576,6 +501,7 @@ extern SdbdCommandlineArgs sdbd_commandline_args;
 #endif
 
 #define CHUNK_SIZE (64*1024)
+#define SDBD_SHELL_CMD_MAX 4096
 
 int sendfailmsg(int fd, const char *reason);
 int handle_host_request(char *service, transport_type ttype, char* serial, int reply_fd, asocket *s);