From dbce49b0f8f1de156bd3ef909640c501ec1e476b Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Mon, 11 May 2015 19:29:35 +0900 Subject: [PATCH] Add missing api: aul_terminate_pid_async Change-Id: Ia2b6c7247aaf939e0d45cc84b81a6d1c4d597a64 Signed-off-by: Sangyoon Jang --- am_daemon/amd_request.c | 8 ++++++++ include/app_sock.h | 2 ++ include/aul.h | 5 ++++- src/launch.c | 19 ++++++++++++++++++- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/am_daemon/amd_request.c b/am_daemon/amd_request.c index f49cab2..01bfaed 100644 --- a/am_daemon/amd_request.c +++ b/am_daemon/amd_request.c @@ -155,6 +155,13 @@ static int __app_process_by_pid(int cmd, if ((ret = __app_send_raw(pid, APP_TERM_REQ_BY_PID, (unsigned char *)&dummy, sizeof(int))) < 0) { _D("terminate req packet send error"); } + break; + case APP_TERM_BY_PID_ASYNC: + if ((ret = __app_send_raw_with_noreply(pid, cmd, (unsigned char *)&dummy, sizeof(int))) < 0) { + _D("terminate req packet send error"); + } + __real_send(clifd, ret); + break; } return ret; @@ -303,6 +310,7 @@ static gboolean __request_handler(gpointer data) case APP_RESUME_BY_PID: case APP_KILL_BY_PID: case APP_TERM_REQ_BY_PID: + case APP_TERM_BY_PID_ASYNC: kb = bundle_decode(pkt->data, pkt->len); appid = (char *)bundle_get_val(kb, AUL_K_APPID); ret = __app_process_by_pid(pkt->cmd, appid, &cr, clifd); diff --git a/include/app_sock.h b/include/app_sock.h index 7b70ac1..78f5536 100644 --- a/include/app_sock.h +++ b/include/app_sock.h @@ -52,6 +52,7 @@ enum app_cmd { APP_RELEASED, APP_RUNNING_LIST_UPDATE, APP_TERM_REQ_BY_PID, + APP_TERM_BY_PID_ASYNC, /* reserved for AMD Agent */ APP_DEAD_SIGNAL, @@ -67,6 +68,7 @@ enum app_cmd { #define EILLEGALACCESS 127 #define ETERMINATING 126 #define ENOLAUNCHPAD 125 +#define EREJECTED 123 typedef struct _app_pkt_t { int cmd; diff --git a/include/aul.h b/include/aul.h index c02f9fb..39b1564 100644 --- a/include/aul.h +++ b/include/aul.h @@ -71,7 +71,9 @@ extern "C" { * @brief Return values in AUL. */ typedef enum _aul_return_val { - AUL_R_ENOAPP = -11, /**< Failed to find app ID or pkg ID */ + AUL_R_EREJECTED = -14, /**< App disable for mode */ + AUL_R_ENOAPP = -13, /**< Failed to find app ID or pkg ID */ + AUL_R_EHIDDENFORGUEST = -11, /**< App hidden for guest mode */ AUL_R_ENOLAUNCHPAD = -10, /**< no launchpad */ AUL_R_ETERMINATING = -9, /**< application terminating */ AUL_R_EILLACC = -8, /**< Illegal Access */ @@ -620,6 +622,7 @@ int aul_resume_pid(int pid); * If you have not the permission, this API return AUL_R_ERROR. \n */ int aul_terminate_pid(int pid); +int aul_terminate_pid_async(int pid); /** @} */ diff --git a/src/launch.c b/src/launch.c index 6ea4070..347f174 100644 --- a/src/launch.c +++ b/src/launch.c @@ -140,6 +140,9 @@ SLPAPI int app_agent_send_cmd(int uid, int cmd, bundle *kb) case -ENOLAUNCHPAD: res = AUL_R_ENOLAUNCHPAD; break; + case -EREJECTED: + res = AUL_R_EREJECTED; + break; default: res = AUL_R_ERROR; } @@ -411,7 +414,7 @@ int aul_sock_handler(int fd) return -1; } - if (pkt->cmd != APP_RESULT && pkt->cmd != APP_CANCEL) { + if (pkt->cmd != APP_RESULT && pkt->cmd != APP_CANCEL && pkt->cmd != APP_TERM_BY_PID_ASYNC) { ret = __send_result_to_launchpad(clifd, 0); if (ret < 0) { free(pkt); @@ -438,6 +441,7 @@ int aul_sock_handler(int fd) break; case APP_TERM_BY_PID: /* run in callee */ + case APP_TERM_BY_PID_ASYNC: app_terminate(); break; @@ -621,6 +625,19 @@ SLPAPI int aul_terminate_pid(int pid) return ret; } +SLPAPI int aul_terminate_pid_async(int pid) +{ + char pkgname[MAX_PID_STR_BUFSZ]; + int ret; + + if (pid <= 0) + return AUL_R_EINVAL; + + snprintf(pkgname, MAX_PID_STR_BUFSZ, "%d", pid); + ret = app_request_to_launchpad(APP_TERM_BY_PID_ASYNC, pkgname, NULL); + return ret; +} + SLPAPI int aul_kill_pid(int pid) { char pkgname[MAX_PID_STR_BUFSZ]; -- 2.7.4