merge private
authorJaeho Lee <jaeho81.lee@samsung.com>
Thu, 8 Aug 2013 06:54:44 +0000 (15:54 +0900)
committerJaeho Lee <jaeho81.lee@samsung.com>
Thu, 8 Aug 2013 06:54:44 +0000 (15:54 +0900)
Signed-off-by: Jaeho Lee <jaeho81.lee@samsung.com>
19 files changed:
am_daemon/amd_appinfo.c
am_daemon/amd_launch.c
am_daemon/amd_main.c
am_daemon/amd_request.c
am_daemon/amd_status.c
am_daemon/amd_status.h
include/app_sock.h
include/aul.h
include/aul_util.h
launchpad_src/launchpad.c
packaging/aul.spec
src/app_sock.c
src/launch.c
src/launch_with_result.c
src/mida.c
src/mime.c
src/pkginfo.c
test/CMakeLists.txt
test/open_app.c [new file with mode: 0755]

index b509569..94f73f5 100755 (executable)
@@ -198,7 +198,7 @@ static int __app_info_insert_handler (const pkgmgrinfo_appinfo_h handle, void *d
        r = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
        c->val[_AI_PKGID] = strdup(pkgid);
 
-       _D("%s : %s : %s", c->val[_AI_FILE], c->val[_AI_COMP], c->val[_AI_TYPE]);
+       SECURE_LOGD("%s : %s : %s", c->val[_AI_FILE], c->val[_AI_COMP], c->val[_AI_TYPE]);
 
        g_hash_table_insert(cf->tbl, c->val[_AI_FILE], c);
 
@@ -257,7 +257,7 @@ static void __vconf_cb(keynode_t *key, void *data)
                return;
        }
 
-       _D("noti_string : %s",noti_string);
+       SECURE_LOGD("noti_string : %s",noti_string);
 
        type_string = strtok_r(noti_string, ":", &saveptr);
        appid = strtok_r(NULL, ":", &saveptr);
@@ -268,7 +268,7 @@ static void __vconf_cb(keynode_t *key, void *data)
                        _E("pkgmgrinfo_appinfo_get_appinfo fail");
                }
 
-               _D("appid : %s /handle : %x", appid, handle);
+               SECURE_LOGD("appid : %s /handle : %x", appid, handle);
 
                __app_info_insert_handler(handle, data);
 
@@ -397,7 +397,7 @@ const char *appinfo_get_filename(const struct appinfo *c)
 {
        if (!c) {
                errno = EINVAL;
-               _E("appinfo get filename: %s", strerror(errno));
+               SECURE_LOGE("appinfo get filename: %s", strerror(errno));
                return NULL;
        }
 
index 760b5c7..fed2659 100755 (executable)
@@ -30,6 +30,7 @@
 #include <app2ext_interface.h>
 #include <sys/prctl.h>
 #include <pkgmgr-info.h>
+#include <poll.h>
 #include <privacy_manager_client.h>
 
 #include "amd_config.h"
@@ -76,20 +77,6 @@ struct ktimer {
        struct cginfo *cg;
 };
 
-static void _set_oom()
-{
-       char buf[MAX_LOCAL_BUFSZ];
-       FILE *fp;
-
-       /* we should reset oomadj value as default because child
-       inherits from parent oom_adj*/
-       snprintf(buf, MAX_LOCAL_BUFSZ, "/proc/%d/oom_adj", getpid());
-       fp = fopen(buf, "w");
-       if (fp == NULL)
-               return;
-       fprintf(fp, "%d", -16);
-       fclose(fp);
-}
 
 static void _set_sdk_env(const char* appid, char* str) {
        char buf[MAX_LOCAL_BUFSZ];
@@ -170,9 +157,6 @@ static void _prepare_exec(const char *appid, bundle *kb)
        pkg_type = appinfo_get_value(ai, AIT_TYPE);
        hwacc = appinfo_get_value(ai, AIT_HWACC);
 
-       /* SET OOM*/
-       _set_oom();
-
        /* SET PRIVILEGES*/
         _D("appid : %s / pkg_type : %s / app_path : %s ", appid, pkg_type, app_path);
        if ((ret = __set_access(appid, pkg_type, app_path)) < 0) {
@@ -481,7 +465,7 @@ int _resume_app(int pid)
        int dummy;
        int ret;
        if ((ret =
-            __app_send_raw(pid, APP_RESUME_BY_PID, (unsigned char *)&dummy,
+            __app_send_raw_with_delay_reply(pid, APP_RESUME_BY_PID, (unsigned char *)&dummy,
                            sizeof(int))) < 0) {
                if (ret == -EAGAIN)
                        _E("resume packet timeout error");
@@ -518,35 +502,12 @@ int _fake_launch_app(int cmd, int pid, bundle * kb)
        bundle_raw *kb_data;
 
        bundle_encode(kb, &kb_data, &datalen);
-       if ((ret = __app_send_raw(pid, cmd, kb_data, datalen)) < 0)
+       if ((ret = __app_send_raw_with_delay_reply(pid, cmd, kb_data, datalen)) < 0)
                _E("error request fake launch - error code = %d", ret);
        free(kb_data);
        return ret;
 }
 
-static int __nofork_processing(int cmd, int pid, bundle * kb)
-{
-       int ret = -1;
-       switch (cmd) {
-       case APP_OPEN:
-       case APP_RESUME:
-               _D("resume app's pid : %d\n", pid);
-               if ((ret = _resume_app(pid)) < 0)
-                       _E("__resume_app failed. error code = %d", ret);
-               _D("resume app done");
-               break;
-
-       case APP_START:
-       case APP_START_RES:
-               _D("fake launch pid : %d\n", pid);
-               if ((ret = _fake_launch_app(cmd, pid, kb)) < 0)
-                       _E("fake_launch failed. error code = %d", ret);
-               _D("fake launch done");
-               break;
-       }
-       return ret;
-}
-
 static void __real_send(int clifd, int ret)
 {
        if (send(clifd, &ret, sizeof(int), MSG_NOSIGNAL) < 0) {
@@ -559,52 +520,159 @@ static void __real_send(int clifd, int ret)
        close(clifd);
 }
 
-int __sat_ui_is_running()
+static gboolean __au_glib_check(GSource *src)
 {
-       char *apppath = "/usr/apps/org.tizen.sat-ui/bin/sat-ui";
-       int ret = 0;
+       GSList *fd_list;
+       GPollFD *tmp;
 
-       ret = __proc_iter_cmdline(NULL, apppath);
+       fd_list = src->poll_fds;
+       do {
+               tmp = (GPollFD *) fd_list->data;
+               if ((tmp->revents & (POLLIN | POLLPRI)))
+                       return TRUE;
+               fd_list = fd_list->next;
+       } while (fd_list);
 
-       return ret;
+       return FALSE;
 }
 
-int __sat_ui_launch(char* appid, bundle* kb, int cmd, int caller_pid, int fd)
+static gboolean __au_glib_dispatch(GSource *src, GSourceFunc callback,
+               gpointer data)
 {
-       int ret = -1;
-       char *app_path = "/usr/apps/org.tizen.sat-ui/bin/sat-ui KEY_EXEC_TYPE 0";
-       int pid = -1;
-       char tmp_pid[MAX_PID_STR_BUFSZ];
+       callback(data);
+       return TRUE;
+}
 
-       snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", caller_pid);
-       bundle_add(kb, AUL_K_CALLER_PID, tmp_pid);
+static gboolean __au_glib_prepare(GSource *src, gint *timeout)
+{
+       return FALSE;
+}
 
-       pid = __sat_ui_is_running();
+static GSourceFuncs funcs = {
+       .prepare = __au_glib_prepare,
+       .check = __au_glib_check,
+       .dispatch = __au_glib_dispatch,
+       .finalize = NULL
+};
+
+struct reply_info {
+       GSource *src;
+       GPollFD *gpollfd;
+       guint timer_id;
+       int clifd;
+       int pid;
+};
 
-       if (pid > 0) {
-               if (caller_pid == pid) {
-                       _D("caller process & callee process is same.[%s:%d]", appid, pid);
-                       pid = -ELOCALLAUNCH_ID;
-               } else if ((ret = __nofork_processing(cmd, pid, kb)) < 0) {
-                       pid = ret;
+static gboolean __reply_handler(gpointer data)
+{
+       struct reply_info *r_info = (struct reply_info *) data;;
+       int fd = r_info->gpollfd->fd;
+       int len;
+       int res = 0;
+       int clifd = r_info->clifd;
+       int pid = r_info->pid;
+
+       len = recv(fd, &res, sizeof(int), 0);
+       if (len == -1) {
+               if (errno == EAGAIN) {
+                       _E("recv timeout : %s", strerror(errno));
+                       res = -EAGAIN;
+               } else {
+                       _E("recv error : %s", strerror(errno));
+                       res = -ECOMM;
                }
-       } else if (cmd != APP_RESUME) {
-               bundle_add(kb, AUL_K_HWACC, "NOT_USE");
-               bundle_add(kb, AUL_K_EXEC, app_path);
-               bundle_add(kb, AUL_K_PACKAGETYPE, "rpm");
-               pid = app_send_cmd(LAUNCHPAD_PID, cmd, kb);
        }
+       close(fd);
 
-       __real_send(fd, pid);
+       if(res < 0) {
+               __real_send(clifd, res);
+       } else {
+               __real_send(clifd, pid);
+       }
 
-       if(pid > 0) {
-               //_status_add_app_info_list(appid, app_path, pid);
-               ac_server_check_launch_privilege(appid, "rpm", pid);
+       _D("listen fd : %d , send fd : %d, pid : %d", fd, clifd, pid);
+
+       g_source_remove(r_info->timer_id);
+       g_source_remove_poll(r_info->src, r_info->gpollfd);
+       g_source_destroy(r_info->src);
+       g_free(r_info->gpollfd);
+       free(r_info);
+
+       return TRUE;
+}
+
+static gboolean __recv_timeout_handler(gpointer data)
+{
+       struct reply_info *r_info = (struct reply_info *) data;
+       int fd = r_info->gpollfd->fd;
+       int clifd = r_info->clifd;
+
+       __real_send(clifd, -EAGAIN);
+
+       close(fd);
+
+       g_source_remove_poll(r_info->src, r_info->gpollfd);
+       g_source_destroy(r_info->src);
+       g_free(r_info->gpollfd);
+       free(r_info);
+
+       return FALSE;
+}
+
+static int __nofork_processing(int cmd, int pid, bundle * kb, int clifd)
+{
+       int ret = -1;
+       int r;
+       GPollFD *gpollfd;
+       GSource *src;
+       struct reply_info *r_info;
+       GMainContext *reply_context;
+
+       switch (cmd) {
+       case APP_OPEN:
+       case APP_RESUME:
+               _D("resume app's pid : %d\n", pid);
+               if ((ret = _resume_app(pid)) < 0)
+                       _E("__resume_app failed. error code = %d", ret);
+               _D("resume app done");
+               break;
+
+       case APP_START:
+       case APP_START_RES:
+               _D("fake launch pid : %d\n", pid);
+               if ((ret = _fake_launch_app(cmd, pid, kb)) < 0)
+                       _E("fake_launch failed. error code = %d", ret);
+               _D("fake launch done");
+               break;
        }
 
-       return pid;
+       if(ret > 0) {
+               src = g_source_new(&funcs, sizeof(GSource));
+
+               gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
+               gpollfd->events = POLLIN;
+               gpollfd->fd = ret;
+
+               r_info = malloc(sizeof(*r_info));
+               r_info->clifd = clifd;
+               r_info->pid = pid;
+               r_info->src = src;
+               r_info->gpollfd = gpollfd;
+
+               _D("listen fd : %d, send fd : %d", ret, clifd);
+
+               r_info->timer_id = g_timeout_add(5200, __recv_timeout_handler, (gpointer) r_info);
+               g_source_add_poll(src, gpollfd);
+               g_source_set_callback(src, (GSourceFunc) __reply_handler,
+                               (gpointer) r_info, NULL);
+               g_source_set_priority(src, G_PRIORITY_DEFAULT);
+               r = g_source_attach(src, NULL);
+       }
+
+       return ret;
 }
 
+
 int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_uid, int fd)
 {
        const struct appinfo *ai;
@@ -621,16 +689,10 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
        const char *preload;
        char caller_appid[256];
        pkgmgrinfo_cert_compare_result_type_e compare_result;
+       int delay_reply = 0;
+       int pad_pid = LAUNCHPAD_PID;
        bool consented = true;
 
-       int location = -1;
-       app2ext_handle *app2_handle = NULL;
-
-       if(strncmp(appid, "org.tizen.sat-ui", 18) == 0) {
-               pid = __sat_ui_launch(appid, kb, cmd, caller_pid, fd);
-               return pid;
-       }
-
        snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", caller_pid);
        bundle_add(kb, AUL_K_CALLER_PID, tmp_pid);
 
@@ -690,6 +752,10 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
                }
        }
 
+       if(app2ext_get_app_location(pkgid) == APP2EXT_SD_CARD) {
+               app2ext_enable_external_pkg(pkgid);
+       }
+
        if (componet && strncmp(componet, "ui", 2) == 0) {
                multiple = appinfo_get_value(ai, AIT_MULTI);
                if (!multiple || strncmp(multiple, "false", 5) == 0) {
@@ -700,10 +766,14 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
                        if (_status_get_app_info_status(pid) == STATUS_DYING) {
                                pid = -ETERMINATING;
                        } else if (caller_pid == pid) {
-                               _D("caller process & callee process is same.[%s:%d]", appid, pid);
+                               SECURE_LOGD("caller process & callee process is same.[%s:%d]", appid, pid);
                                pid = -ELOCALLAUNCH_ID;
-                       } else if ((ret = __nofork_processing(cmd, pid, kb)) < 0) {
-                               pid = ret;
+                       } else {
+                               if ((ret = __nofork_processing(cmd, pid, kb, fd)) < 0) {
+                                       pid = ret;
+                               } else {
+                                       delay_reply = 1;
+                               }
                        }
                } else if (cmd != APP_RESUME) {
                        hwacc = appinfo_get_value(ai, AIT_HWACC);
@@ -711,12 +781,11 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
                        bundle_add(kb, AUL_K_EXEC, app_path);
                        bundle_add(kb, AUL_K_PACKAGETYPE, pkg_type);
                        if(bundle_get_type(kb, AUL_K_SDK) != BUNDLE_TYPE_NONE) {
-                               pid = app_send_cmd(DEBUG_LAUNCHPAD_PID, cmd, kb);
+                               pad_pid = DEBUG_LAUNCHPAD_PID;          
                        } else if(strncmp(pkg_type, "wgt", 3) == 0) {
-                               pid = app_send_cmd(WEB_LAUNCHPAD_PID, cmd, kb);
-                       } else {
-                               pid = app_send_cmd(LAUNCHPAD_PID, cmd, kb);
+                               pad_pid = WEB_LAUNCHPAD_PID;
                        }
+                       pid = app_send_cmd(pad_pid, cmd, kb);
                        if(pid == -3) {
                                pid = -ENOLAUNCHPAD;
                        }
@@ -725,7 +794,7 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
        } else if (componet && strncmp(componet, "svc", 3) == 0) {
                pid = _status_app_is_running_v2(appid);
                if (pid > 0) {
-                       if ((ret = __nofork_processing(cmd, pid, kb)) < 0) {
+                       if ((ret = __nofork_processing(cmd, pid, kb, fd)) < 0) {
                                pid = ret;
                        }
                } else if (cmd != APP_RESUME) {
@@ -735,28 +804,11 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
                _E("unkown application");
        }
 
-       location = app2ext_get_app_location(pkgid);
-       if (location == APP2EXT_SD_CARD)
-       {
-               app2_handle = app2ext_init(APP2EXT_SD_CARD);
-               if (app2_handle == NULL) {
-                       _E("app2_handle : app2ext init failed\n");
-                       close(fd);
-                       return -1;
-               }
-
-               ret = app2_handle->interface.enable(pkgid);
-               if (ret) {
-                       _E("app2_handle : app enable API fail Reason %d", ret);
-               }
-
-               app2ext_deinit(app2_handle);
-       }
-
-       __real_send(fd, pid);
+       if(!delay_reply)
+               __real_send(fd, pid);
 
        if(pid > 0) {
-               _status_add_app_info_list(appid, app_path, pid);
+               _status_add_app_info_list(appid, app_path, pid, pad_pid);
                ret = ac_server_check_launch_privilege(appid, appinfo_get_value(ai, AIT_TYPE), pid);
                return ret != AC_R_ERROR ? pid : -1;
        }
index 0966638..6135d69 100755 (executable)
@@ -63,6 +63,8 @@ static void __vconf_cb(keynode_t *key, void *data);
 static int __app_dead_handler(int pid, void *data);
 static int __init();
 
+extern int _status_init(struct amdmgr* amd);
+
 static int __send_to_sigkill(int pid)
 {
        int pgid;
@@ -209,13 +211,10 @@ static void __vconf_cb(keynode_t *key, void *data)
        name = vconf_keynode_get_name(key);
        if( name == NULL ) {
                return;
-       } else if ( strcmp(name, VCONFKEY_SETAPPL_DEVOPTION_BGPROCESS) != 0)
-       {
-               return;
+       }else if ( strcmp(name, VCONFKEY_SETAPPL_DEVOPTION_BGPROCESS) == 0){
+               limit = vconf_keynode_get_int(key);
+               if(limit>0) __kill_bg_apps(limit);
        }
-
-       limit = vconf_keynode_get_int(key);
-       if(limit>0) __kill_bg_apps(limit);
 }
 
 static int __app_dead_handler(int pid, void *data)
@@ -263,7 +262,6 @@ static int __init()
 #ifndef __emul__
        _key_init();
 #endif
-
        if (vconf_notify_key_changed(VCONFKEY_SETAPPL_DEVOPTION_BGPROCESS, __vconf_cb, NULL) != 0)
                _E("Unable to register callback for VCONFKEY_SETAPPL_DEVOPTION_BGPROCESS\n");
        aul_listen_app_dead_signal(__app_dead_handler, NULL);
index e119a3c..7e38a79 100755 (executable)
@@ -181,12 +181,8 @@ static gboolean __add_history_handler(gpointer user_data)
        kb = bundle_decode(pkt->data, pkt->len);
        appid = (char *)bundle_get_val(kb, AUL_K_PKG_NAME);
 
-       if(strncmp(appid, "org.tizen.sat-ui", 18) == 0) {
-               app_path = "/usr/apps/org.tizen.sat-ui/bin/sat-ui KEY_EXEC_TYPE 0";
-       } else {
-               ai = (struct appinfo *)appinfo_find(_raf, appid);
-               app_path = (char *)appinfo_get_value(ai, AIT_EXEC);
-       }
+       ai = (struct appinfo *)appinfo_find(_raf, appid);
+       app_path = (char *)appinfo_get_value(ai, AIT_EXEC);
 
        memset((void *)&rec, 0, sizeof(rec));
 
@@ -197,7 +193,7 @@ static gboolean __add_history_handler(gpointer user_data)
                rec.arg = (char *)pkt->data;
        }
 
-       _D("add rua history %s %s", rec.pkg_name, rec.app_path);
+       SECURE_LOGD("add rua history %s %s", rec.pkg_name, rec.app_path);
 
        ret = rua_add_history(&rec);
        if (ret == -1)
@@ -232,11 +228,11 @@ static int __releasable(const char *filename)
 
        r = cgutil_exist_group(_rcg, CTRL_MGR, filename);
        if (r == -1) {
-               _E("release service: exist: %s", strerror(errno));
+               SECURE_LOGE("release service: exist: %s", strerror(errno));
                return -1;
        }
        if (r == 0) {
-               _E("release service: '%s' already not exist", filename);
+               SECURE_LOGE("release service: '%s' already not exist", filename);
                return -1;
        }
 
@@ -244,11 +240,11 @@ static int __releasable(const char *filename)
        r = cgutil_group_foreach_pid(_rcg, CTRL_MGR, filename,
                        __get_pid_cb, &sz);
        if (r == -1) {
-               _E("release service: '%s' read pid error", filename);
+               SECURE_LOGE("release service: '%s' read pid error", filename);
                return -1;
        }
        if (sz > 0) {
-               _E("release service: '%s' group has process", filename);
+               SECURE_LOGE("release service: '%s' group has process", filename);
                return -1;
        }
 
@@ -266,14 +262,14 @@ static int __release_srv(const char *filename)
 
        ai = (struct appinfo *)appinfo_find(_raf, filename);
        if (!ai) {
-               _E("release service: '%s' not found", filename);
+               SECURE_LOGE("release service: '%s' not found", filename);
                return -1;
        }
 
        r = appinfo_get_boolean(ai, AIT_RESTART);
        if (r == 1) {
                /* Auto restart */
-               _D("Auto restart set: '%s'", filename);
+               SECURE_LOGD("Auto restart set: '%s'", filename);
                return _start_srv(ai, NULL);
        }
 
@@ -281,7 +277,7 @@ static int __release_srv(const char *filename)
 
        r = cgutil_remove_group(_rcg, CTRL_MGR, filename);
        if (r == -1) {
-               _E("'%s' group remove error: %s", filename, strerror(errno));
+               SECURE_LOGE("'%s' group remove error: %s", filename, strerror(errno));
                return -1;
        }
 
@@ -303,6 +299,7 @@ static gboolean __request_handler(gpointer data)
        char *tmp_pid;*/
        int pid;
        bundle *kb = NULL;
+       item_pkt_t *item;
 
        if ((pkt = __app_recv_raw(fd, &clifd, &cr)) == NULL) {
                _E("recv error");
@@ -318,13 +315,18 @@ static gboolean __request_handler(gpointer data)
                        appid = (char *)bundle_get_val(kb, AUL_K_PKG_NAME);
                        ret = _start_app(appid, kb, pkt->cmd, cr.pid, cr.uid, clifd);
 
-                       if (kb != NULL)
-                               bundle_free(kb), kb = NULL;
-
                        if(ret > 0) {
+                               item = calloc(1, sizeof(item_pkt_t));
+                               item->pid = ret;
+                               strncpy(item->appid, appid, 511);
                                free_pkt = 0;
+
                                g_timeout_add(1000, __add_history_handler, pkt);
+                               g_timeout_add(1200, __add_item_running_list, item);
                        }
+
+                       if (kb != NULL)
+                               bundle_free(kb), kb = NULL;
                        break;
                case APP_RESULT:
                case APP_CANCEL:
@@ -349,7 +351,7 @@ static gboolean __request_handler(gpointer data)
                        appid = malloc(MAX_PACKAGE_STR_SIZE);
                        strncpy(appid, (const char*)pkt->data, MAX_PACKAGE_STR_SIZE-1);
                        ret = _status_app_is_running_v2(appid);
-                       _D("APP_IS_RUNNING : %s : %d",appid, ret);
+                       SECURE_LOGD("APP_IS_RUNNING : %s : %d",appid, ret);
                        __send_result_to_client(clifd, ret);
                        free(appid);
                        break;
index ee2b83c..d1e70f0 100755 (executable)
@@ -38,7 +38,7 @@ GSList *app_status_info_list = NULL;
 
 struct appinfomgr *_saf = NULL;
 
-int _status_add_app_info_list(char *appid, char *app_path, int pid)
+int _status_add_app_info_list(char *appid, char *app_path, int pid, int pad_pid)
 {
        GSList *iter = NULL;
        app_status_info_t *info_t = NULL;
@@ -56,13 +56,14 @@ int _status_add_app_info_list(char *appid, char *app_path, int pid)
        strncpy(info_t->app_path, app_path, MAX_PACKAGE_APP_PATH_SIZE-1);
        info_t->status = STATUS_LAUNCHING;
        info_t->pid = pid;
+       info_t->pad_pid = pad_pid;
        app_status_info_list = g_slist_append(app_status_info_list, info_t);
 
        for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
        {
                info_t = (app_status_info_t *)iter->data;
 
-               _D("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
+               //SECURE_LOGD("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
        }
 
        return 0;
@@ -77,7 +78,7 @@ static Eina_Bool __app_terminate_timer_cb(void *data)
 
        ret = kill(pid, SIGKILL);
        if (ret == -1)
-               _E("send SIGKILL: %s", strerror(errno));
+               _D("send SIGKILL: %s", strerror(errno));
 
        return ECORE_CALLBACK_CANCEL;
 }
@@ -93,7 +94,8 @@ int _status_update_app_info_list(int pid, int status)
                if(pid == info_t->pid) {
                        info_t->status = status;
                        if(status == STATUS_DYING) {
-                               ecore_timer_add(2, __app_terminate_timer_cb, info_t->pid);
+                               if(info_t->pad_pid != DEBUG_LAUNCHPAD_PID)
+                                       ecore_timer_add(2, __app_terminate_timer_cb, info_t->pid);
                        }
                        break;
                }
@@ -103,7 +105,7 @@ int _status_update_app_info_list(int pid, int status)
        {
                info_t = (app_status_info_t *)iter->data;
 
-               _D("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
+               //SECURE_LOGD("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
        }
 
        return 0;
@@ -128,7 +130,7 @@ int _status_remove_app_info_list(int pid)
        {
                info_t = (app_status_info_t *)iter->data;
 
-               _D("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
+               //SECURE_LOGD("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
        }
 
        return 0;
@@ -341,7 +343,7 @@ int _status_get_appid_bypid(int fd, int pid)
        pkt->cmd = APP_GET_APPID_BYPID_ERROR;
 
        if (__get_pkgname_bypid(pid, (char *)pkt->data, MAX_PACKAGE_STR_SIZE) == 0) {
-               _D("appid for %d is %s", pid, pkt->data);
+               SECURE_LOGD("appid for %d is %s", pid, pkt->data);
                pkt->cmd = APP_GET_APPID_BYPID_OK;
                goto out;
        }
index 3ac2a93..157d749 100755 (executable)
@@ -21,7 +21,7 @@
 
 
 
-int _status_add_app_info_list(char *appid, char *app_path, int pid);
+int _status_add_app_info_list(char *appid, char *app_path, int pid, int pad_pid);
 int _status_update_app_info_list(int pid, int status);
 int _status_remove_app_info_list(int pid);
 int _status_get_app_info_status(int pid);
index 59769e2..ee31aa6 100755 (executable)
@@ -64,7 +64,6 @@ enum app_cmd {
 #define ETERMINATING 126
 #define ENOLAUNCHPAD 125
 
-
 typedef struct _app_pkt_t {
        int cmd;
        int len;
@@ -75,6 +74,7 @@ int __create_server_sock(int pid);
 int __create_client_sock(int pid);
 int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen);
 int __app_send_raw_with_noreply(int pid, int cmd, unsigned char *kb_data, int datalen);
+int __app_send_raw_with_delay_reply(int pid, int cmd, unsigned char *kb_data, int datalen);
 app_pkt_t *__app_recv_raw(int fd, int *clifd, struct ucred *cr);
 app_pkt_t *__app_send_cmd_with_result(int pid, int cmd, unsigned char *kb_data, int datalen);
 
index 2ca0809..3864945 100755 (executable)
@@ -32,14 +32,14 @@ extern "C" {
 
 /**
  * @mainpage
- * 
- * This is new version of Application Utility Library 
+ *
+ * This is new version of Application Utility Library
  *
  * Almost function's input param is application package name(APN).\n
  * APN is application package name which is set by developer.\n
  * In case of in-house application, prefix is org.tizen.\n
  * It is different from debian package name.\n
- * 
+ *
  * - Debian Package Name : Name which is managed by package manager
  * - Application Package Name : Name which is used by AUL
  * - Execution Path : real program executable path
@@ -52,7 +52,7 @@ extern "C" {
  * @{
  */
 
-       
+
 /**
  * @file       aul.h
  * @brief      Application Utility Library header
@@ -65,9 +65,9 @@ extern "C" {
  * @addtogroup aul
  * @{
  */
-       
+
 /**
- * @brief Return values in AUL. 
+ * @brief Return values in AUL.
  */
 typedef enum _aul_return_val {
        AUL_R_ENOLAUNCHPAD = -10,       /**< no launchpad */
@@ -93,13 +93,13 @@ enum app_status {
        STATUS_HOME
 };
 
-/** @} */ 
+/** @} */
 
 /**
- * @defgroup aul_launch                Primitive APIs to launch/resume/terminate application 
+ * @defgroup aul_launch                Primitive APIs to launch/resume/terminate application
  * @ingroup aul
  * @brief
- *     APIs to launch/resume/terminate application 
+ *     APIs to launch/resume/terminate application
  *     - Launch application based on application package name
  *     - Resume application based on application package name
  *     - Resume application based on pid (required root or inhouse permisssion)
@@ -109,12 +109,12 @@ enum app_status {
  *     - AUL grant pid, gid to launched application for security
  *     - AUL send RESET/RESUME/TERM event for running application in case of single instance
  *     - AUL set application enviroment based on desktop entry
- *     - AUL support single instance / multi instance 
+ *     - AUL support single instance / multi instance
  *     - AUL support application data exchange format (bundle)
  */
 
 /**
- * @addtogroup aul_launch 
+ * @addtogroup aul_launch
  * @{
  */
 
@@ -152,7 +152,7 @@ typedef enum _aul_type{
 /** AUL public key - To check caller's secuirty */
 #define AUL_K_CALLEE_APPID     "__AUL_CALLEE_APPID__"
 
-/** AUL public key - To find argv0 */ 
+/** AUL public key - To find argv0 */
 #define AUL_K_ARGV0            "__AUL_ARGV0__"
 /** AUL public key - To measure launching time */
 #define AUL_K_STARTTIME                "__AUL_STARTTIME__"
@@ -205,8 +205,7 @@ typedef enum _aul_type{
 #define PRIVACY_POPUP "tizenprv00.privacy-popup"
 
 
-
-/** 
+/**
  * @brief      This is callback function for aul_launch_init
  * @param[in]  type    event's type received from system
  * @param[in]  b       In case of RESET events, bundle which is received from peer
@@ -224,7 +223,7 @@ typedef int (*aul_handler_fn) (aul_type type, bundle * b, void *data);
  *     In general, you need not use this API.
  *      If you use AppCore, you should NOT use this API.
  *      AppCore will set default aul_handler.
- *              
+ *
  * @param[in]  handler         aul main callback handler function
  * @param[in]  data            user-supplied data for start_handler
  * @return     0 if success, negative value(<0) if fail\n
@@ -232,16 +231,16 @@ typedef int (*aul_handler_fn) (aul_type type, bundle * b, void *data);
  * @retval     AUL_R_ECANCELD  - aul handler was installed already by others
  * @retval     AUL_R_ECOMM     - error to create internal ipc
  * @retval     AUL_R_ERROR     - error to attach glib main loop or ecore main loop
- *             
+ *
  * @warning    If you use AppCore, you should NOT use this API.\n
  *             You need glib main loop or ecore main loop.\n
  * @pre
  *     you must have aul handler to use this API.
  *     aul_luanch_init register aul handler.
- * @post 
+ * @post
+ *     None
+ * @see
  *     None
- * @see 
- *     None    
  * @code
  * #include <aul.h>
  * #include <bundle.h>
@@ -270,7 +269,7 @@ typedef int (*aul_handler_fn) (aul_type type, bundle * b, void *data);
  *      aul_launch_argv_handler(argc, argv);
  *     ecore_main_loop_begin();
  * }
- * 
+ *
  * @endcode
  * @remark
  *     None
@@ -293,21 +292,21 @@ int aul_launch_init(aul_handler_fn handler, void *data);
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_ENOINIT   - aul handler was NOT yet installed
  * @retval     AUL_R_ECANCLED  - error to create internal bundle with given argc,argv.
- * @retval     AUL_R_ERROR     - general error 
+ * @retval     AUL_R_ERROR     - general error
  *
  * @pre
  *     you must have aul handler to use this API.
  *     aul_luanch_init register aul handler.
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_launch_init
  * @code
  * #include <aul.h>
  * #include <bundle.h>
- * 
+ *
  * int send_local_reset_event()
- * { 
+ * {
  *     int argc=3;
  *     char* argv[4];
  *     argv[0] = "local.app";
@@ -328,7 +327,7 @@ int aul_launch_argv_handler(int argc, char **argv);
  *     This API creates internal RESET events with given bundle \n
  * @par Purpose:
  *  This API's purpose is to generate reset event.
- *  If you want to generate local RESET events with argument vector format, first use 
+ *  If you want to generate local RESET events with argument vector format, first use
  *  bundle_import_from_argv to create a bundle from the argument vector and then use this API
  *  Eventually, this API will replace aul_launch_argv_handler().
  * @par Typical use case:
@@ -339,21 +338,21 @@ int aul_launch_argv_handler(int argc, char **argv);
  * @return     0 if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_ENOINIT   - aul handler was NOT yet installed
- * @retval     AUL_R_ERROR     - general error 
+ * @retval     AUL_R_ERROR     - general error
  *
  * @pre
  *     you must have aul handler to use this API.
  *     aul_luanch_init register aul handler.
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_launch_init, bundle_import_from_argv
  * @code
  * #include <aul.h>
  * #include <bundle.h>
- * 
+ *
  * int send_local_reset_event()
- * { 
+ * {
  *  bundle* b;
  *     int argc=3;
  *     char* argv[4];
@@ -374,38 +373,38 @@ int aul_launch_local(bundle *b);
 
 /**
  * @par Description:
- *     This API launches application with the given bundle. 
+ *     This API launches application with the given bundle.
  *  If the application is not running or a multiple-instance one, this API launches with the given bundle.
  *     If the application is running, this API sends a RESET event to the App.
- *     While the application is running, if the application cannot receive the RESET event, 
+ *     While the application is running, if the application cannot receive the RESET event,
  *     this API returns a general error(AUL_R_ERROR).\n
  * @par Purpose:
  *      This API is for caller.
  *      This API's purpose is to launch/reset application with given bundle.
  * @par Typical use case:
- *     If you know the target application's pkgname and bundle types, 
+ *     If you know the target application's pkgname and bundle types,
  *     you can use this API to launch/reset the application.
  *
  * @param[in]  pkgname         package name to be run as callee
  * @param[in]  kb              bundle to be passed to callee
  * @return     callee's pid if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
- * @retval     AUL_R_EINVAL    - invaild package name 
+ * @retval     AUL_R_EINVAL    - invaild package name
  * @retval     AUL_R_ECOM      - internal AUL IPC error
- * @retval     AUL_R_ERROR     - general error 
- * 
+ * @retval     AUL_R_ERROR     - general error
+ *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_open_app
  * @code
  * #include <aul.h>
  * #include <bundle.h>
- * 
+ *
  * int launch_inhouse_contact_app()
- * { 
+ * {
  *     bundle *b;
  *     b = bundle_create();
  *     bundle_add(b,"type","SIM");
@@ -431,33 +430,33 @@ int aul_launch_app(const char *appid, bundle *kb);
  *      This API's purpose is to resume/launch application
  * @par Typical use case:
  *     If you only want to show application with previous state or default state, Use this API.
- *             
+ *
  * @param[in]  pkgname         package name to be resume as callee
  * @return     callee's pid if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
- * @retval     AUL_R_EINVAL    - invaild package name 
+ * @retval     AUL_R_EINVAL    - invaild package name
  * @retval     AUL_R_ECOM      - internal AUL IPC error
- * @retval     AUL_R_ERROR     - general error 
+ * @retval     AUL_R_ERROR     - general error
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_launch_app, aul_app_is_running, aul_resume_pid
  * @code
  * #include <aul.h>
  * #include <bundle.h>
- * 
+ *
  * int open_inhouse_contact_app()
- * { 
+ * {
  *     if(aul_app_is_running("org.tizen.contact"))
  *             aul_open_app("org.tizen.contact");
  * }
  *
  * @endcode
  * @remark
- *     If you don't want to launch the app, 
+ *     If you don't want to launch the app,
  *     you should check app's running state with aul_app_is_running.
  *     This API will launch the application if the application is not running.
 */
@@ -465,45 +464,45 @@ int aul_open_app(const char *appid);
 
 /**
  * @par Description:
- *     This API trigger to resume application 
+ *     This API trigger to resume application
  *     If the application is running, this API send a resume event to the App.
  *     If the application is not running, this API returns fail.
- *     Although the application is running, if the application cannot receive resume event, 
+ *     Although the application is running, if the application cannot receive resume event,
  *     AUL try to raise the application's default windows.
  * @par Purpose:
  *      This API is for caller.
  *      This API's purpose is to send resume event.
  * @par Typical use case:
  *     If you only want to show application with previous state or default state, Use this API.
- *             
+ *
  * @param[in]  pkgname         package name to be resume as callee
  * @return     callee's pid if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
- * @retval     AUL_R_EINVAL    - invaild package name 
+ * @retval     AUL_R_EINVAL    - invaild package name
  * @retval     AUL_R_ECOM      - internal AUL IPC error
- * @retval     AUL_R_ERROR     - general error 
+ * @retval     AUL_R_ERROR     - general error
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_launch_app, aul_app_is_running, aul_resume_pid
  * @deprecated
  *  This function will be deprecated. Use aul_open_add() instead.
  * @code
  * #include <aul.h>
  * #include <bundle.h>
- * 
+ *
  * int resume_inhouse_contact_app()
- * { 
+ * {
  *     if(aul_app_is_running("org.tizen.contact"))
  *             aul_resume_app("org.tizen.contact");
  * }
  *
  * @endcode
  * @remark
- *     If you don't want to launch the app, 
+ *     If you don't want to launch the app,
  *     you should check app's running state with aul_app_is_running.
  *     This API will launch the application if the application is not running.
  *     If you want to only resume without launching in multiple instance application model,
@@ -513,10 +512,10 @@ int aul_resume_app(const char *appid);
 
 /**
  * @par Description:
- *     This API trigger to resume application 
+ *     This API trigger to resume application
  *     If the application is running, this API send a resume event to the App.
  *     If the application is not running, this API return AUL_R_ERROR.
- *     Although the application is running, if the application cannot receive resume event, 
+ *     Although the application is running, if the application cannot receive resume event,
  *     AUL try to raise the application's default windows.
  * @par Purpose:
  *      This API is for caller.
@@ -527,21 +526,21 @@ int aul_resume_app(const char *appid);
  * @param[in]  pid     application's pid to be resumed
  * @return     0 if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
- * @retval     AUL_R_EINVAL    - invaild pid 
+ * @retval     AUL_R_EINVAL    - invaild pid
  * @retval     AUL_R_ECOM      - internal AUL IPC error
- * @retval     AUL_R_ERROR     - general error (include application is not running) 
+ * @retval     AUL_R_ERROR     - general error (include application is not running)
  * @warning    This API need to require root or inhouse permisssion \n
  *             If you have not the permission, this API return AUL_R_ERROR. \n
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_launch_app
  * @code
  * #include <aul.h>
  * #include <bundle.h>
- * 
+ *
  * int iterfunc(const aul_app_info *info, void *data)
  * {
  *     if(strcmp(info->pkg_name,"org.tizen.contact")==0)
@@ -549,7 +548,7 @@ int aul_resume_app(const char *appid);
  * }
  *
  * int iterate_running_apps()
- * { 
+ * {
  *      return aul_app_get_running_app_info(iterfunc,NULL);
  * }
  *
@@ -561,35 +560,35 @@ int aul_resume_pid(int pid);
 
 /**
  * @par Description:
- *     This API trigger to terminate application 
- * 
+ *     This API trigger to terminate application
+ *
  *     If the application is running, this API send a terminate event to the App. \n
  *     If the app cannot receive the event, AUL kill forcely the application.\n
  * @par Purpose:
- *      This API's purpose is to kill application 
+ *      This API's purpose is to kill application
  * @par Typical use case:
  *     In general, Application like Task Manager use this API.
- *     
+ *
  *             This API need to require root or inhouse permisssion. \n
  *
- * @param[in]  pid     application's pid to be terminated 
+ * @param[in]  pid     application's pid to be terminated
  * @return     0 if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
- * @retval     AUL_R_EINVAL    - invaild pid 
+ * @retval     AUL_R_EINVAL    - invaild pid
  * @retval     AUL_R_ECOM      - internal AUL IPC error
- * @retval     AUL_R_ERROR     - general error 
+ * @retval     AUL_R_ERROR     - general error
  * @warning    This API need to require root or inhouse permisssion. \n
  *
  * @pre
  *     None
- * @post 
+ * @post
+ *     None
+ * @see
  *     None
- * @see 
- *     None    
  * @code
  * #include <aul.h>
  * #include <bundle.h>
- * 
+ *
  * int iterfunc(const aul_app_info *info, void *data)
  * {
  *     if(strcmp(info->pkg_name,"org.tizen.contact")==0)
@@ -597,7 +596,7 @@ int aul_resume_pid(int pid);
  * }
  *
  * int iterate_running_apps()
- * { 
+ * {
  *      return aul_app_get_running_app_info(iterfunc,NULL);
  * }
  *
@@ -624,8 +623,8 @@ int aul_terminate_pid(int pid);
  * @{
  */
 
-/** 
- *@brief Running application's information structure retrieved by AUL 
+/**
+ *@brief Running application's information structure retrieved by AUL
  */
 typedef struct _aul_app_info {
        int pid;                /**< app's pid if running*/
@@ -634,10 +633,10 @@ typedef struct _aul_app_info {
        char* appid;
 } aul_app_info;
 
-/** 
- * @brief iterator function running with aul_app_get_running_app_info 
+/**
+ * @brief iterator function running with aul_app_get_running_app_info
  * @param[out] ainfo   aul_app_info retreived by aul_app_get_running_app_info
- * @param[out] data    user-supplied data      
+ * @param[out] data    user-supplied data
 */
 typedef int (*aul_app_info_iter_fn)(const aul_app_info *ainfo, void *data);
 
@@ -647,7 +646,7 @@ typedef int (*aul_app_info_iter_fn)(const aul_app_info *ainfo, void *data);
  * @par Purpose:
  *     To know whether some application is running or not, use this API
  * @par Typical use case:
- *     For example, If you want to know browser application running, 
+ *     For example, If you want to know browser application running,
  *     you can check it by using this API.
  *
  * @param[in]  pkgname application package name
@@ -657,22 +656,22 @@ typedef int (*aul_app_info_iter_fn)(const aul_app_info *ainfo, void *data);
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     None
  * @code
  * #include <aul.h>
  *
  * int is_running_browser_app()
- * { 
+ * {
  *      return aul_app_is_running("org.tizen.browser");
  * }
  *
  * @endcode
  * @remark
  *     None
-* 
+*
 */
 int aul_app_is_running(const char *appid);
 
@@ -694,9 +693,9 @@ int aul_app_is_running(const char *appid);
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     None
  * @code
  * #include <aul.h>
@@ -712,7 +711,7 @@ int aul_app_is_running(const char *appid);
  * }
  *
  * int iterate_running_apps()
- * { 
+ * {
  *      return aul_app_get_running_app_info(iterfunc,NULL);
  * }
  *
@@ -728,7 +727,7 @@ int aul_app_get_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
  * @par Description:
  *     This API get application package name by pid
  * @par Purpose:
- *     If you want to get package name of running application, use this API 
+ *     If you want to get package name of running application, use this API
  * @par Typical use case:
  *     In general, You can use this API when you want to know caller's information.
  *
@@ -737,19 +736,19 @@ int aul_app_get_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
  * @param[in]  len             length of pkgname
  * @return     0 if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
- * @retval     AUL_R_ERROR     - no such a package name 
+ * @retval     AUL_R_ERROR     - no such a package name
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     None
  * @code
  * #include <aul.h>
  * #include <bundle.h>
  *
- * static int app_reset(bundle *b, void *data) 
- * { 
+ * static int app_reset(bundle *b, void *data)
+ * {
  *     int pid;
  *     char appname[255];
  *
@@ -806,15 +805,15 @@ int aul_app_get_appid_bypid(int pid, char *appid, int len);
 /** @} */
 
 /**
- * @defgroup aul_mime High-level APIs to launch default application based on mime type 
+ * @defgroup aul_mime High-level APIs to launch default application based on mime type
  * @ingroup aul
  * @brief
  *   AUL High-level APIs based on mime type
  *
  *   These APIs provide two functionality\n
- *   
+ *
  *   -# To launch default application to open a file based on its MIME type \n
- *   For example, you can launch the default video player to open .mp4 files 
+ *   For example, you can launch the default video player to open .mp4 files
  *   or launch the default browser to open HTML files \n
  *   -# To launch default application to process given content \n
  *   For example, you can launch the default e-mail application to process
@@ -837,9 +836,9 @@ int aul_app_get_appid_bypid(int pid, char *appid, int len);
  *     and then launch the app with filename argument.
  * @par Typical use case:
  *     You can launch application to process given filename.
- *     That is, Even if you don't know the specific application's pkgname, 
- *     you can launch the applicaiton processing given filename . 
- *     For example, If you want to process image file, you can simply launch image viewer. 
+ *     That is, Even if you don't know the specific application's pkgname,
+ *     you can launch the applicaiton processing given filename .
+ *     For example, If you want to process image file, you can simply launch image viewer.
  *     At that time, you can use this APIs like aul_open_file("myimage.jpg");
  *
  * @param[in]  filename        filename
@@ -848,26 +847,26 @@ int aul_app_get_appid_bypid(int pid, char *appid, int len);
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_EINVAL    - invalid argument(filename)
  * @retval     AUL_R_ECOM      - internal AUL IPC error
- * @retval     AUL_R_ERROR     - general error 
+ * @retval     AUL_R_ERROR     - general error
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     None
  * @code
  * #include <aul.h>
  *
  * int view_image_file(char *filename)
- * { 
+ * {
  *      aul_open_file(filename);
  * }
  *
  * @endcode
  * @remark
  *     None
- * 
+ *
  */
 int aul_open_file(const char* filename);
 
@@ -885,7 +884,7 @@ int aul_open_file(const char* filename);
  *     For example, To know mime type of files with DRM lock, first we should unlock DRM file.
  *     In this case, You can use this API.
  *     First, unlock DRM file, and extract mimetype from unlock file by using aul_get_mime_from_file,
- *     and then, use this API with DRM file and extracted mime type. 
+ *     and then, use this API with DRM file and extracted mime type.
  *
  * @param[in]  filename        filename
  * @param[in]  mimetype        specific mimetype
@@ -894,19 +893,19 @@ int aul_open_file(const char* filename);
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_EINVAL    - invalid argument(filename,mimetype)
  * @retval     AUL_R_ECOM      - internal AUL IPC error
- * @retval     AUL_R_ERROR     - general error 
- * 
+ * @retval     AUL_R_ERROR     - general error
+ *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_open_file, aul_get_mime_from_file
  * @code
  * #include <aul.h>
  *
  * int view_drm_image_file(char *drm_filename)
- * { 
+ * {
  *     char* mimetype;
  *     // you must implement this function
  *     mimetype = get_mimetype_from_drmfile(drm_filename);
@@ -930,14 +929,14 @@ int aul_open_file_with_mimetype(const char *filename, const char *mimetype);
  *     and then find default app associated with found mime_type,
  *     and then launch the app with content argument.
  * @par Typical use case:
- *     You can launch application to process given content. 
- *     That is, Even if you don't know the specific application's pkgname, 
- *     you can launch the applicaiton processing given content.  
- *     For example, If you want to process URL "http://www.samsung.com", 
- *     you can simply launch browser. 
+ *     You can launch application to process given content.
+ *     That is, Even if you don't know the specific application's pkgname,
+ *     you can launch the applicaiton processing given content.
+ *     For example, If you want to process URL "http://www.samsung.com",
+ *     you can simply launch browser.
  *     At that time, you can use this APIs like aul_open_content("http://www.samsung.com");
  *
- * @param[in]   content                content 
+ * @param[in]   content                content
  * @return     callee's pid or 0 if success, negative value if fail\n
  *              (when no found default app, return 0)
  * @retval     AUL_R_OK        - success
@@ -947,22 +946,22 @@ int aul_open_file_with_mimetype(const char *filename, const char *mimetype);
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     None
  * @code
  * #include <aul.h>
  *
  * int view_url(char *url)
- * { 
+ * {
  *      aul_open_content(url);
  * }
  *
  * @endcode
  * @remark
  *     None
- * 
+ *
  */
 int aul_open_content(const char* content);
 
@@ -970,8 +969,8 @@ int aul_open_content(const char* content);
  * @par Description:
  *      This API get the default application(appid) associated with MIME type
  * @par Purpose:
- *     This API use to get default application associteted with mimetype 
- *     In general, Setting Application need this API. 
+ *     This API use to get default application associteted with mimetype
+ *     In general, Setting Application need this API.
  * @par Typical use case:
  *     Setting Application show mapping of default application / mimetype
  *
@@ -985,23 +984,23 @@ int aul_open_content(const char* content);
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_set_defapp_with_mime
  * @code
  * #include <aul.h>
- * 
+ *
  * void get_text_html_defapp()
  * {
  *     char appname[255];
  *     aul_get_defapp_from_mime("text/html",appname,sizeof(appname));
  * }
- * 
+ *
  * @endcode
  * @remark
  *     None
- * 
+ *
  */
 int aul_get_defapp_from_mime(const char *mimetype, char *defapp, int len);
 
@@ -1009,33 +1008,33 @@ int aul_get_defapp_from_mime(const char *mimetype, char *defapp, int len);
  * @par Description:
  *      This API set the default application(appid) associated with MIME type
  * @par Purpose:
- *     This API use to change default application associteted with mimetype 
- *     In general, Setting Application or Installer need this API. 
+ *     This API use to change default application associteted with mimetype
+ *     In general, Setting Application or Installer need this API.
  * @par Typical use case:
- *     Default Application associated with mimetype can be changed by Setting Application or installer 
- *     So, application to process specific mimetype can be substituted. 
+ *     Default Application associated with mimetype can be changed by Setting Application or installer
+ *     So, application to process specific mimetype can be substituted.
  *
  * @param[in]  mimetype        a mime type
  * @param[in]  defapp          a application appid of the app to be set
  * @return     0 if success, negative value if fail
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_EINVAL    - invalid argument(mimetype)
- * @retval     AUL_R_ERROR     - general error 
+ * @retval     AUL_R_ERROR     - general error
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_get_defapp_from_mime
  * @code
  * #include <aul.h>
- * 
+ *
  * void set_text_html_defapp()
  * {
  *     aul_set_defapp_with_mime("text/html","org.tizen.browser");
  * }
- * 
+ *
  * @endcode
  * @remark
  *     None
@@ -1046,36 +1045,36 @@ int aul_set_defapp_with_mime(const char *mimetype, const char *defapp);
  * @par Description:
  *     This API get the mimetype associated with filename
  * @par Purpose:
- *     This API use to get mimetype associteted with given filename 
+ *     This API use to get mimetype associteted with given filename
  *     In general, This API use when you want to know only mimetype given filename.
  * @par Typical use case:
- *     For example, In trasfering data through bluetooth, 
+ *     For example, In trasfering data through bluetooth,
  *     additional information like mimetype should be added.
  *     In such situation, You can get mimetype by using this API.
- *     
- * @param[in]  filename        file name 
+ *
+ * @param[in]  filename        file name
  * @param[out] mimetype        a mime type
- * @param[in]  len             length of mimetype 
+ * @param[in]  len             length of mimetype
  * @return     0 if success, negative value if fail
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_EINVAL    - invalid argument(filename)
- * @retval     AUL_R_ERROR     - general error 
- * 
+ * @retval     AUL_R_ERROR     - general error
+ *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     None
  * @code
  * #include <aul.h>
- * 
+ *
  * void get_mimetype()
  * {
  *     char mimetype[255];
  *     aul_get_mime_from_file("image.jpg",mimetype,sizeof(mimetype));
  * }
- * 
+ *
  * @endcode
  * @remark
  *     None
@@ -1084,38 +1083,38 @@ int aul_get_mime_from_file(const char *filename, char *mimetype, int len);
 
 /**
  * @par Description:
- *     This API get the mimetype associated with given content 
+ *     This API get the mimetype associated with given content
  * @par Purpose:
- *     This API use to get mimetype associteted with given content 
- *     In general, This API use when you want to know only mimetype given content 
+ *     This API use to get mimetype associteted with given content
+ *     In general, This API use when you want to know only mimetype given content
  * @par Typical use case:
- *     For example, In trasfering data through bluetooth, 
+ *     For example, In trasfering data through bluetooth,
  *     additional information like mimetype should be added.
  *     In such situation, You can get mimetype by using this API.
  *
- * @param[in]  content         content string like "011-0000-0000" 
+ * @param[in]  content         content string like "011-0000-0000"
  * @param[out] mimetype        a mime type
- * @param[in]  len             length of mimetype 
+ * @param[in]  len             length of mimetype
  * @return     0 if success, negative value if fail
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_EINVAL    - invalid argument(content)
- * @retval     AUL_R_ERROR     - general error 
+ * @retval     AUL_R_ERROR     - general error
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     None
  * @code
  * #include <aul.h>
- * 
+ *
  * void get_mimetype()
  * {
  *     char mimetype[255];
  *     aul_get_mime_from_content("http://www.samsung.com",mimetype,sizeof(mimetype));
  * }
- * 
+ *
  * @endcode
  * @remark
  *     None
@@ -1124,7 +1123,7 @@ int aul_get_mime_from_content(const char *content, char *mimetype, int len);
 
 /**
  * @par Description:
- *     This API get the icon's name associated with given mimetype 
+ *     This API get the icon's name associated with given mimetype
  * @par Purpose:
  *     This API use to get icon's name associteted with given mimetype
  * @par Typical use case:
@@ -1136,23 +1135,23 @@ int aul_get_mime_from_content(const char *content, char *mimetype, int len);
  * @return     0 if success, negative value if fail
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_EINVAL    - invalid argument(content)
- * @retval     AUL_R_ERROR     - general error (no such mime type) 
+ * @retval     AUL_R_ERROR     - general error (no such mime type)
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     None
  * @code
  * #include <aul.h>
- * 
+ *
  * void get_mime_icon()
  * {
  *     char icon[255];
  *     aul_get_mime_icon("text/html",icon,sizeof(icon));
  * }
- * 
+ *
  * @endcode
  * @remark
  *     None
@@ -1161,7 +1160,7 @@ int aul_get_mime_icon(const char *mimetype, char *iconname, int len);
 
 /**
  * @par Description:
- *     This API get the extensions associated with given mimetype 
+ *     This API get the extensions associated with given mimetype
  * @par Purpose:
  *     This API use to get extensions associteted with given mimetype
  * @par Typical use case:
@@ -1175,34 +1174,34 @@ int aul_get_mime_icon(const char *mimetype, char *iconname, int len);
  * @return     0 if success, negative value if fail
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_EINVAL    - invalid argument(mimetype)
- * @retval     AUL_R_ERROR     - general error (no mimetype or no extenstion) 
+ * @retval     AUL_R_ERROR     - general error (no mimetype or no extenstion)
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_get_mime_description
  * @code
  * #include <aul.h>
- * 
+ *
  * void get_extension()
  * {
  *     char extlist[255];
  *     aul_get_mime_extension("text/html",extlist,sizeof(extlist));
  * }
- * 
+ *
  * @endcode
  * @remark
  *     Some mimetype don't have extension.
  *     In that case, You can use aul_get_mime_description.
- * 
+ *
 */
 int aul_get_mime_extension(const char *mimetype, char *extlist, int len);
 
 /**
  * @par Description:
- *     This API get the description associated with given mimetype 
+ *     This API get the description associated with given mimetype
  * @par Purpose:
  *     This API use to get description associteted with given mimetype
  * @par Typical use case:
@@ -1212,22 +1211,22 @@ int aul_get_mime_extension(const char *mimetype, char *extlist, int len);
  *     At that time,to show mimetype information to user, use this API
  *
  * @param[in]  mimetype        a mime type
- * @param[out] desc            description (ex> Call client)   
+ * @param[out] desc            description (ex> Call client)
  * @param[in]  len             length of desc
  * @return     0 if success, negative value if fail
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_EINVAL    - invalid argument(mimetype)
- * @retval     AUL_R_ERROR     - general error (no mimetype or no descrition) 
+ * @retval     AUL_R_ERROR     - general error (no mimetype or no descrition)
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_get_mime_extension
  * @code
  * #include <aul.h>
- * 
+ *
  * void get_information_from_mime()
  * {
  *     char info[255];
@@ -1235,10 +1234,10 @@ int aul_get_mime_extension(const char *mimetype, char *extlist, int len);
  *             aul_get_mime_description("text/html",info,sizeof(info));
  *     }
  * }
- * 
+ *
  * @endcode
  * @remark
- *     None 
+ *     None
  */
 int aul_get_mime_description(const char *mimetype, char *desc, int len);
 
@@ -1258,11 +1257,11 @@ int aul_get_mime_description(const char *mimetype, char *desc, int len);
 /** @} */
 
 /**
- * @defgroup aul_service High-level APIs to launch applications based on service. 
+ * @defgroup aul_service High-level APIs to launch applications based on service.
  * @ingroup aul
  * @brief
- *      AUL High-level APIs based on service 
- * 
+ *      AUL High-level APIs based on service
+ *
  *     This is Request/Response mechanism based on AUL like DBUS service call with auto-activation.\n
  *     We recommend this APIs for requesting application service like camera application service (take_picture)
  *     But, You can use other mechanism like DBUS service or your own internal IPC
@@ -1282,10 +1281,10 @@ int aul_get_mime_description(const char *mimetype, char *desc, int len);
  * @{
  */
 
-/** 
+/**
  * @brief aul_service_res_fn is service result function
- * @param[out] b       result bundle   
- * @param[out] data    user-supplied data      
+ * @param[out] b       result bundle
+ * @param[out] data    user-supplied data
 */
 typedef void (*aul_service_res_fn)(bundle *b, int reserved, void *user_data);
 
@@ -1295,15 +1294,15 @@ typedef void (*aul_service_res_fn)(bundle *b, int reserved, void *user_data);
  * @par Purpose:
  *      This API is for caller.
  *     This API launch application based on service name.
- *     This API find default application associated with service name. 
+ *     This API find default application associated with service name.
  *     and then launch the application with given bundle.
  * @par Typical use case:
  *     You can launch application provided the service if you know service name.
- *     That is, even if you don't know the specific application's pkgname, 
- *     you can launch the applicaiton by requesting the service. 
- *     For example, If you want to take a picture in your app, you can simply launch camera application. 
+ *     That is, even if you don't know the specific application's pkgname,
+ *     you can launch the applicaiton by requesting the service.
+ *     For example, If you want to take a picture in your app, you can simply launch camera application.
  *     At that time, you can use this API like aul_open_service(TAKE_PICTURE_SVC,..);
- *     
+ *
  *
  * @param[in]   svcname         service name to launch as callee
  * @param[in]   b               bundle to be passed to callee
@@ -1314,13 +1313,13 @@ typedef void (*aul_service_res_fn)(bundle *b, int reserved, void *user_data);
  * @retval      AUL_R_EINVAL    - invaild service name
  * @retval      AUL_R_ENOINIT   - you must initilize aul library with aul_launch_init
  * @retval      AUL_R_ECOM      - internal AUL IPC error
- * @retval      AUL_R_ERROR     - general error 
+ * @retval      AUL_R_ERROR     - general error
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     None
  * @code
  * #include <aul.h>
@@ -1329,11 +1328,11 @@ typedef void (*aul_service_res_fn)(bundle *b, int reserved, void *user_data);
  *
  * void res_func(bundle *b, int reserved, void *user_data)
  * {
- *     // process result bundle 
+ *     // process result bundle
  * }
  *
  * int create_camera_view()
- * { 
+ * {
  *      aul_open_service(TAKE_PICTURE_SVC, NULL, res_func, NULL);
  * }
  *
@@ -1341,7 +1340,7 @@ typedef void (*aul_service_res_fn)(bundle *b, int reserved, void *user_data);
  * @remark
  *     This API can wait result (asynchronous).
  *     To see kinds of default service provided by platform, see "aul_service.h" header file
- * 
+ *
  */
 int aul_open_service(const char *svcname, bundle *b, aul_service_res_fn cbfunc, void *data);
 
@@ -1354,20 +1353,20 @@ int aul_open_service(const char *svcname, bundle *b, aul_service_res_fn cbfunc,
  *     This API is for callee which provide application service.\n
  *      To send result to caller, You must create result bundle. \n
  *      Callee(application providing the service) can send result by using this API and aul_send_service_result.
- * 
- * @param[in]   inb             bundle received in reset event 
- * @param[out]  outb            bundle to use for returning result 
+ *
+ * @param[in]   inb             bundle received in reset event
+ * @param[out]  outb            bundle to use for returning result
  * @return      0 if success, negative value(<0) if fail
  * @retval      AUL_R_OK        - success
  * @retval      AUL_R_EINVAL    - inb is not bundle created by aul_open_service
- * @retval      AUL_R_ERROR     - general error 
+ * @retval      AUL_R_ERROR     - general error
  *
  * @pre
  *     To create result bundle, You need received original bundle.
  *     The original bundle can get from app_reset handler.
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_send_service_result
  * @code
  * #include <aul.h>
@@ -1377,7 +1376,7 @@ int aul_open_service(const char *svcname, bundle *b, aul_service_res_fn cbfunc,
  * {
  *      ad->recved_bundle = bundle_dup(b);
  * }
- * 
+ *
  * int click_ok()
  * {
  *      bundle* res_bundle;
@@ -1388,7 +1387,7 @@ int aul_open_service(const char *svcname, bundle *b, aul_service_res_fn cbfunc,
  * @endcode
  * @remark
  *     None
- * 
+ *
  */
 int aul_create_result_bundle(bundle *inb, bundle **outb);
 
@@ -1407,14 +1406,14 @@ int aul_create_result_bundle(bundle *inb, bundle **outb);
  * @retval      AUL_R_OK        - success
  * @retval      AUL_R_EINVAL    - invalid result bundle
  * @retval      AUL_R_ECOMM     - internal AUL IPC error
- * @retval      AUL_R_ERROR     - general error 
+ * @retval      AUL_R_ERROR     - general error
  *
  * @pre
- *     To send result bundle, You must create result bundle. 
- *      see aul_create_result_bundle   
- * @post 
+ *     To send result bundle, You must create result bundle.
+ *      see aul_create_result_bundle
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_create_result_bundle
  * @code
  * #include <aul.h>
@@ -1424,7 +1423,7 @@ int aul_create_result_bundle(bundle *inb, bundle **outb);
  * {
  *      ad->recved_bundle = bundle_dup(b);
  * }
- * 
+ *
  * int click_ok()
  * {
  *      bundle* res_bundle;
@@ -1435,7 +1434,7 @@ int aul_create_result_bundle(bundle *inb, bundle **outb);
  * @endcode
  * @remark
  *     None
- * 
+ *
  */
 int aul_send_service_result(bundle *b);
 
@@ -1444,37 +1443,37 @@ int aul_send_service_result(bundle *b);
  *     This API set the default application(appid) associated with service name
  * @par Purpose:
  *     This API use to change default application associteted with service name
- *     In general, Setting Application needs this API. 
+ *     In general, Setting Application needs this API.
  * @par Typical use case:
- *     Default Application associated with service name can be changed by Setting Application 
- *     So, Inhouse service application can be substituted by 3rd party service application 
+ *     Default Application associated with service name can be changed by Setting Application
+ *     So, Inhouse service application can be substituted by 3rd party service application
  *
- * @param[in]  svcname         service string like "create_contact" 
- * @param[in]  defapp          default application like "org.tizen.contact"    
+ * @param[in]  svcname         service string like "create_contact"
+ * @param[in]  defapp          default application like "com.samsung.contact"
  * @return     0 if success, negative value if fail
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_EINVAL    - invalid argument(content)
- * @retval     AUL_R_ERROR     - general error 
+ * @retval     AUL_R_ERROR     - general error
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_get_defapp_for_service
  * @code
  * #include <aul.h>
  * #include <aul_service.h>
- * 
+ *
  * void set_camera_service_defapp()
  * {
- *     aul_set_defapp_for_service(TAKE_PICTURE_SVC,"org.tizen.camera");
+ *     aul_set_defapp_for_service(TAKE_PICTURE_SVC,"com.samsung.camera");
  * }
- * 
+ *
  * @endcode
  * @remark
  *     None
- * 
+ *
  */
 int aul_set_defapp_for_service(const char *svcname, const char *defapp);
 
@@ -1483,38 +1482,38 @@ int aul_set_defapp_for_service(const char *svcname, const char *defapp);
  *     This API get the application appid associated with given service name
  * @par Purpose:
  *     This API use to get default application associteted with service name
- *     In general, Setting Application need this API. 
+ *     In general, Setting Application need this API.
  * @par Typical use case:
- *     Setting Application show mapping of default application/ service 
- * 
- * @param[in]  svcname         service string like "create_contact" 
- * @param[out] defapp          default application     
+ *     Setting Application show mapping of default application/ service
+ *
+ * @param[in]  svcname         service string like "create_contact"
+ * @param[out] defapp          default application
  * @param[in]  len             length of defapp
  * @return     0 if success, negative value if fail
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_EINVAL    - invalid argument(content)
- * @retval     AUL_R_ERROR     - general error 
+ * @retval     AUL_R_ERROR     - general error
  *
  * @pre
  *     None
- * @post 
+ * @post
  *     None
- * @see 
+ * @see
  *     aul_set_defapp_for_service
  * @code
  * #include <aul.h>
  * #include <aul_service.h>
- * 
+ *
  * void get_camera_service_defapp()
  * {
  *     char appname[255];
  *     aul_get_defapp_for_service(TAKE_PICTURE_SVC,appname,sizeof(appname));
  * }
- * 
+ *
  * @endcode
  * @remark
  *     None
- * 
+ *
  */
 int aul_get_defapp_for_service(const char *svcname, char *defapp, int len);
 
index e4c4630..d6f300d 100755 (executable)
@@ -34,6 +34,7 @@ typedef struct _app_status_info_t{
        char app_path[MAX_PACKAGE_APP_PATH_SIZE];
        int status;
        int pid;
+       int pad_pid;
 } app_status_info_t;
 
 struct amdmgr {
index d08a9f5..a836de9 100755 (executable)
@@ -94,7 +94,7 @@ _static_ int __raise_win_by_x(int pid);
 _static_ int __send_to_sigkill(int pid);
 _static_ int __term_app(int pid);
 _static_ int __resume_app(int pid);
-_static_ void __real_send(int clifd, int ret);
+_static_ int __real_send(int clifd, int ret);
 _static_ void __send_result_to_caller(int clifd, int ret);
 _static_ void __launchpad_main_loop(int main_fd);
 _static_ int __launchpad_pre_init(int argc, char **argv);
@@ -273,11 +273,13 @@ _static_ void __real_launch(const char *app_path, bundle * kb)
        app_argv = __create_argc_argv(kb, &app_argc);
        app_argv[0] = strdup(app_path);
 
-       for (i = 0; i < app_argc; i++)
-               _D("input argument %d : %s##", i, app_argv[i]);
+       for (i = 0; i < app_argc; i++) {
+               if( (i%2) == 1)
+                       continue;
+               SECURE_LOGD("input argument %d : %s##", i, app_argv[i]);
+       }
 
        PERF("setup argument done");
-       _E("lock up test log(no error) : setup argument done");
 
        /* Temporary log: launch time checking */
        LOG(LOG_DEBUG, "LAUNCH", "[%s:Platform:launchpad:done]", app_path);
@@ -408,7 +410,7 @@ _static_ void __modify_bundle(bundle * kb, int caller_pid,
                        char value[256];
 
                        ptr += flag;
-                       _D("parsing app_path: EXEC - %s\n", exe);
+                       SECURE_LOGD("parsing app_path: EXEC - %s\n", exe);
 
                        do {
                                flag = __parser(ptr, key, sizeof(key));
@@ -554,16 +556,19 @@ _static_ int __foward_cmd(int cmd, bundle *kb, int cr_pid)
        return res;
 }
 
-_static_ void __real_send(int clifd, int ret)
+_static_ int __real_send(int clifd, int ret)
 {
        if (send(clifd, &ret, sizeof(int), MSG_NOSIGNAL) < 0) {
                if (errno == EPIPE) {
                        _E("send failed due to EPIPE.\n");
+                       close(clifd);
+                       return -1;
                }
                _E("send fail to client");
        }
 
        close(clifd);
+       return 0;
 }
 
 _static_ void __send_result_to_caller(int clifd, int ret)
@@ -572,6 +577,7 @@ _static_ void __send_result_to_caller(int clifd, int ret)
        int wait_count;
        int cmdline_changed = 0;
        int cmdline_exist = 0;
+       int r;
 
        if (clifd == -1)
                return;
@@ -609,7 +615,12 @@ _static_ void __send_result_to_caller(int clifd, int ret)
        if (!cmdline_changed)
                _E("process launched, but cmdline not changed");
 
-       __real_send(clifd, ret);
+       if(__real_send(clifd, ret) < 0) {
+               r = kill(ret, SIGKILL);
+               if (r == -1)
+                       _E("send SIGKILL: %s", strerror(errno));
+       }
+       
        return;
 }
 
@@ -669,7 +680,7 @@ _static_ void __launchpad_main_loop(int main_fd)
        PERF("packet processing start");
 
        pkg_name = bundle_get_val(kb, AUL_K_PKG_NAME);
-       _D("pkg name : %s\n", pkg_name);
+       SECURE_LOGD("pkg name : %s\n", pkg_name);
 
        menu_info = _get_app_info_from_bundle_by_pkgname(pkg_name, kb);
        if (menu_info == NULL) {
@@ -696,7 +707,7 @@ _static_ void __launchpad_main_loop(int main_fd)
                pid = fork();
                if (pid == 0) {
                        PERF("fork done");
-                       _E("lock up test log(no error) : fork done");
+                       _D("lock up test log(no error) : fork done");
 
                        close(clifd);
                        close(main_fd);
@@ -707,23 +718,23 @@ _static_ void __launchpad_main_loop(int main_fd)
                        unlink(sock_path);
 
                        PERF("prepare exec - first done");
-                       _E("lock up test log(no error) : prepare exec - first done");
+                       _D("lock up test log(no error) : prepare exec - first done");
 
                        if (__prepare_exec(pkg_name, app_path,
                                           menu_info, kb) < 0) {
-                               _E("preparing work fail to launch - "
+                               SECURE_LOGE("preparing work fail to launch - "
                                   "can not launch %s\n", pkg_name);
                                exit(-1);
                        }
 
                        PERF("prepare exec - second done");
-                       _E("lock up test log(no error) : prepare exec - second done");
+                       _D("lock up test log(no error) : prepare exec - second done");
 
                        __real_launch(app_path, kb);
 
                        exit(-1);
                }
-               _D("==> real launch pid : %d %s\n", pid, app_path);
+               SECURE_LOGD("==> real launch pid : %d %s\n", pid, app_path);
                is_real_launch = 1;
        }
 
index 36c546e..0b60365 100644 (file)
@@ -118,6 +118,7 @@ systemctl daemon-reload
 %attr(0755,root,root) %{_bindir}/aul_mime.sh
 %{_bindir}/aul_test
 %{_bindir}/launch_app
+%{_bindir}/open_app
 /usr/share/aul/miregex/*
 /usr/share/aul/service/*
 /usr/share/aul/preload_list.txt
index 1c31577..5759a83 100755 (executable)
@@ -313,11 +313,15 @@ int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen)
                pkt = NULL;
        }
 
+retry_recv:
        len = recv(fd, &res, sizeof(int), 0);
        if (len == -1) {
                if (errno == EAGAIN) {
                        _E("recv timeout : %s", strerror(errno));
                        res = -EAGAIN;
+               } else if (errno == EINTR) {
+                       _D("recv : %s", strerror(errno));
+                       goto retry_recv;
                } else {
                        _E("recv error : %s", strerror(errno));
                        res = -ECOMM;
@@ -400,6 +404,76 @@ int __app_send_raw_with_noreply(int pid, int cmd, unsigned char *kb_data, int da
        return res;
 }
 
+int __app_send_raw_with_delay_reply(int pid, int cmd, unsigned char *kb_data, int datalen)
+{
+       int fd;
+       int len;
+       int ret;
+       int res = 0;
+       app_pkt_t *pkt = NULL;
+
+       if (kb_data == NULL || datalen > AUL_SOCK_MAXBUFF - 8) {
+               _E("keybundle error\n");
+               return -EINVAL;
+       }
+
+       _D("pid(%d) : cmd(%d)", pid, cmd);
+
+       fd = __create_client_sock(pid);
+       if (fd < 0)
+               return -ECOMM;
+
+       pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+       if (NULL == pkt) {
+               _E("Malloc Failed!");
+               return -ENOMEM;
+       }
+       memset(pkt, 0, AUL_SOCK_MAXBUFF);
+
+       pkt->cmd = cmd;
+       pkt->len = datalen;
+       memcpy(pkt->data, kb_data, datalen);
+
+       if ((len = send(fd, pkt, datalen + 8, 0)) != datalen + 8) {
+               _E("sendto() failed - %d %d (errno %d)", len, datalen + 8, errno);
+               if(len > 0) {
+                       while (len != datalen + 8) {
+                               ret = send(fd, &pkt->data[len-8], datalen + 8 - len, 0);
+                               if (ret < 0) {
+                                       _E("second sendto() failed - %d %d (errno %d)", ret, datalen + 8, errno);
+                                       if (errno == EPIPE) {
+                                               _E("pid:%d, fd:%d\n", pid, fd);
+                                       }
+                                       close(fd);
+                                       if (pkt) {
+                                               free(pkt);
+                                               pkt = NULL;
+                                       }
+                                       return -ECOMM;
+                               }
+                               len += ret;
+                               _D("sendto() len - %d %d", len, datalen + 8);
+                       }
+               } else {
+                       if (errno == EPIPE) {
+                               _E("pid:%d, fd:%d\n", pid, fd);
+                       }
+                       close(fd);
+                       if (pkt) {
+                               free(pkt);
+                               pkt = NULL;
+                       }
+                       return -ECOMM;
+               }
+       }
+       if (pkt) {
+               free(pkt);
+               pkt = NULL;
+       }
+
+       return fd;
+}
+
 app_pkt_t *__app_recv_raw(int fd, int *clifd, struct ucred *cr)
 {
        int len;
index 51fc466..0fd263e 100755 (executable)
@@ -230,7 +230,7 @@ int app_request_to_launchpad(int cmd, const char *pkgname, bundle *kb)
        int must_free = 0;
        int ret = 0;
 
-       _D("launch request : %s", pkgname);
+       SECURE_LOGD("launch request : %s", pkgname);
        if (kb == NULL) {
                kb = bundle_create();
                must_free = 1;
@@ -273,8 +273,11 @@ int app_request_to_launchpad(int cmd, const char *pkgname, bundle *kb)
 static int __send_result_to_launchpad(int fd, int res)
 {
        if (send(fd, &res, sizeof(int), MSG_NOSIGNAL) < 0) {
-               if (errno == EPIPE)
+               if (errno == EPIPE) {
                        _E("send failed due to EPIPE.\n");
+                       close(fd);
+                       return -1;
+               }
                _E("send fail to client");
        }
        close(fd);
@@ -293,6 +296,7 @@ int aul_sock_handler(int fd)
 
        const char *pid_str;
        int pid;
+       int ret;
 
        if ((pkt = __app_recv_raw(fd, &clifd, &cr)) == NULL) {
                _E("recv error");
@@ -307,7 +311,11 @@ int aul_sock_handler(int fd)
        }
 
        if (pkt->cmd != APP_RESULT && pkt->cmd != APP_CANCEL) {
-               __send_result_to_launchpad(clifd, 0);
+               ret = __send_result_to_launchpad(clifd, 0);
+               if (ret < 0) {
+                       free(pkt);
+                       return -1;
+               }
        } else {
                close(clifd);
        }
@@ -426,7 +434,7 @@ int aul_register_init_callback(
 int aul_initialize()
 {
        if (aul_initialized) {
-               _E("aul already initialized");
+               //_E("aul already initialized");
                return AUL_R_ECANCELED;
        }
 
index 62b6904..60fd2ec 100755 (executable)
@@ -457,10 +457,15 @@ SLPAPI int aul_subapp_terminate_request_pid(int pid)
 {
        char pid_str[MAX_PID_STR_BUFSZ];
        int ret;
+       app_resultcb_info_t *info;
 
        if (pid <= 0)
                return AUL_R_EINVAL;
 
+       info = __find_resultcb(pid);
+       if(info)
+               __remove_resultcb(info);
+
        snprintf(pid_str, MAX_PID_STR_BUFSZ, "%d", pid);
        ret = app_request_to_launchpad(APP_TERM_REQ_BY_PID, pid_str, NULL);
        return ret;
index be597a1..f61eef7 100755 (executable)
@@ -333,7 +333,7 @@ int mida_add_app(const char *mime_type, const char *pkg_name)
        cnt = __count_with_field(MIDA_TBL_NAME, MIDA_F_MIMETYPE, mime_type, 0);
 
        if (cnt == 0) {
-               _D("Inserting (%s, %s)", pkg_name, mime_type);
+               SECURE_LOGD("Inserting (%s, %s)", pkg_name, mime_type);
                /* insert */
                _sqlbuf = sqlite3_mprintf(
                            "INSERT INTO %s (%s,%s) values (\"%s\", \"%s\");",
@@ -343,7 +343,7 @@ int mida_add_app(const char *mime_type, const char *pkg_name)
                rc = _exec(mida_db, _sqlbuf);
                sqlite3_free(_sqlbuf);
        } else {
-               _D("Setting %s for %s", pkg_name, mime_type);
+               SECURE_LOGD("Setting %s for %s", pkg_name, mime_type);
                /* update */
                _sqlbuf = sqlite3_mprintf(
                                    "UPDATE %s SET %s = '%s' where %s = '%s';",
@@ -442,7 +442,7 @@ int svc_add_app(const char *svc_name, const char *pkg_name)
 
        if (cnt == 0) {
                /* insert */
-               _D("Inserting (%s, %s)", pkg_name, svc_name);
+               SECURE_LOGD("Inserting (%s, %s)", pkg_name, svc_name);
                _sqlbuf = sqlite3_mprintf(
                     "INSERT INTO %s (%s,%s) values (\"%s\", \"%s\");",
                     SVC_TBL_NAME, SVC_F_PKGNAME, SVC_F_SVCNAME, pkg_name,
@@ -452,7 +452,7 @@ int svc_add_app(const char *svc_name, const char *pkg_name)
                sqlite3_free(_sqlbuf);
        } else {
                /* update */
-               _D("Setting %s for %s", pkg_name, svc_name);
+               SECURE_LOGD("Setting %s for %s", pkg_name, svc_name);
                _sqlbuf = sqlite3_mprintf(
                                    "UPDATE %s SET %s = '%s' where %s = '%s';",
                                    SVC_TBL_NAME, SVC_F_PKGNAME, pkg_name,
@@ -508,7 +508,7 @@ int is_supported_svc(const char *svc_name)
        if (cnt > 0)
                rc = 1;
        else
-               _D("%s is not supported.", svc_name);
+               SECURE_LOGD("%s is not supported.", svc_name);
 
        __fini();
        return rc;
index a6d48ee..0715a74 100755 (executable)
@@ -70,7 +70,7 @@ SLPAPI int aul_get_mime_from_content(const char *content, char *mimetype,
                if (__match_content_with_regex(content,
                        &(miregex_tbl->regex_preg))) {
                        founded = miregex_tbl->mimetype;
-                       _D("content %s => mimetype %s\n", content, founded);
+                       SECURE_LOGD("content %s => mimetype %s\n", content, founded);
                        break;
                }
                miregex_tbl = miregex_tbl->next;
@@ -350,7 +350,7 @@ static int __launch_with_defapp(const char *mime_type, const char *mime_content)
        if (_aul_get_defapp_from_mime
            (mime_type, unaliased_mime_type, defapp,
             sizeof(unaliased_mime_type), sizeof(defapp)) < 0) {
-               _D("mimetype : %s, unaliased mimetype : %s, mime_content : %s,"
+               SECURE_LOGD("mimetype : %s, unaliased mimetype : %s, mime_content : %s,"
                        " no default app", mime_type, 
                                unaliased_mime_type, mime_content);
                bundle_add(kb, AUL_K_UNALIASED_MIME_TYPE, unaliased_mime_type);
@@ -365,7 +365,7 @@ static int __launch_with_defapp(const char *mime_type, const char *mime_content)
 
                if (ail_ret == AIL_ERROR_OK) {
                        ail_destroy_appinfo(handle);
-                       _D("mimetype : %s, unaliased mimetype : %s, "
+                       SECURE_LOGD("mimetype : %s, unaliased mimetype : %s, "
                                "mime_content : %s, defapp : %s", mime_type, 
                                        unaliased_mime_type, 
                                                mime_content, defapp);
@@ -373,14 +373,14 @@ static int __launch_with_defapp(const char *mime_type, const char *mime_content)
                                   unaliased_mime_type);
                        ret = aul_launch_app(defapp, kb);
                } else if (ail_ret == AIL_ERROR_NO_DATA) {
-                       _D("defapp %s for mimetype : %s, mime_content : %s "
+                       SECURE_LOGD("defapp %s for mimetype : %s, mime_content : %s "
                                "does NOT exist", defapp, 
                                        mime_type, mime_content);
                        mida_delete_with_pkgname(defapp);
                        ail_destroy_appinfo(handle);
                        goto retry;
                } else {
-                       _E("ail_get_appinfo with %s failed", defapp);
+                       SECURE_LOGE("ail_get_appinfo with %s failed", defapp);
                        if (kb) {
                                bundle_free(kb);
                                kb = NULL;
index 245b51d..417f0cd 100755 (executable)
@@ -122,11 +122,11 @@ SLPAPI int aul_app_get_appid_bypid(int pid, char *appid, int len)
 
        if(pid == getpid() || getuid()==0 || geteuid()==0) {
                if (__get_pkgname_bypid(pid, appid, len) == 0) {
-                       _D("appid for %d is %s", pid, appid);
+                       SECURE_LOGD("appid for %d is %s", pid, appid);
                        return AUL_R_OK;
                }
                /* support app launched by shell script*/
-               _D("second chance");
+
                pgid = getpgid(pid);
                if (pgid <= 1)
                        return AUL_R_ERROR;
index 547d3d9..5da396d 100644 (file)
@@ -12,6 +12,11 @@ add_executable(launch_app
 target_link_libraries(launch_app aul ${pkgs_LDFLAGS})
 INSTALL(TARGETS launch_app DESTINATION bin)
 
+add_executable(open_app
+                open_app.c)
+target_link_libraries(open_app aul ${pkgs_LDFLAGS})
+INSTALL(TARGETS open_app DESTINATION bin)
+
 add_executable(dbusapp_test
                dbusapp_test.c) 
 target_link_libraries(dbusapp_test aul ${pkgs_LDFLAGS})
diff --git a/test/open_app.c b/test/open_app.c
new file mode 100755 (executable)
index 0000000..d9b677c
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ *  aul
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+#include <Ecore.h>
+#include "aul.h"
+
+#define ROOT_UID 0
+#define TMP_FILE "/tmp/.testpkg"
+
+static char **gargv;
+static int gargc;
+bundle *kb = NULL;
+
+
+static bundle *create_internal_bundle(int start)
+{
+       bundle *kb;
+       int i;
+       char arg[1024] = {0, };
+       char* val_array[128];
+
+       kb = bundle_create();
+       for (i = start; i < gargc - 1; i++) {
+               if ((i + 1) > gargc - 1)
+                       bundle_add(kb, gargv[i], " ");
+               else {
+                       int j = 1;
+                       strncpy(arg, gargv[i + 1], 1023);
+                       val_array[0] = strtok(arg,",");
+                       while(1)
+                       {
+                               val_array[j] = strtok(NULL,",");
+                               if(val_array[j] == NULL)
+                                       break;
+                               j++;
+                       }
+                       if(j==1)
+                               bundle_add(kb, gargv[i], gargv[i + 1]);
+                       else if(j>1)
+                               bundle_add_str_array(kb, gargv[i],
+                                       (const char**)val_array, j);
+               }
+       }
+
+       return kb;
+}
+
+int launch()
+{
+       FILE *fp;
+       int ret = -1;
+       int pid = -1;
+
+       kb = create_internal_bundle(2);
+       if (NULL == kb) {
+               printf("bundle creation fail\n");
+               return -1;
+       }
+
+       pid = aul_open_app(gargv[1]);
+
+       /* Write the package name to TMP_FILE*/
+       fp = fopen(TMP_FILE, "w");
+       if (fp == NULL)
+               return -1;
+       ret = fprintf(fp, "%d", pid);
+       fclose(fp);
+       if (ret < 0)
+               return -1;
+
+       return pid;
+}
+
+void print_usage(char *progname)
+{
+       printf("[usage] %s <appid>\n",
+              progname);
+}
+
+static int __launch_app_dead_handler(int pid, void *data)
+{
+       int listen_pid = (int) data;
+
+       if(listen_pid == pid)
+               ecore_main_loop_quit();
+
+       return 0;
+}
+
+static Eina_Bool run_func(void *data)
+{
+       int pid = -1;
+       char *str = NULL;
+       if ((pid = launch()) > 0) {
+               printf("... successfully launched\n");
+       } else {
+               printf("... launch failed\n");
+       }
+
+       str = bundle_get_val(kb, "__LAUNCH_APP_MODE__");
+
+       if( str && strcmp(str, "SYNC") == 0 ) {
+               aul_listen_app_dead_signal(__launch_app_dead_handler, pid);
+       } else {
+               ecore_main_loop_quit();
+       }
+
+       if (kb) {
+               bundle_free(kb);
+               kb = NULL;
+       }
+
+       return 0;
+}
+
+int main(int argc, char **argv)
+{
+       if (argc < 2) {
+               print_usage(argv[0]);
+               exit(EXIT_FAILURE);
+       }
+
+       ecore_init();
+
+       gargc = argc;
+       gargv = argv;
+
+       aul_launch_init(NULL, NULL);
+
+       ecore_idler_add(run_func, NULL);
+
+       ecore_main_loop_begin();
+
+       return 0;
+}
+