Support app group instance launch 07/111507/2
authorHawnkyu Jhun <h.jhun@samsung.com>
Sat, 21 Jan 2017 02:26:51 +0000 (11:26 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 23 Jan 2017 04:29:53 +0000 (13:29 +0900)
- Add new internal APIs to get instance id

Change-Id: I75dbed523133202c8ad52faa5eaf9b44e2f6158f
Signed-off-by: Hawnkyu Jhun <h.jhun@samsung.com>
include/aul.h
include/aul_cmd.h
src/pkginfo.c

index bfac5f7..e45af3e 100644 (file)
@@ -3015,6 +3015,13 @@ int aul_app_get_running_app_instance_info(aul_app_info_iter_fn iter_fn,
 int aul_app_get_running_app_instance_info_for_uid(aul_app_info_iter_fn iter_fn,
                void *user_data, uid_t uid);
 
+/*
+ * This API is only for Appfw internally.
+ */
+int aul_app_get_instance_id_bypid(int pid, char *instance_id, int len);
+int aul_app_get_instance_id_bypid_for_uid(int pid, char *instance_id,
+               int len, uid_t uid);
+
 #ifdef __cplusplus
        }
 #endif
index 4259111..55e653e 100644 (file)
@@ -114,6 +114,7 @@ enum app_cmd {
        REMOVE_SCREEN_VIEWER = 84,
        LAUNCHPAD_LAUNCH_SIGNAL = 85,
        APP_RUNNING_INSTANCE_INFO = 86,
+       APP_GET_INSTANCE_ID_BYPID = 87,
 
        APP_CMD_MAX
 };
index 7ce560c..70c648c 100644 (file)
@@ -663,3 +663,56 @@ API int aul_disable_alias_info(const char *appid)
 
        return AUL_R_OK;
 }
+
+API int aul_app_get_instance_id_bypid_for_uid(int pid, char *instance_id,
+               int len, uid_t uid)
+{
+       app_pkt_t *pkt = NULL;
+       bundle *b;
+       int ret;
+       int fd;
+       char buf[MAX_PID_STR_BUFSZ];
+
+       if (pid <= 0 || instance_id == NULL) {
+               _E("Invalid parameter");
+               return AUL_R_EINVAL;
+       }
+
+       b = bundle_create();
+       if (b == NULL) {
+               _E("Out of memory");
+               return AUL_R_ERROR;
+       }
+
+       snprintf(buf, sizeof(buf), "%d", pid);
+       bundle_add(b, AUL_K_PID, buf);
+       snprintf(buf, sizeof(buf), "%d", uid);
+       bundle_add(b, AUL_K_TARGET_UID, buf);
+
+       fd = aul_sock_send_bundle(AUL_UTIL_PID, uid,
+                       APP_GET_INSTANCE_ID_BYPID, b,
+                       AUL_SOCK_ASYNC);
+       bundle_free(b);
+       if (fd <= 0)
+               return AUL_R_ERROR;
+
+       ret = aul_sock_recv_reply_pkt(fd, &pkt);
+       if (ret < 0 || pkt == NULL)
+               return  AUL_R_ERROR;
+
+       if (pkt->cmd == APP_GET_INFO_OK) {
+               snprintf(instance_id, len, "%s", pkt->data);
+               free(pkt);
+               return AUL_R_OK;
+       }
+
+       free(pkt);
+
+       return AUL_R_ERROR;
+}
+
+API int aul_app_get_instance_id_bypid(int pid, char *instance_id, int len)
+{
+       return aul_app_get_instance_id_bypid_for_uid(pid,
+                       instance_id, len, getuid());
+}