Support multiple instance launch 20/108620/16
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 5 Jan 2017 08:14:38 +0000 (17:14 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 16 Jan 2017 05:42:34 +0000 (14:42 +0900)
- Add new APIs and new internal keys
aul_app_get_running_app_instance_info(): Retrieves the app instance info
aul_svc_set_instance_id: Sets the instance ID
aul_svc_get_instance_id: Gets the instance ID

- Requires:
[application] https://review.tizen.org/gerrit/#/c/108805/
[app-manager] https://review.tizen.org/gerrit/#/c/110114/
[amd] https://review.tizen.org/gerrit/#/c/109746/
[rua] https://review.tizen.org/gerrit/#/c/109906/

Change-Id: I1cc83fe8a82b6df09a3cfa551b9861247040da27
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/aul.h
include/aul_cmd.h
include/aul_svc.h
src/pkginfo.c
src/service.c

index f3864e9..116534a 100644 (file)
@@ -148,7 +148,14 @@ typedef enum aul_widget_instance_event {
 #define AUL_K_RUA_ARG "__K_RUA_ARG"
 /** AUL public key - To support rua add */
 #define AUL_K_RUA_TIME "__K_RUA_TIME"
-
+/** AUL public bundle value */
+#define AUL_K_RUA_INSTANCE_ID "__K_RUA_INSTANCE_ID"
+/** AUL public bundle value */
+#define AUL_K_RUA_INSTANCE_NAME "__K_RUA_INSTANCE_NAME"
+/** AUL public bundle value */
+#define AUL_K_RUA_ICON "__K_RUA_ICON"
+/** AUL public bundle value */
+#define AUL_K_RUA_URI "__K_RUA_URI"
 
 /** AUL internal private key */
 #define AUL_K_PKG_NAME         "__AUL_PKG_NAME__"
@@ -248,6 +255,8 @@ typedef enum aul_widget_instance_event {
 #define AUL_K_STATUS           "__AUL_STATUS__"
 /** AUL internal private key */
 #define AUL_K_IS_SUBAPP                "__AUL_IS_SUBAPP__"
+/** AUL internal private key */
+#define AUL_K_INSTANCE_ID      "__AUL_INSTANCE_ID__"
 
 /**
  * @brief      This is callback function for aul_launch_init
@@ -895,6 +904,7 @@ typedef struct _aul_app_info {
        char *pkgid;            /**< package id */
        int status;             /**< app's status */
        int is_sub_app;         /**< state whether sub app of app group */
+       char *instance_id;
 } aul_app_info;
 
 /**
@@ -964,7 +974,7 @@ int aul_app_is_running_for_uid(const char *appid, uid_t uid);
  *     In general, this API is used by task manager appllication. (running application list viewer)
  *
  * @param[in]  iter_fn         iterator function
- * @param[in]  data            user-supplied data for iter_fn
+ * @param[in]  user_data       user-supplied data for iter_fn
  * @return     0 if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_ERROR     - internal error
@@ -994,7 +1004,7 @@ int aul_app_is_running_for_uid(const char *appid, uid_t uid);
  *     Or, If you want to get all window list, you must iterate XWindows by using XWindow APIs
  *     This API is only available in User Session.
  */
-int aul_app_get_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
+int aul_app_get_running_app_info(aul_app_info_iter_fn iter_fn, void *user_data);
 
 /**
  * @par Description:
@@ -1006,7 +1016,7 @@ int aul_app_get_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
  *     In general, this API is used by task manager appllication. (running application list viewer)
  *
  * @param[in]  iter_fn         iterator function
- * @param[in]  data            user-supplied data for iter_fn
+ * @param[in]  user_data       user-supplied data for iter_fn
  * @param[in]  uid             User ID
  * @return     0 if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
@@ -1018,7 +1028,7 @@ int aul_app_get_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
  *     Or, If you want to get all window list, you must iterate XWindows by using XWindow APIs
  *     This API is only available to System user.
  */
-int aul_app_get_running_app_info_for_uid(aul_app_info_iter_fn iter_fn, void *data, uid_t uid);
+int aul_app_get_running_app_info_for_uid(aul_app_info_iter_fn iter_fn, void *user_data, uid_t uid);
 
 /**
  * @par Description:
@@ -1030,7 +1040,7 @@ int aul_app_get_running_app_info_for_uid(aul_app_info_iter_fn iter_fn, void *dat
  *     In general, this API is used by task manager application. (running application list viewer)
  *
  * @param[in]  iter_fn         iterator function
- * @param[in]  data            user-supplied data for iter_fn
+ * @param[in]  user_data       user-supplied data for iter_fn
  * @return     0 if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_ERROR     - internal error
@@ -1063,7 +1073,7 @@ int aul_app_get_running_app_info_for_uid(aul_app_info_iter_fn iter_fn, void *dat
  *     Or, If you want to get all window list, you must iterate XWindows by using XWindow APIs
  *     This API is only available in User Session.
  */
-int aul_app_get_all_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
+int aul_app_get_all_running_app_info(aul_app_info_iter_fn iter_fn, void *user_data);
 
 /**
  * @par Description:
@@ -1075,7 +1085,7 @@ int aul_app_get_all_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
  *     In general, this API is used by task manager application. (running application list viewer)
  *
  * @param[in]  iter_fn         iterator function
- * @param[in]  data            user-supplied data for iter_fn
+ * @param[in]  user_data       user-supplied data for iter_fn
  * @param[in]  uid             User ID
  * @return     0 if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
@@ -1087,7 +1097,7 @@ int aul_app_get_all_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
  *     Or, If you want to get all window list, you must iterate XWindows by using XWindow APIs
  *     This API is only available to System user.
  */
-int aul_app_get_all_running_app_info_for_uid(aul_app_info_iter_fn iter_fn, void *data, uid_t uid);
+int aul_app_get_all_running_app_info_for_uid(aul_app_info_iter_fn iter_fn, void *user_data, uid_t uid);
 
 /**
  * @par Description:
@@ -2991,6 +3001,23 @@ API int aul_listen_app_status(const char *appid,
  */
 int aul_widget_instance_get_content(const char *widget_id, const char *instance_id, char **content);
 
+/**
+ * @par Description:
+ *      Gets running application instance info
+ *      This API calls the iter_fn with the aul_app_info when running app instance info is found.
+ *
+ * @param[in]   iter_fn         iterative function
+ * @param[in]   user_data       User data
+ * @return      0 if success, negative value(<0) if fail
+ * @retval      AUL_R_OK        Successful
+ * @retval      AUL_R_ERROR     General error
+ * @retval      AUL_R_EINVAL    Invalid parameter
+ */
+int aul_app_get_running_app_instance_info(aul_app_info_iter_fn iter_fn,
+               void *user_data);
+int aul_app_get_running_app_instance_info_for_uid(aul_app_info_iter_fn iter_fn,
+               void *user_data, uid_t uid);
+
 #ifdef __cplusplus
        }
 #endif
index a064d50..4259111 100644 (file)
@@ -113,6 +113,7 @@ enum app_cmd {
        ADD_SCREEN_VIEWER = 83,
        REMOVE_SCREEN_VIEWER = 84,
        LAUNCHPAD_LAUNCH_SIGNAL = 85,
+       APP_RUNNING_INSTANCE_INFO = 86,
 
        APP_CMD_MAX
 };
index 7d36ef7..9b85497 100755 (executable)
@@ -1254,8 +1254,27 @@ int aul_svc_foreach_allowed_info_by_appid_for_uid(int (*callback)(
                        const char *appid, const char *allowed_appid, void *data),
                const char *appid, uid_t uid, void *user_data);
 
+/**
+ * @par Description:
+ *      Gets the instance ID.
+ *
+ * @param[in]   b               Bundle object
+ *
+ * @return Pointer for application id string if success, NULL if fail
+ */
+const char *aul_svc_get_instance_id(bundle *b);
+
+/**
+ * @par Description:
+ *      Sets the instance ID.
+ *
+ * @param[in]  b                Bundle object
+ * @param[in]  instance ID      Instance ID
+ *
+ * @return 0 if success, negative value(<0) if fail
+ */
+int aul_svc_set_instance_id(bundle *b, const char *instance_id);
+
 #ifdef __cplusplus
 }
 #endif
-
-
index 18eb0e9..7ce560c 100644 (file)
@@ -29,8 +29,8 @@
 #include "aul_error.h"
 
 typedef struct _internal_param_t {
-       aul_app_info_iter_fn enum_fn;
-       void *user_param;
+       aul_app_info_iter_fn iter_fn;
+       void *user_data;
 } internal_param_t;
 
 static const char *__appid = NULL;
@@ -117,6 +117,7 @@ static void __running_app_info_cb(app_pkt_t *pkt, void *user_data)
        info.appid = (char *)bundle_get_val(b, AUL_K_APPID);
        info.app_path = (char *)bundle_get_val(b, AUL_K_EXEC);
        info.pkgid = (char *)bundle_get_val(b, AUL_K_PKGID);
+       info.instance_id = (char *)bundle_get_val(b, AUL_K_INSTANCE_ID);
 
        val = bundle_get_val(b, AUL_K_STATUS);
        if (val == NULL) {
@@ -133,30 +134,20 @@ static void __running_app_info_cb(app_pkt_t *pkt, void *user_data)
        info.is_sub_app = atoi(val);
 
        info.pkg_name = info.appid;
-       param->enum_fn(&info, param->user_param);
+       param->iter_fn(&info, param->user_data);
        bundle_free(b);
 }
 
-API int aul_app_get_running_app_info(aul_app_info_iter_fn enum_fn,
-               void *user_param)
-{
-       return aul_app_get_running_app_info_for_uid(enum_fn,
-                       user_param, getuid());;
-}
-
-API int aul_app_get_running_app_info_for_uid(aul_app_info_iter_fn enum_fn,
-               void *user_param, uid_t uid)
+static int __get_running_app_info(int cmd, aul_app_info_iter_fn iter_fn,
+               void *user_data, uid_t uid)
 {
        int ret;
        int fd;
        bundle *b;
        char buf[MAX_PID_STR_BUFSZ];
-       internal_param_t param = {
-               enum_fn,
-               user_param
-       };
+       internal_param_t param = {iter_fn, user_data};
 
-       if (enum_fn == NULL)
+       if (iter_fn == NULL)
                return AUL_R_EINVAL;
 
        b = bundle_create();
@@ -168,8 +159,7 @@ API int aul_app_get_running_app_info_for_uid(aul_app_info_iter_fn enum_fn,
        snprintf(buf, sizeof(buf), "%d", uid);
        bundle_add(b, AUL_K_TARGET_UID, buf);
 
-       fd = aul_sock_send_bundle(AUL_UTIL_PID, uid, APP_RUNNING_INFO,
-                       b, AUL_SOCK_ASYNC);
+       fd = aul_sock_send_bundle(AUL_UTIL_PID, uid, cmd, b, AUL_SOCK_ASYNC);
        bundle_free(b);
        if (fd < 0)
                return aul_error_convert(fd);
@@ -181,48 +171,46 @@ API int aul_app_get_running_app_info_for_uid(aul_app_info_iter_fn enum_fn,
        return AUL_R_OK;
 }
 
-API int aul_app_get_all_running_app_info(aul_app_info_iter_fn enum_fn,
-               void *user_param)
+API int aul_app_get_running_app_info(aul_app_info_iter_fn iter_fn,
+               void *user_data)
 {
-       return aul_app_get_all_running_app_info_for_uid(enum_fn,
-                       user_param, getuid());
+       return aul_app_get_running_app_info_for_uid(iter_fn,
+                       user_data, getuid());
 }
 
-API int aul_app_get_all_running_app_info_for_uid(aul_app_info_iter_fn enum_fn,
-               void *user_param, uid_t uid)
+API int aul_app_get_running_app_info_for_uid(aul_app_info_iter_fn iter_fn,
+               void *user_data, uid_t uid)
 {
-       int ret;
-       int fd;
-       bundle *b;
-       char buf[MAX_PID_STR_BUFSZ];
-       internal_param_t param = {
-               enum_fn,
-               user_param
-       };
-
-       if (enum_fn == NULL)
-               return AUL_R_EINVAL;
-
-       b = bundle_create();
-       if (b == NULL) {
-               _E("out of memory");
-               return AUL_R_ERROR;
-       }
+       return __get_running_app_info(APP_RUNNING_INFO, iter_fn,
+                       user_data, uid);
+}
 
-       snprintf(buf, sizeof(buf), "%d", uid);
-       bundle_add(b, AUL_K_TARGET_UID, buf);
+API int aul_app_get_all_running_app_info(aul_app_info_iter_fn iter_fn,
+               void *user_data)
+{
+       return aul_app_get_all_running_app_info_for_uid(iter_fn,
+                       user_data, getuid());
+}
 
-       fd = aul_sock_send_bundle(AUL_UTIL_PID, uid, APP_ALL_RUNNING_INFO,
-                       b, AUL_SOCK_ASYNC);
-       bundle_free(b);
-       if (fd < 0)
-               return aul_error_convert(fd);
+API int aul_app_get_all_running_app_info_for_uid(aul_app_info_iter_fn iter_fn,
+               void *user_data, uid_t uid)
+{
+       return __get_running_app_info(APP_ALL_RUNNING_INFO, iter_fn,
+                       user_data, uid);
+}
 
-       ret = aul_sock_recv_pkt_with_cb(fd, __running_app_info_cb, &param);
-       if (ret < 0)
-               return aul_error_convert(ret);
+API int aul_app_get_running_app_instance_info(aul_app_info_iter_fn iter_fn,
+               void *user_data)
+{
+       return aul_app_get_running_app_instance_info_for_uid(iter_fn,
+                       user_data, getuid());
+}
 
-       return AUL_R_OK;
+API int aul_app_get_running_app_instance_info_for_uid(
+               aul_app_info_iter_fn iter_fn, void *user_data, uid_t uid)
+{
+       return __get_running_app_info(APP_RUNNING_INSTANCE_INFO, iter_fn,
+                       user_data, uid);
 }
 
 API void aul_set_preinit_appid(const char *appid)
index a4f0384..e951362 100755 (executable)
@@ -1647,3 +1647,18 @@ API int aul_svc_foreach_allowed_info_by_appid_for_uid(int (*callback)(
 
        return AUL_SVC_RET_OK;
 }
+
+API const char *aul_svc_get_instance_id(bundle *b)
+{
+       return bundle_get_val(b, AUL_K_INSTANCE_ID);
+}
+
+API int aul_svc_set_instance_id(bundle *b, const char *instance_id)
+{
+       if (b == NULL || instance_id == NULL) {
+               _E("Invalid parameter");
+               return AUL_SVC_RET_EINVAL;
+       }
+
+       return __set_bundle(b, AUL_K_INSTANCE_ID, instance_id);
+}