diff options
author | Hwankyu Jhun <h.jhun@samsung.com> | 2017-04-19 17:52:49 +0900 |
---|---|---|
committer | Hwankyu Jhun <h.jhun@samsung.com> | 2017-04-19 17:52:49 +0900 |
commit | df03357a77c5faa0906683754953f8083384c5ad (patch) | |
tree | e64c797f0d39ae09918d7ba363fe7ca35b338de9 | |
parent | b5aedc005ea0ad8a60382c961616b7153a9671e7 (diff) | |
download | aul-1-df03357a77c5faa0906683754953f8083384c5ad.tar.gz aul-1-df03357a77c5faa0906683754953f8083384c5ad.tar.bz2 aul-1-df03357a77c5faa0906683754953f8083384c5ad.zip |
Adds the API for system users
Adds:
- aul_listen_app_status_for_uid()
Change-Id: I2d7ddebbe641b113bebaf36b47568e6245b2b79b
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r-- | include/aul.h | 12 | ||||
-rw-r--r-- | include/aul_util.h | 1 | ||||
-rw-r--r-- | src/status.c | 21 | ||||
-rw-r--r-- | tool/aul_test.c | 10 |
4 files changed, 39 insertions, 5 deletions
diff --git a/include/aul.h b/include/aul.h index 118c0e72..6f0e66de 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 e6e7104e..2b78cddf 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 4439ff3c..7c080168 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 e1fbe1e7..b308dbc2 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 <pid> <uid>"}, {"listen_app_status", listen_app_status, "aul_listen_app_status", "[usage] listen_app_status <appid>"}, + {"listen_app_status_for_uid", listen_app_status_for_uid_test, "aul_listen_app_status_for_uid", + "[usage] listen_app_status_for_uid <appid> <uid>"}, }; int callfunc(char *testname) |