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
REMOVE_SCREEN_VIEWER = 84,
LAUNCHPAD_LAUNCH_SIGNAL = 85,
APP_RUNNING_INSTANCE_INFO = 86,
+ APP_GET_INSTANCE_ID_BYPID = 87,
APP_CMD_MAX
};
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());
+}