Remove unnecessary console msg in shell protocol with 2.3.1.
authorKim Gunsoo <gunsoo83.kim@samsung.com>
Tue, 17 Nov 2015 06:23:21 +0000 (15:23 +0900)
committerKim Gunsoo <gunsoo83.kim@samsung.com>
Fri, 20 Nov 2015 08:07:25 +0000 (17:07 +0900)
- Since the shell festure uses a different protocol depending on
  the platform version, the console message due to compatibility
  problems are no longer output.

Change-Id: I447d797852f715bd6798daf6b4355e8d5262a888
Signed-off-by: Kim Gunsoo <gunsoo83.kim@samsung.com>
src/command_function.c
src/commandline.c
src/commandline.h

index ad45421d30a617ae59d8a302ad0c5dbe77cd10a6..6fb7c4565d7524f2c9643072a066af90f50ba6ce 100644 (file)
@@ -660,40 +660,29 @@ static int is_support_debug_option(void){
     return is_support;
 }
 
-#define INFOBUF_MAXLEN 64
-typedef struct platform_info {
-    char platform_info_version[INFOBUF_MAXLEN];
-    char model_name[INFOBUF_MAXLEN]; // Emulator
-    char platform_name[INFOBUF_MAXLEN]; // Tizen
-    char platform_version[INFOBUF_MAXLEN]; // 2.2.1
-    char profile_name[INFOBUF_MAXLEN]; // 2.2.1
-} pinfo;
-
 static int is_support_whitespace_pkgname(void){
     int is_support = 0;
-    struct platform_info pinfo;
-
-    const char* GET_SYSTEM_INFO_CMD = "sysinfo:";
-    int fd = sdb_connect(GET_SYSTEM_INFO_CMD);
+    int version = 0;
+    int major = 0;
+    int minor = 0;
+    int patch = 0;
 
-    if(fd < 0) {
+    version = get_platform_version();
+    if(!version) {
         // default : not support whitespace for package file name.
         return 0;
     }
 
-    if (readx(fd, &pinfo, sizeof(struct platform_info)) == 0) {
-        int major = 0;
-        int minor = 0;
-        int patch = 0;
-        if (sscanf(pinfo.platform_version, "%d.%d.%d", &major, &minor, &patch) == 3) {
-            // version number at least 2.4.0
-            if (major >= 3 || (major >= 2 && minor >=4)) {
-                is_support = 1;
-            }
-        }
+    major = MK_PLATFORM_MAJOR(version);
+    minor = MK_PLATFORM_MINOR(version);
+    patch = MK_PLATFORM_PATCH(version);
+
+    D("Platform version : %d.%d.%d\n", major, minor, patch);
+    // version number at least 2.4.0
+    if (major >= 3 || (major >= 2 && minor >=4)) {
+        is_support = 1;
     }
 
-    sdb_close(fd);
     return is_support;
 }
 
index 104f2034ea3f8870765ab159ca92a3a6f73305c6..304fef40da3bb992f463f06921f1df01618603fa 100755 (executable)
@@ -56,6 +56,46 @@ static int ishell_fd = -1;
 static int enable_sync_winsz = 0;
 static void sync_winsz(void);
 
+#define INFOBUF_MAXLEN 64
+typedef struct platform_info {
+    char platform_info_version[INFOBUF_MAXLEN];
+    char model_name[INFOBUF_MAXLEN]; // Emulator
+    char platform_name[INFOBUF_MAXLEN]; // Tizen
+    char platform_version[INFOBUF_MAXLEN]; // 2.2.1
+    char profile_name[INFOBUF_MAXLEN]; // 2.2.1
+} pinfo;
+
+int get_platform_version(void) {
+    struct platform_info pinfo;
+
+    const char* GET_SYSTEM_INFO_CMD = "sysinfo:";
+    int fd = sdb_connect(GET_SYSTEM_INFO_CMD);
+    int version = 0;
+
+    if(fd < 0) {
+        return 0;
+    }
+
+    if (readx(fd, &pinfo, sizeof(struct platform_info)) == 0) {
+        int major = 0;
+        int minor = 0;
+        int patch = 0;
+        if (sscanf(pinfo.platform_version, "%d.%d.%d", &major, &minor, &patch) == 3) {
+            if (major < 1024 && minor < 1024 && patch < 1024) {
+                version |= (major << 20);
+                version |= (minor << 10);
+                version |= patch;
+            } else {
+                LOG_ERROR("Unexpected version : %d.%d.%d\n", major, minor, patch);
+            }
+        }
+    }
+    D("Platform version : %s(%x)\n", pinfo.platform_version, version);
+
+    sdb_close(fd);
+    return version;
+}
+
 #ifdef HAVE_TERMIO_H
 
 static __inline__ void stdin_raw_init(int fd, struct termios* tio_save);
@@ -441,17 +481,33 @@ int interactive_shell()
     char eshell[32] = "eshell:";
     int lines, columns;
     int fd = -1;
-
-    if(get_screensize(&lines, &columns) == 0) {
-        snprintf(eshell+7, sizeof(eshell)-7, "%d:%d", lines, columns);
-        D("interactive shell : eshell command=%s\n", eshell);
-        fd = sdb_connect(eshell);
-        if(fd < 0) {
-            fprintf(stdout, "failed environment shell, so it will retry shell command.\n");
+    int major = 0;
+    int minor = 0;
+    int patch = 0;
+    int version = 0;
+
+    version = get_platform_version();
+    major = MK_PLATFORM_MAJOR(version);
+    minor = MK_PLATFORM_MINOR(version);
+    patch = MK_PLATFORM_PATCH(version);
+
+    // eshell to support from the 2.4.0 version.
+    if (major >= 3 || (major >= 2 && minor >=4)) {
+        if(get_screensize(&lines, &columns) == 0) {
+            snprintf(eshell+7, sizeof(eshell)-7, "%d:%d", lines, columns);
+            D("interactive shell : eshell command=%s\n", eshell);
+            fd = sdb_connect(eshell);
+            if(fd < 0) {
+                fprintf(stdout, "failed environment shell, so it will retry shell command.\n");
+                return 1;
+            }
         }
-    }
 
-    if(fd < 0) {
+        if(check_syncwinsz_support() == 1) {
+            D("Support sync window size with remote\n");
+            enable_sync_winsz = 1;
+        }
+    } else {
         fd = sdb_connect("shell:");
         if(fd < 0) {
             return 1;
@@ -461,10 +517,6 @@ int interactive_shell()
     int* fd_p = malloc(sizeof(int));
     *fd_p = fd;
     ishell_fd = fd;
-    if(check_syncwinsz_support() == 1) {
-        D("Support sync window size with remote\n");
-        enable_sync_winsz = 1;
-    }
 
 #ifdef HAVE_TERMIO_H
     void** args = (void**)malloc(sizeof(void*)*2);
index 0962070b22fb4336647383b1b62a99d941b333e2..6f62268956f0b99309d133202771f057c8033299 100644 (file)
 #define INPUT_FD 0
 #endif
 
+#define MK_PLATFORM_MAJOR(ver)      ((version & 0x3ff00000) >> 20)
+#define MK_PLATFORM_MINOR(ver)      ((version & 0xffc00) >> 10)
+#define MK_PLATFORM_PATCH(ver)      ((version & 0x3ff))
+
 int send_shellcommand(char* buf);
 int process_cmdline(int argc, char** argv);
 void read_and_dump(int fd);
 int interactive_shell();
 int get_server_port();
+int get_platform_version();
 int __sdb_command(const char* cmd);
 
 #endif /* COMMANDLINE_H_ */