return 0;
}
-API int aul_launch_app_with_result(const char *pkgname, bundle *kb,
- void (*cbfunc) (bundle *, int, void *),
- void *data)
-{
- return aul_launch_app_with_result_for_uid(pkgname, kb, cbfunc, data, getuid());
-}
-
-API int aul_launch_app_with_result_for_uid(const char *pkgname, bundle *kb,
- void (*cbfunc) (bundle *, int, void *),
- void *data, uid_t uid)
+static int __launch_app_with_result(int cmd, const char *appid, bundle *kb,
+ void (*callback)(bundle *, int, void *), void *data, uid_t uid)
{
int ret;
- char num_str[MAX_LOCAL_BUFSZ] = { 0, };
+ char num_str[MAX_LOCAL_BUFSZ];
int num;
if (!aul_is_initialized()) {
return AUL_R_ENOINIT;
}
- if (pkgname == NULL || cbfunc == NULL || kb == NULL)
+ if (appid == NULL || callback == NULL || kb == NULL)
return AUL_R_EINVAL;
num = __gen_seq_num();
- snprintf(num_str, MAX_LOCAL_BUFSZ, "%d", num);
+ snprintf(num_str, sizeof(num_str), "%d", num);
bundle_del(kb, AUL_K_SEQ_NUM);
bundle_add(kb, AUL_K_SEQ_NUM, num_str);
- ret = app_request_to_launchpad_for_uid(APP_START_RES, pkgname, kb, uid);
-
+ ret = app_request_to_launchpad_for_uid(cmd, appid, kb, uid);
if (ret > 0)
- __add_resultcb(ret, cbfunc, data, num);
+ __add_resultcb(ret, callback, data, num);
return ret;
}
+API int aul_launch_app_with_result(const char *pkgname, bundle *kb,
+ void (*cbfunc) (bundle *, int, void *),
+ void *data)
+{
+ return __launch_app_with_result(APP_START_RES, pkgname, kb, cbfunc,
+ data, getuid());
+}
+
+API int aul_launch_app_with_result_for_uid(const char *pkgname, bundle *kb,
+ void (*cbfunc) (bundle *, int, void *), void *data, uid_t uid)
+{
+ return __launch_app_with_result(APP_START_RES, pkgname, kb, cbfunc,
+ data, uid);
+}
+
void __iterate(const char *key, const char *val, void *data)
{
static int i = 0;
return 0;
}
+
+API int aul_launch_app_with_result_async(const char *appid, bundle *b,
+ void (*callback)(bundle *, int, void *), void *data)
+{
+ return __launch_app_with_result(APP_START_RES_ASYNC, appid, b, callback,
+ data, getuid());
+}
+
+API int aul_launch_app_with_result_async_for_uid(const char *appid, bundle *b,
+ void (*callback)(bundle *, int, void *), void *data, uid_t uid)
+{
+ return __launch_app_with_result(APP_START_RES_ASYNC, appid, b, callback,
+ data, uid);
+}
static int __set_bundle(bundle *b, const char *key, const char *value);
static void __aul_cb(bundle *b, int is_cancel, void *data);
static int __run_svc_with_pkgname(char *pkgname, bundle *b, int request_code,
- aul_svc_res_fn cbfunc, void *data, uid_t uid);
+ aul_svc_res_fn cbfunc, void *data, uid_t uid, bool sync);
static int __get_resolve_info(bundle *b, aul_svc_resolve_info_t *info);
static int __free_resolve_info_data(aul_svc_resolve_info_t *info);
}
static int __run_svc_with_pkgname(char *pkgname, bundle *b, int request_code,
- aul_svc_res_fn cbfunc, void *data, uid_t uid)
+ aul_svc_res_fn cbfunc, void *data, uid_t uid, bool sync)
{
aul_svc_cb_info_t *cb_info = NULL;
int ret = -1;
SECURE_LOGD("pkg_name : %s - with result", pkgname);
cb_info = __create_rescb(request_code, cbfunc, data);
- ret = aul_launch_app_with_result_for_uid(pkgname, b, __aul_cb,
- cb_info, uid);
+ if (sync) {
+ ret = aul_launch_app_with_result_for_uid(pkgname, b,
+ __aul_cb, cb_info, uid);
+ } else {
+ ret = aul_launch_app_with_result_async_for_uid(pkgname,
+ b, __aul_cb, cb_info, uid);
+ }
} else {
SECURE_LOGD("pkg_name : %s - no result", pkgname);
if (data)
SECURE_LOGD("multi_instance value = %s", data);
- if (data && strncmp(data, "TRUE", strlen("TRUE")) == 0)
- ret = aul_launch_app_for_multi_instance(pkgname, b);
- else
- ret = aul_launch_app(pkgname, b);
+ if (data && strncmp(data, "TRUE", strlen("TRUE")) == 0) {
+ if (sync) {
+ ret = aul_launch_app_for_multi_instance(pkgname,
+ b);
+ } else {
+ ret = aul_launch_app_for_multi_instance_async(
+ pkgname, b);
+ }
+ } else {
+ if (sync)
+ ret = aul_launch_app(pkgname, b);
+ else
+ ret = aul_launch_app_async(pkgname, b, uid);
+ }
#else
- ret = aul_launch_app_for_uid(pkgname, b, uid);
+ if (sync)
+ ret = aul_launch_app_for_uid(pkgname, b, uid);
+ else
+ ret = aul_launch_app_async_for_uid(pkgname, b, uid);
#endif
}
return __set_bundle(b, AUL_SVC_K_LAUNCH_MODE, mode);
}
-API int aul_svc_run_service(bundle *b, int request_code,
- aul_svc_res_fn cbfunc, void *data)
-{
- return aul_svc_run_service_for_uid(b, request_code, cbfunc, data, getuid());
-}
-
-API int aul_svc_run_service_for_uid(bundle *b, int request_code,
- aul_svc_res_fn cbfunc, void *data, uid_t uid)
+static int __run_service(bundle *b, int request_code,
+ aul_svc_res_fn cbfunc, void *data, uid_t uid, bool sync)
{
aul_svc_resolve_info_t info;
char *pkgname;
int ret = -1;
char *appid;
int l;
-
GSList *pkg_list = NULL;
char *query = NULL;
gchar *checksum;
if (operation == NULL)
aul_svc_set_operation(b, AUL_SVC_OPERATION_DEFAULT);
ret = __run_svc_with_pkgname(pkgname, b, request_code, cbfunc,
- data, uid);
+ data, uid, sync);
return ret;
}
|| strcmp(operation, AUL_SVC_OPERATION_MULTI_SHARE) == 0
|| strcmp(operation, AUL_SVC_OPERATION_SHARE_TEXT) == 0)) {
ret = __run_svc_with_pkgname(SHARE_PANEL, b, request_code,
- cbfunc, data, uid);
+ cbfunc, data, uid, sync);
return ret;
}
if (!strncmp("@APP_SELECTOR ", appid, l)) {
bundle_add(b, AUL_SVC_K_URI_R_INFO, &appid[l]);
ret = __run_svc_with_pkgname(APP_SELECTOR, b, request_code,
- cbfunc, data, uid);
+ cbfunc, data, uid, sync);
} else if (!strcmp(appid, "^")) {
ret = AUL_SVC_RET_ENOMATCH;
} else {
ret = __run_svc_with_pkgname(appid, b, request_code,
- cbfunc, data, uid);
+ cbfunc, data, uid, sync);
}
free(appid);
g_free(checksum);
if (pkgname != NULL) {
__put_cache(checksum, pkgname, uid);
ret = __run_svc_with_pkgname(pkgname, b, request_code,
- cbfunc, data, uid);
+ cbfunc, data, uid, sync);
free(pkgname);
goto end;
}
if (pkgname != NULL) {
__put_cache(checksum, pkgname, uid);
ret = __run_svc_with_pkgname(pkgname, b, request_code,
- cbfunc, data, uid);
+ cbfunc, data, uid, sync);
goto end;
}
} else if (pkg_count > 1) {
bundle_add(b, AUL_SVC_K_URI_R_INFO, info.uri);
__put_cache_with_info(checksum, info.uri, uid);
ret = __run_svc_with_pkgname(APP_SELECTOR, b, request_code,
- cbfunc, data, uid);
+ cbfunc, data, uid, sync);
goto end;
}
__free_pkg_list(pkg_list);
if (pkgname != NULL) {
__put_cache(checksum, pkgname, uid);
ret = __run_svc_with_pkgname(pkgname, b, request_code,
- cbfunc, data, uid);
+ cbfunc, data, uid, sync);
free(pkgname);
goto end;
}
if (pkgname != NULL) {
__put_cache(checksum, pkgname, uid);
ret = __run_svc_with_pkgname(pkgname, b, request_code,
- cbfunc, data, uid);
+ cbfunc, data, uid, sync);
goto end;
}
} else if (pkg_count > 1) {
bundle_add(b, AUL_SVC_K_URI_R_INFO, info.uri_r_info);
__put_cache_with_info(checksum, info.uri_r_info, uid);
ret = __run_svc_with_pkgname(APP_SELECTOR, b, request_code,
- cbfunc, data, uid);
+ cbfunc, data, uid, sync);
goto end;
}
if (pkgname != NULL) {
__put_cache(checksum, pkgname, uid);
ret = __run_svc_with_pkgname(pkgname, b, request_code,
- cbfunc, data, uid);
+ cbfunc, data, uid, sync);
free(pkgname);
goto end;
}
if (pkgname != NULL) {
__put_cache(checksum, pkgname, uid);
ret = __run_svc_with_pkgname(pkgname, b, request_code,
- cbfunc, data, uid);
+ cbfunc, data, uid, sync);
}
} else if (pkg_count < 1) {
__free_resolve_info_data(&info);
bundle_add(b, AUL_SVC_K_URI_R_INFO, info.scheme);
__put_cache_with_info(checksum, info.scheme, uid);
ret = __run_svc_with_pkgname(APP_SELECTOR, b, request_code,
- cbfunc, data, uid);
+ cbfunc, data, uid, sync);
}
end:
return ret;
}
+API int aul_svc_run_service(bundle *b, int request_code,
+ aul_svc_res_fn cbfunc, void *data)
+{
+ return __run_service(b, request_code, cbfunc, data, getuid(), true);
+}
+
+API int aul_svc_run_service_for_uid(bundle *b, int request_code,
+ aul_svc_res_fn cbfunc, void *data, uid_t uid)
+{
+ return __run_service(b, request_code, cbfunc, data, uid, true);
+}
+
API int aul_svc_get_list(bundle *b, aul_svc_info_iter_fn iter_fn,
void *data)
{
return __set_bundle(b, AUL_K_INSTANCE_ID, instance_id);
}
+
+API int aul_svc_run_service_async(bundle *b, int request_code,
+ aul_svc_res_fn cbfunc, void *data)
+{
+ return __run_service(b, request_code, cbfunc, data, getuid(), false);
+}
+
+API int aul_svc_run_service_async_for_uid(bundle *b, int request_code,
+ aul_svc_res_fn cbfunc, void *data, uid_t uid)
+{
+ return __run_service(b, request_code, cbfunc, data, uid, false);
+}