From: Hwankyu Jhun Date: Wed, 9 Dec 2015 22:51:42 +0000 (+0900) Subject: Add aul_app_get_pid API X-Git-Tag: accepted/tizen/mobile/20151212.070857~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a60db24d22d1ed97df016bc72bf8308228957546;p=platform%2Fcore%2Fappfw%2Faul-1.git Add aul_app_get_pid API - This API gets specified application process id. Change-Id: I7b9b40fedbd8cb752225d75ae20801f7cb826105 Signed-off-by: Hwankyu Jhun --- diff --git a/am_daemon/amd_request.c b/am_daemon/amd_request.c index 89b344c..d3dcdae 100644 --- a/am_daemon/amd_request.c +++ b/am_daemon/amd_request.c @@ -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, }; diff --git a/include/app_sock.h b/include/app_sock.h index 65c9aac..68bbf68 100644 --- a/include/app_sock.h +++ b/include/app_sock.h @@ -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, diff --git a/include/aul.h b/include/aul.h index ec4708f..c1ea180 100644 --- a/include/aul.h +++ b/include/aul.h @@ -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 } diff --git a/src/pkginfo.c b/src/pkginfo.c index ce4c42e..42bbed1 100644 --- a/src/pkginfo.c +++ b/src/pkginfo.c @@ -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; diff --git a/test/aul_test.c b/test/aul_test.c index d798656..a944265 100644 --- a/test/aul_test.c +++ b/test/aul_test.c @@ -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 "}, + {"get_pid", get_pid, "aul_app_get_pid test", + "[usage] get_pid "}, }; int callfunc(char *testname)