merge private
authorJaeho Lee <jaeho81.lee@samsung.com>
Tue, 18 Jun 2013 06:01:26 +0000 (15:01 +0900)
committerJaeho Lee <jaeho81.lee@samsung.com>
Tue, 18 Jun 2013 06:01:26 +0000 (15:01 +0900)
1. added new API
2. support valgrind
3. fixed media key bug

Signed-off-by: Jaeho Lee <jaeho81.lee@samsung.com>
am_daemon/amd_appinfo.c
am_daemon/amd_key.c
am_daemon/amd_request.c
include/app_sock.h
include/aul.h
src/app_sock.c
src/launch.c
src/launch_with_result.c
src/simple_util.c
test/aul_test.c

index 1e3e9fd..e4c5847 100755 (executable)
@@ -221,7 +221,7 @@ static int _read_pkg_info(struct appinfomgr *cf)
 {
        int r;
 
-       r = pkgmgrinfo_appinfo_get_installed_list(__app_info_insert_handler, cf);
+       r = pkgmgrinfo_appinfo_get_install_list(__app_info_insert_handler, cf);
 
        return r;
 }
index 3eafc81..5a4b038 100755 (executable)
@@ -141,11 +141,12 @@ int _unregister_key_event(int pid)
        GSList *entry;
        int *pid_data;
 
-       for (entry = key_pid_list; entry; entry = entry->next) {
+       for (entry = key_pid_list; entry;) {
                if (entry->data) {
                        pid_data = (int *) entry->data;
+                       entry = entry->next;
                        if(pid == *pid_data) {
-                               key_pid_list = g_slist_remove(key_pid_list, entry->data);
+                               key_pid_list = g_slist_remove(key_pid_list, pid_data);
                                free(pid_data);
                        }
                }
index be5a3f1..1f18e0e 100755 (executable)
@@ -135,6 +135,7 @@ static int __app_process_by_pid(int cmd,
 {
        int pid;
        int ret = -1;
+       int dummy;
 
        if (pkg_name == NULL)
                return -1;
@@ -160,6 +161,11 @@ static int __app_process_by_pid(int cmd,
        case APP_KILL_BY_PID:
                if ((ret = _send_to_sigkill(pid)) < 0)
                        _E("fail to killing - %d\n", pid);
+               break;
+       case APP_TERM_REQ_BY_PID:
+               if ((ret = __app_send_raw(pid, APP_TERM_REQ_BY_PID, (unsigned char *)&dummy, sizeof(int))) < 0) {
+                       _D("terminate req packet send error");
+               }
        }
 
        return ret;
@@ -336,6 +342,7 @@ static gboolean __request_handler(gpointer data)
                case APP_TERM_BY_PID:
                case APP_RESUME_BY_PID:
                case APP_KILL_BY_PID:
+               case APP_TERM_REQ_BY_PID:
                        kb = bundle_decode(pkt->data, pkt->len);
                        appid = (char *)bundle_get_val(kb, AUL_K_PKG_NAME);
                        ret = __app_process_by_pid(pkt->cmd, appid, &cr);
index 4096e7e..59769e2 100755 (executable)
@@ -50,7 +50,8 @@ enum app_cmd {
        APP_KEY_RELEASE,
        APP_STATUS_UPDATE,
        APP_RELEASED,
-       APP_RUNNING_LIST_UPDATE
+       APP_RUNNING_LIST_UPDATE,
+       APP_TERM_REQ_BY_PID
 };
 
 #define AUL_SOCK_PREFIX "/tmp/alaunch"
index bbbbecd..2ca0809 100755 (executable)
@@ -1598,6 +1598,14 @@ int aul_listen_app_dead_signal(int (*func) (int, void *), void *data);
  */
 int aul_listen_app_launch_signal(int (*func) (int, void *), void *data);
 
+
+typedef int (*subapp_fn)(void *data);
+
+int aul_set_subapp(subapp_fn cb, void *data);
+int aul_subapp_terminate_request_pid(int pid);
+int aul_is_subapp(void);
+
+
 /** @} */
 
 
index 026fa4e..1c31577 100755 (executable)
@@ -39,7 +39,7 @@ static int __connect_client_sock(int sockfd, const struct sockaddr *saptr, sockl
 static inline void __set_sock_option(int fd, int cli)
 {
        int size;
-       struct timeval tv = { 3, 200 * 1000 };  /*  3.2 sec */
+       struct timeval tv = { 5, 200 * 1000 };  /*  5.2 sec */
 
        size = AUL_SOCK_MAXBUFF;
        setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
@@ -316,10 +316,10 @@ int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen)
        len = recv(fd, &res, sizeof(int), 0);
        if (len == -1) {
                if (errno == EAGAIN) {
-                       _E("recv timeout \n");
+                       _E("recv timeout : %s", strerror(errno));
                        res = -EAGAIN;
                } else {
-                       _E("recv error\n");
+                       _E("recv error : %s", strerror(errno));
                        res = -ECOMM;
                }
        }
index 4639b50..51fc466 100755 (executable)
@@ -88,6 +88,7 @@ static int app_terminate()
        return 0;
 }
 
+
 /**
  * @brief      encode kb and send it to 'pid'
  * @param[in]  pid             receiver's pid
@@ -331,6 +332,10 @@ int aul_sock_handler(int fd)
                app_terminate();
                break;
 
+       case APP_TERM_REQ_BY_PID:       /* run in callee */
+               app_subapp_terminate_request();
+               break;
+
        case APP_RESULT:        /* run in caller */
        case APP_CANCEL:
                kbundle = bundle_decode(pkt->data, pkt->len);
index a574a31..e052820 100755 (executable)
@@ -43,6 +43,11 @@ typedef struct _app_resultcb_info_t {
 static int latest_caller_pid = -1;
 static app_resultcb_info_t *rescb_head = NULL;
 
+static int is_subapp = 0;
+subapp_fn subapp_cb = NULL;
+void *subapp_data = NULL;
+
+
 static void __add_resultcb(int pid, void (*cbfunc) (bundle *, int, void *),
                         void *data);
 static app_resultcb_info_t *__find_resultcb(int pid);
@@ -407,3 +412,37 @@ int aul_send_result(bundle *kb, int is_cancel)
        return ret;
 }
 
+int app_subapp_terminate_request()
+{
+       if(is_subapp) {
+               subapp_cb(subapp_data);
+       }
+       return 0;
+}
+
+SLPAPI int aul_set_subapp(subapp_fn cb, void *data)
+{
+       is_subapp = 1;
+       subapp_cb = cb;
+       subapp_data = data;
+
+       return 0;
+}
+
+SLPAPI int aul_subapp_terminate_request_pid(int pid)
+{
+       char pid_str[MAX_PID_STR_BUFSZ];
+       int ret;
+
+       if (pid <= 0)
+               return AUL_R_EINVAL;
+
+       snprintf(pid_str, MAX_PID_STR_BUFSZ, "%d", pid);
+       ret = app_request_to_launchpad(APP_TERM_REQ_BY_PID, pid_str, NULL);
+       return ret;
+}
+
+SLPAPI int aul_is_subapp()
+{
+       return is_subapp;
+}
index d5bbeda..9d6fdca 100755 (executable)
@@ -31,6 +31,9 @@
 
 #define BINSH_NAME     "/bin/sh"
 #define BINSH_SIZE     7
+#define VALGRIND_NAME  "/home/developer/sdk_tools/valgrind/usr/bin/valgrind"
+#define VALGRIND_SIZE  51
+
 
 #define PROC_STAT_GID_POS      5
 
@@ -139,6 +142,8 @@ char *__proc_get_cmdline_bypid(int pid)
        /* support app launched by shell script*/
        if (strncmp(buf, BINSH_NAME, BINSH_SIZE) == 0)
                return strdup(&buf[BINSH_SIZE + 1]);
+       else if (strncmp(buf, VALGRIND_NAME, VALGRIND_SIZE) == 0)
+               return strdup(&buf[VALGRIND_SIZE + 1]);
        else
                return strdup(buf);
 }
index 5d4bd49..c912951 100755 (executable)
@@ -156,6 +156,13 @@ int term_pid_test()
        return aul_terminate_pid(apn_pid);
 }
 
+int term_req_pid_test()
+{
+       static int num = 0;
+       printf("[aul_subapp_terminate_request_pid %d test] %d \n", num++, apn_pid);
+       return aul_subapp_terminate_request_pid(apn_pid);
+}
+
 static test_func_t scn_func[] = {
        {"n", launch_test, "launch_test", ""},
        {"n", launch_test, "launch_test", ""},
@@ -550,6 +557,8 @@ static test_func_t test_func[] = {
                "[usage] resume_pid <pid>" },
        {"term_pid", term_pid_test,"aul_terminate_pid test",
                "[usage] term_pid <pid>" },
+       {"term_req_pid", term_req_pid_test,"aul_subapp_terminate_request_pid test",
+               "[usage] term_req_pid <pid>" },
        {"dbuslaunch", dbus_launch_test,"launch by dbus auto activation",
                "[usage] term_pid <pid>" },
        {"all",all_test,"test based on predefine scenario",