DA runs application through launch_app
authorwoojin <woojin2.jung@samsung.com>
Thu, 2 May 2013 08:23:15 +0000 (17:23 +0900)
committerwoojin <woojin2.jung@samsung.com>
Thu, 2 May 2013 08:23:15 +0000 (17:23 +0900)
Change-Id: Ie2226d7eef17fa45502456ae910ad01061b092cf

daemon/daemon.h
daemon/utils.c
daemon/utils.h

index 8d04548..9e5c3cf 100644 (file)
@@ -39,6 +39,7 @@ extern "C" {
 #define PROTOCOL_VERSION                       "2.1"
 
 #define RUN_APP_LOADER
+#define USE_LAUNCH_PAD
 
 #define MAX_TARGET_COUNT                       8
 #define DA_MSG_MAX                                     4096
index ac130f9..7de644b 100644 (file)
@@ -51,6 +51,9 @@
 #define SID_APP                                5000
 #define MANIFEST_PATH          "/info/manifest.xml"
 
+#define APPDIR1                                "/opt/apps/"
+#define APPDIR2                                "/opt/usr/apps/"
+
 uint64_t str_to_uint64(char* str)
 {
        uint64_t res = 0;
@@ -209,6 +212,56 @@ int get_smack_label(const char* execpath, char* buffer, int buflen)
                return -1;
 }
 
+int get_appid(const char* execpath, char* buffer, int buflen)
+{
+       int i, ret = 0;
+       char* temp;
+       if(strncmp(execpath, APPDIR1, strlen(APPDIR1)) == 0)
+       {
+               execpath = execpath + strlen(APPDIR1);
+               temp = strchr(execpath, '/');
+               for(i = 0; i < strlen(execpath); i++)
+               {
+                       if(execpath + i == temp)
+                               break;
+                       buffer[i] = execpath[i];
+               }
+               buffer[i] = '.';
+               buffer[i+1] = '\0';
+               temp = strrchr(execpath, '/');
+               if(temp != NULL)
+               {
+                       temp++;
+                       strcat(buffer, temp);
+               }
+       }
+       else if(strncmp(execpath, APPDIR2, strlen(APPDIR2)) == 0)
+       {
+               execpath = execpath + strlen(APPDIR2);
+               temp = strchr(execpath, '/');
+               for(i = 0; i < strlen(execpath); i++)
+               {
+                       if(execpath + i == temp)
+                               break;
+                       buffer[i] = execpath[i];
+               }
+               buffer[i] = '.';
+               buffer[i+1] = '\0';
+               temp = strrchr(execpath, '/');
+               if(temp != NULL)
+               {
+                       temp++;
+                       strcat(buffer, temp);
+               }
+       }
+       else
+       {
+               ret = -1;
+       }
+
+       return ret;
+}
+
 // return 0 if succeed
 // return -1 if error occured
 int remove_indir(const char *dirname)
@@ -279,6 +332,37 @@ int get_manifest_path(const char* exec_path, char* buf, int buflen)
 // execute applcation with executable binary path
 // return 0 to fail to execute
 // return 1 to succeed to execute
+#ifdef USE_LAUNCH_PAD
+int exec_app(const char* exec_path, int app_type)
+{
+       pid_t pid;
+       char command[PATH_MAX];
+       char appid[PATH_MAX];
+
+       if (exec_path == NULL || strlen(exec_path) <= 0) 
+       {
+               LOGE("Executable path is not correct\n");
+               return 0;
+       }
+
+       if (( pid = fork()) < 0)        // fork error
+       return 0;
+    else if(pid > 0)
+       return 1;               // exit parent process with successness
+
+       if(get_appid(exec_path, appid, PATH_MAX) < 0)
+       {
+               LOGE("failed to get appid\n");
+               return 0;
+       }
+       else
+       {
+               LOGI("launch app path is %s, executable path is %s\n", LAUNCH_APP_PATH, exec_path);
+               execl(LAUNCH_APP_PATH, LAUNCH_APP_NAME, appid, LAUNCH_APP_SDK, DA_PRELOAD_EXEC, NULL);
+               return 1;
+       }
+}
+#else
 int exec_app(const char* exec_path, int app_type)
 {
        pid_t   pid;
@@ -363,6 +447,7 @@ int exec_app(const char* exec_path, int app_type)
                return 1;
        }
 }
+#endif
 
 // find process id from executable binary path
 pid_t find_pid_from_path(const char* path)
index b0f72b9..5032b3b 100644 (file)
@@ -39,7 +39,8 @@ extern "C" {
 #define LAUNCH_APP_PATH                        "/usr/bin/launch_app"
 #define KILL_APP_PATH                  "/usr/bin/pkill"
 #define LAUNCH_APP_NAME                        "launch_app"
-#define DA_PRELOAD_EXEC                        "__AUL_SDK_DYNAMIC_ANALYSIS"
+#define LAUNCH_APP_SDK                 "__AUL_SDK__"
+#define DA_PRELOAD_EXEC                        "DYNAMIC_ANALYSIS"
 #define DA_PRELOAD(AppType)            AppType ? DA_PRELOAD_OSP : DA_PRELOAD_TIZEN
 #define DA_PRELOAD_TIZEN               "LD_PRELOAD=/usr/lib/da_probe_tizen.so"
 #define DA_PRELOAD_OSP                 "LD_PRELOAD=/usr/lib/da_probe_osp.so"