From: Hwankyu Jhun Date: Wed, 19 Apr 2017 08:52:49 +0000 (+0900) Subject: Adds the API for system users X-Git-Tag: accepted/tizen/unified/20170421.113814~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=df03357a77c5faa0906683754953f8083384c5ad;p=platform%2Fcore%2Fappfw%2Faul-1.git Adds the API for system users Adds: - aul_listen_app_status_for_uid() Change-Id: I2d7ddebbe641b113bebaf36b47568e6245b2b79b Signed-off-by: Hwankyu Jhun --- diff --git a/include/aul.h b/include/aul.h index 118c0e7..6f0e66d 100644 --- a/include/aul.h +++ b/include/aul.h @@ -2994,10 +2994,20 @@ typedef int (*app_status_cb)(aul_app_info *info, int ctx_status, void *data); typedef struct status_listen_s *status_listen_h; /** - * This API is only for Appfw internally. + * @par Description: + * Registers a callback function to be invoked when the application change status. + * + * @param[in] appid The application ID to get status + * @param[in] callback The callback function to register + * @param[in] data The user data to be passed to the callback function + * @param[out] handle The status listen handle + * @return @c 0 on success, + * otherwise a negative error value */ int aul_listen_app_status(const char *appid, app_status_cb callback, void *data, status_listen_h *handle); +int aul_listen_app_status_for_uid(const char *appid, app_status_cb callback, + void *data, status_listen_h *handle, uid_t uid); /* * This API is only for Appfw internally. diff --git a/include/aul_util.h b/include/aul_util.h index e6e7104..2b78cdd 100644 --- a/include/aul_util.h +++ b/include/aul_util.h @@ -34,6 +34,7 @@ #define MAX_PACKAGE_STR_SIZE 512 #define MAX_PID_STR_BUFSZ 20 #define MAX_UID_STR_BUFSZ 20 +#define REGULAR_UID_MIN 5000 typedef enum { TIZEN_PROFILE_UNKNOWN = 0, diff --git a/src/status.c b/src/status.c index 4439ff3..7c08016 100644 --- a/src/status.c +++ b/src/status.c @@ -312,8 +312,8 @@ static int __app_status_event_cb(const char *endpoint, aul_app_com_result_e res, return 0; } -API int aul_listen_app_status(const char *appid, app_status_cb callback, - void *data, status_listen_h *handle) +API int aul_listen_app_status_for_uid(const char *appid, app_status_cb callback, + void *data, status_listen_h *handle, uid_t uid) { struct status_listen_s *listen; char endpoint[128]; @@ -329,8 +329,14 @@ API int aul_listen_app_status(const char *appid, app_status_cb callback, return AUL_R_ERROR; } - snprintf(endpoint, sizeof(endpoint), "app_status_event:%s:%d", - appid, getuid()); + if (uid < REGULAR_UID_MIN) { + snprintf(endpoint, sizeof(endpoint), + "app_status_event:%s", appid); + } else { + snprintf(endpoint, sizeof(endpoint), + "app_status_event:%s:%d", appid, uid); + } + aul_app_com_create(endpoint, NULL, __app_status_event_cb, listen, &listen->conn); if (listen->conn == NULL) { @@ -346,3 +352,10 @@ API int aul_listen_app_status(const char *appid, app_status_cb callback, return AUL_R_OK; } + +API int aul_listen_app_status(const char *appid, app_status_cb callback, + void *data, status_listen_h *handle) +{ + return aul_listen_app_status_for_uid(appid, callback, data, handle, + getuid()); +} diff --git a/tool/aul_test.c b/tool/aul_test.c index e1fbe1e..b308dbc 100644 --- a/tool/aul_test.c +++ b/tool/aul_test.c @@ -695,6 +695,14 @@ static int listen_app_status(void) return aul_listen_app_status(gargv[2], app_status_handler, NULL, &listen_handle); } +static int listen_app_status_for_uid_test(void) +{ + static int num; + + printf("aul_listen_app_status %d test] %s \n", num++, gargv[2]); + return aul_listen_app_status_for_uid(gargv[2], app_status_handler, NULL, &listen_handle, apn_pid); +} + static int test_regex() { char *token; @@ -833,6 +841,8 @@ static test_func_t test_func[] = { "[usage] resume_pid_async_for_uid "}, {"listen_app_status", listen_app_status, "aul_listen_app_status", "[usage] listen_app_status "}, + {"listen_app_status_for_uid", listen_app_status_for_uid_test, "aul_listen_app_status_for_uid", + "[usage] listen_app_status_for_uid "}, }; int callfunc(char *testname)