Add aul_app_get_pid API 47/53847/1
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 9 Dec 2015 22:51:42 +0000 (07:51 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 9 Dec 2015 22:51:42 +0000 (07:51 +0900)
- This API gets specified application process id.

Change-Id: I7b9b40fedbd8cb752225d75ae20801f7cb826105
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
am_daemon/amd_request.c
include/app_sock.h
include/aul.h
src/pkginfo.c
test/aul_test.c

index 89b344c..d3dcdae 100644 (file)
@@ -1055,6 +1055,7 @@ static app_cmd_dispatch_func dispatch_table[APP_CMD_MAX] = {
        [APP_GET_STATUS] = __dispatch_app_get_status,
        [APP_ADD_LOADER] = __dispatch_app_add_loader,
        [APP_REMOVE_LOADER] = __dispatch_app_remove_loader,
+       [APP_GET_PID] = __dispatch_app_is_running,
        [AMD_RELOAD_APPINFO] = __dispatch_amd_reload_appinfo,
        [AGENT_DEAD_SIGNAL] = __dispatch_agent_dead_signal,
 };
index 65c9aac..68bbf68 100644 (file)
@@ -70,6 +70,7 @@ enum app_cmd {
        APP_GET_SOCKET_PAIR,
        APP_ADD_LOADER,
        APP_REMOVE_LOADER,
+       APP_GET_PID,
 
        /* for special purpose */
        AMD_RELOAD_APPINFO,
index ec4708f..c1ea180 100644 (file)
@@ -1916,6 +1916,19 @@ int aul_add_loader(const char *loader_path);
 */
 int aul_remove_loader(int loader_id);
 
+/**
+ * @par Description
+ *     This API gets specified application process id.
+ * @par Purpose:
+ *     The purpose of this API is to get the pid of specified application.
+ *
+ * @param[in]  appid   application name
+ * @return     callee's pid if success, negative value(<0) if fail
+ *
+ * @remark
+ *     This API is only available in User Session.
+ */
+int aul_app_get_pid(const char *appid);
 
 #ifdef __cplusplus
        }
index ce4c42e..42bbed1 100644 (file)
@@ -39,6 +39,19 @@ typedef struct _internal_param_t {
 static const char *__appid = NULL;
 static const char *__pkgid = NULL;
 
+SLPAPI int aul_app_get_pid(const char *appid)
+{
+       int ret = 0;
+
+       if (appid == NULL)
+               return -1;
+
+       ret = __app_send_raw(AUL_UTIL_PID, APP_GET_PID, (unsigned char *)appid,
+                       strlen(appid));
+
+       return ret;
+}
+
 SLPAPI int aul_app_is_running(const char *appid)
 {
        int ret = 0;
index d798656..a944265 100644 (file)
@@ -435,6 +435,14 @@ static int get_status_pid()
        return 0;
 }
 
+static int get_pid()
+{
+       static int num = 0;
+
+       printf("[aul_app_get_pid %d test] %s \n", num++, gargv[2]);
+       return aul_app_get_pid(gargv[2]);;
+}
+
 static int update_running_list()
 {
        aul_running_list_update(gargv[2], gargv[3], gargv[4]);
@@ -596,6 +604,8 @@ static test_func_t test_func[] = {
                "[usage] reload"},
        {"get_status_pid", get_status_pid, "aul_app_get_status_bypid test",
                "[usage] get_status_pid <pid>"},
+       {"get_pid", get_pid, "aul_app_get_pid test",
+               "[usage] get_pid <appid>"},
 };
 
 int callfunc(char *testname)