#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <uuid.h>
#include <bundle.h>
#include <bundle_internal.h>
#include <glib.h>
#include "aul_svc_priv_key.h"
#include "launch.h"
#include "aul_svc_internal.h"
+#include "aul_app_group.h"
#define MAX_CHECKSUM_BUF 2048
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
__remove_rescb(cb_info);
}
-static int __run_svc_with_pkgname(char *pkgname, bundle *b, int request_code,
- aul_svc_res_fn cbfunc, aul_svc_err_cb err_cb,
- void *data, uid_t uid, bool sync)
+static void __set_instance_id(bundle *b, const char *appid)
{
- aul_svc_cb_info_t *cb_info = NULL;
- int ret = -1;
+ const char *comp_id;
+ char buf[1024];
+ char uuid[37];
+ uuid_t u;
+
+ uuid_generate(u);
+ uuid_unparse(u, uuid);
+
+ comp_id = bundle_get_val(b, AUL_K_COMPONENT_ID);
+ if (comp_id)
+ snprintf(buf, sizeof(buf), "%s:%s:%s", uuid, appid, comp_id);
+ else
+ snprintf(buf, sizeof(buf), "%s:%s", uuid, appid);
- if (bundle_get_type(b, AUL_SVC_K_SELECTOR_EXTRA_LIST) != BUNDLE_TYPE_NONE) {
+ bundle_add(b, AUL_K_INSTANCE_ID, buf);
+}
+
+static void __verify_request(bundle *b, char **appid)
+{
+ const char *launch_mode;
+ int ret;
+
+ ret = bundle_get_type(b, AUL_SVC_K_SELECTOR_EXTRA_LIST);
+ if (ret != BUNDLE_TYPE_NONE) {
if (!aul_svc_get_pkgname(b))
- pkgname = APP_SELECTOR;
+ *appid = APP_SELECTOR;
}
if (bundle_get_val(b, AUL_K_FORCE_LAUNCH_APP_SELECTOR))
- pkgname = APP_SELECTOR;
+ *appid = APP_SELECTOR;
- if (__is_special_app(pkgname) || __is_special_operation(b)) {
+ if (__is_special_app(*appid) || __is_special_operation(b)) {
bundle_del(b, AUL_SVC_K_CAN_BE_LEADER);
bundle_add_str(b, AUL_SVC_K_CAN_BE_LEADER, "true");
bundle_del(b, AUL_SVC_K_REROUTE);
bundle_add_str(b, AUL_SVC_K_RECYCLE, "true");
}
+ launch_mode = aul_svc_get_launch_mode(b);
+ if (launch_mode && !strcmp(launch_mode, "group")) {
+ ret = bundle_get_type(b, AUL_K_INSTANCE_ID);
+ if (ret == BUNDLE_TYPE_NONE)
+ __set_instance_id(b, *appid);
+ }
+}
+
+static int __run_svc_with_pkgname(char *pkgname, bundle *b, int request_code,
+ aul_svc_res_fn cbfunc, aul_svc_err_cb err_cb,
+ void *data, uid_t uid, bool sync)
+{
+ aul_svc_cb_info_t *cb_info = NULL;
+ int ret = -1;
+
+ __verify_request(b, &pkgname);
+
if (cbfunc || err_cb) {
SECURE_LOGD("pkg_name : %s - with result", pkgname);
*appid = info.appid;
-
return AUL_SVC_RET_OK;
}
API int aul_svc_send_launch_request_sync_for_uid(bundle *b, int request_code,
bundle **res_b, aul_svc_result_val *res, uid_t uid)
{
- const char *pkgname = NULL;
+ char *pkgname = NULL;
const char *val;
char *appid = NULL;
int ret;
}
pkgname = appid;
- if (bundle_get_type(b, AUL_SVC_K_SELECTOR_EXTRA_LIST) != BUNDLE_TYPE_NONE) {
- if (!aul_svc_get_pkgname(b))
- pkgname = APP_SELECTOR;
- }
-
- if (bundle_get_val(b, AUL_K_FORCE_LAUNCH_APP_SELECTOR))
- pkgname = APP_SELECTOR;
-
- if (__is_special_app(pkgname) || __is_special_operation(b)) {
- bundle_del(b, AUL_SVC_K_CAN_BE_LEADER);
- bundle_add_str(b, AUL_SVC_K_CAN_BE_LEADER, "true");
- bundle_del(b, AUL_SVC_K_REROUTE);
- bundle_add_str(b, AUL_SVC_K_REROUTE, "true");
- bundle_del(b, AUL_SVC_K_RECYCLE);
- bundle_add_str(b, AUL_SVC_K_RECYCLE, "true");
- }
+ __verify_request(b, &pkgname);
ret = aul_send_launch_request_sync_for_uid(pkgname, b, uid, res_b);
if (ret > 0) {
{
return bundle_get_val(b, AUL_K_COMPONENT_ID);
}
+
+static void __foreach_group_info(aul_app_group_info_h info, void *data)
+{
+ int *cnt = (int *)data;
+
+ (*cnt)++;
+}
+
+API int aul_svc_subapp_terminate_request(bundle *b, int pid)
+{
+ const char *caller_inst_id;
+ const char *inst_id;
+ char buf[512] = { 0, };
+ int cnt = 0;
+ int ret;
+
+ if (!b || pid < 0) {
+ _E("Invalid parameter");
+ return AUL_SVC_RET_EINVAL;
+ }
+
+ inst_id = bundle_get_val(b, AUL_K_INSTANCE_ID);
+ if (!inst_id) {
+ _E("Invalid request");
+ return AUL_SVC_RET_EINVAL;
+ }
+
+ caller_inst_id = bundle_get_val(b, AUL_K_CALLER_INSTANCE_ID);
+ if (!caller_inst_id) {
+ ret = aul_app_get_instance_id_bypid(getpid(), buf, sizeof(buf));
+ if (ret != AUL_R_OK) {
+ _E("Failed to get caller instance ID");
+ return AUL_SVC_RET_ERROR;
+ }
+ caller_inst_id = buf;
+ }
+
+ aul_app_group_foreach_group_info(caller_inst_id,
+ __foreach_group_info, (void *)&cnt);
+ if (cnt == 0)
+ return aul_subapp_terminate_request(inst_id, pid);
+
+ return aul_app_group_clear_top();
+}