Adds the API for system users 01/125901/1
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 19 Apr 2017 08:52:49 +0000 (17:52 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 19 Apr 2017 08:52:49 +0000 (17:52 +0900)
Adds:
 - aul_listen_app_status_for_uid()

Change-Id: I2d7ddebbe641b113bebaf36b47568e6245b2b79b
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/aul.h
include/aul_util.h
src/status.c
tool/aul_test.c

index 118c0e7..6f0e66d 100644 (file)
@@ -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.
index e6e7104..2b78cdd 100644 (file)
@@ -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,
index 4439ff3..7c08016 100644 (file)
@@ -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());
+}
index e1fbe1e..b308dbc 100644 (file)
@@ -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)