fixed running list bug
authorJaeho Lee <jaeho81.lee@samsung.com>
Thu, 13 Dec 2012 08:46:49 +0000 (17:46 +0900)
committerJaeho Lee <jaeho81.lee@samsung.com>
Thu, 13 Dec 2012 09:09:11 +0000 (18:09 +0900)
Signed-off-by: Jaeho Lee <jaeho81.lee@samsung.com>
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
packaging/aul.spec

index bcf5f6e..293c251 100755 (executable)
@@ -438,7 +438,7 @@ int __sat_ui_launch(char* appid, bundle* kb, int cmd, int caller_pid, int fd)
        snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", caller_pid);
        bundle_add(kb, AUL_K_CALLER_PID, tmp_pid);
 
-       pid = _status_app_is_running(appid);
+       pid = _status_app_is_running_v2(appid);
 
        if (pid > 0) {
                if (caller_pid == pid) {
@@ -457,7 +457,7 @@ int __sat_ui_launch(char* appid, bundle* kb, int cmd, int caller_pid, int fd)
        __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);
                ac_server_check_launch_privilege(appid, "rpm", pid);
        }
 
@@ -496,7 +496,7 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, int fd)
        if (componet && strncmp(componet, "ui", 2) == 0) {
                multiple = appinfo_get_value(ai, AIT_MULTI);
                if (!multiple || strncmp(multiple, "false", 5) == 0) {
-                       pid = _status_app_is_running(appid);
+                       pid = _status_app_is_running_v2(appid);
                }
 
                if (pid > 0) {
@@ -515,7 +515,7 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, int fd)
                        //_add_cgroup(_lcg, appid, pid);
                }
        } else if (componet && strncmp(componet, "svc", 3) == 0) {
-               pid = _status_app_is_running(appid);
+               pid = _status_app_is_running_v2(appid);
                if (pid > 0) {
                        if ((ret = __nofork_processing(cmd, pid, kb)) < 0) {
                                pid = ret;
@@ -547,7 +547,7 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, int fd)
        __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);
                ac_server_check_launch_privilege(appid, appinfo_get_value(ai, AIT_TYPE), pid);
        }
 
index ee432c4..6ceb4b8 100755 (executable)
@@ -258,6 +258,7 @@ static int __init()
        cgutil_create(MOUNT_PATH, AGENT_PATH, &amd.cg);
        _requset_init(&amd);
        _launch_init(&amd);
+       _status_init(&amd);
 
 #ifndef __i386__
        _key_init();
index 59e3850..f1e3312 100755 (executable)
@@ -338,13 +338,13 @@ static gboolean __request_handler(gpointer data)
                free(pkt);
                break;
        case APP_RUNNING_INFO:
-               _status_send_running_appinfo(clifd);
+               _status_send_running_appinfo_v2(clifd);
                free(pkt);
                break;
        case APP_IS_RUNNING:
                appid = malloc(MAX_PACKAGE_STR_SIZE);
                strncpy(appid, (const char*)pkt->data, MAX_PACKAGE_STR_SIZE-1);
-               ret = _status_app_is_running(appid);
+               ret = _status_app_is_running_v2(appid);
                _D("APP_IS_RUNNING : %s : %d",appid, ret);
                __send_result_to_client(clifd, ret);
                free(pkt);
@@ -373,12 +373,13 @@ static gboolean __request_handler(gpointer data)
                free(pkt);
                break;
        case APP_RUNNING_LIST_UPDATE:
-               kb = bundle_decode(pkt->data, pkt->len);
+               /*kb = bundle_decode(pkt->data, pkt->len);
                appid = (char *)bundle_get_val(kb, AUL_K_APPID);
                app_path = (char *)bundle_get_val(kb, AUL_K_EXEC);
                tmp_pid = (char *)bundle_get_val(kb, AUL_K_PID);
                pid = atoi(tmp_pid);
-               ret = _status_add_app_info_list(appid, app_path, pid);
+               ret = _status_add_app_info_list(appid, app_path, pid);*/
+               ret = 0;
                __send_result_to_client(clifd, ret);
                free(pkt);
                break;
index 35fc38a..b61d86d 100755 (executable)
 
 #include "amd_config.h"
 #include "amd_status.h"
+#include "amd_appinfo.h"
 #include "aul_util.h"
 #include "simple_util.h"
 #include "app_sock.h"
+#include "menu_db_util.h"
 
 GSList *app_status_info_list = NULL;
 
+struct appinfomgr *_saf = NULL;
+
 int _status_add_app_info_list(char *appid, char *app_path, int pid)
 {
        GSList *iter = NULL;
@@ -171,3 +175,100 @@ int _status_send_running_appinfo(int fd)
        return 0;
 }
 
+int _status_app_is_running_v2(char *appid)
+{
+       char *apppath = NULL;
+       int ret = 0;
+       int i = 0;
+       struct appinfo *ai;
+
+       if(appid == NULL)
+               return -1;
+
+       ai = appinfo_find(_saf, appid);
+
+       if(ai == NULL)
+               return -1;
+
+       apppath = strdup(appinfo_get_value(ai, AIT_EXEC));
+
+       /*truncate apppath if it includes default bundles */
+       while (apppath[i] != 0) {
+               if (apppath[i] == ' ' || apppath[i] == '\t') {
+                       apppath[i]='\0';
+                       break;
+               }
+               i++;
+       }
+
+       ret = __proc_iter_cmdline(NULL, apppath);
+
+       free(apppath);
+
+       return ret;
+}
+
+static int __get_pkginfo(const char *dname, const char *cmdline, void *priv)
+{
+       app_info_from_db *menu_info;
+       char *r_info;
+
+       r_info = (char *)priv;
+
+       if ((menu_info = _get_app_info_from_db_by_apppath(cmdline)) == NULL)
+               goto out;
+       else {
+               strncat(r_info, dname, 8);
+               strncat(r_info, ":", 1);
+               strncat(r_info, _get_pkgname(menu_info), MAX_PACKAGE_STR_SIZE);
+               strncat(r_info, ":", 1);
+               strncat(r_info, _get_app_path(menu_info), MAX_PACKAGE_APP_PATH_SIZE);
+               strncat(r_info, ";", 1);
+       }
+
+ out:
+       if (menu_info != NULL)
+               _free_app_info_from_db(menu_info);
+       return 0;
+}
+
+int _status_send_running_appinfo_v2(int fd)
+{
+       app_pkt_t *pkt = NULL;
+       int len;
+
+       pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+       if(!pkt) {
+               _E("malloc fail");
+               close(fd);
+               return 0;
+       }
+
+       memset(pkt, 0, AUL_SOCK_MAXBUFF);
+
+       __proc_iter_cmdline(__get_pkginfo, pkt->data);
+
+       pkt->cmd = APP_RUNNING_INFO_RESULT;
+       pkt->len = strlen((char *)pkt->data) + 1;
+
+       if ((len = send(fd, pkt, pkt->len + 8, 0)) != pkt->len + 8) {
+               if (errno == EPIPE)
+                       _E("send failed due to EPIPE.\n");
+               _E("send fail to client");
+       }
+
+       if(pkt)
+               free(pkt);
+
+       close(fd);
+
+       return 0;
+}
+
+int _status_init(struct amdmgr* amd)
+{
+       _saf = amd->af;
+
+       return 0;
+}
+
index 4f532c2..5b55d56 100755 (executable)
@@ -26,6 +26,9 @@ int _status_update_app_info_list(int pid, int status);
 int _status_remove_app_info_list(int pid);
 int _status_app_is_running(char *appid);
 int _status_send_running_appinfo(int fd);
+int _status_app_is_running_v2(char *appid);
+int _status_send_running_appinfo_v2(int fd);
+
 
 
 //TODO : remove
index f952fd1..a36fd6a 100644 (file)
@@ -1,6 +1,6 @@
 Name:       aul
 Summary:    App utility library
-Version:    0.0.214
+Version:    0.0.218
 Release:    1
 Group:      System/Libraries
 License:    Apache License, Version 2.0