2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <sys/types.h>
24 #include <bundle_internal.h>
29 #include <iniparser.h>
30 #include <pkgmgr-info.h>
36 #include "aul_svc_db.h"
38 #include "aul_svc_priv_key.h"
41 #define MAX_CHECKSUM_BUF 2048
43 /* callback handling */
44 typedef struct _aul_svc_cb_info_t {
46 aul_svc_res_fn cb_func;
47 aul_svc_err_cb err_cb;
51 typedef struct _aul_svc_resolve_info_t {
65 } aul_svc_resolve_info_t;
67 typedef struct _aul_svc_transient_cb_info_t {
68 aul_svc_host_res_fn cb_func;
70 } aul_svc_transient_cb_info_t;
72 pthread_mutex_t iniparser_lock = PTHREAD_MUTEX_INITIALIZER;
75 static aul_svc_cb_info_t *__create_rescb(int request_code,
76 aul_svc_res_fn cbfunc, aul_svc_err_cb err_cb, void *data);
77 static void __remove_rescb(aul_svc_cb_info_t *info);
78 static int __set_bundle(bundle *b, const char *key, const char *value);
79 static void __aul_cb(bundle *b, int is_cancel, void *data);
80 static int __run_svc_with_pkgname(char *pkgname, bundle *b, int request_code,
81 aul_svc_res_fn cbfunc, aul_svc_err_cb err_cb, void *data,
82 uid_t uid, bool sync);
83 static int __get_resolve_info(bundle *b, aul_svc_resolve_info_t *info);
84 static int __free_resolve_info_data(aul_svc_resolve_info_t *info);
86 static char *white_list[] = {
92 static bool __is_special_app(const char *appid)
100 while ((id = white_list[i]) != NULL) {
101 if (strcmp(id, appid) == 0)
108 static bool __is_special_operation(bundle *b)
110 const char *operation;
111 const char *white_operations[] = {
112 "http://tizen.org/appcontrol/operation/guide_privacy_setting",
117 operation = aul_svc_get_operation(b);
121 for (i = 0; white_operations[i]; ++i) {
122 if (!strcmp(operation, white_operations[i]))
129 static aul_svc_cb_info_t *__create_rescb(int request_code,
130 aul_svc_res_fn cbfunc, aul_svc_err_cb err_cb, void *data)
132 aul_svc_cb_info_t* info;
134 info = calloc(1, sizeof(aul_svc_cb_info_t));
140 info->request_code = request_code;
141 info->cb_func = cbfunc;
142 info->err_cb = err_cb;
148 static void __remove_rescb(aul_svc_cb_info_t *info)
154 static int __set_bundle(bundle *b, const char *key, const char *value)
156 const char *val = NULL;
158 val = bundle_get_val(b, key);
160 if (bundle_del(b, key) != 0)
161 return AUL_SVC_RET_ERROR;
165 return AUL_SVC_RET_EINVAL;
167 if (bundle_add(b, key, value) != 0)
168 return AUL_SVC_RET_ERROR;
172 return AUL_SVC_RET_OK;
175 static int __set_bundle_array(bundle *b, const char *key,
176 const char **value, int len)
180 type = aul_svc_data_is_array(b, key);
183 if (bundle_del(b, key) != 0)
184 return AUL_SVC_RET_ERROR;
188 return AUL_SVC_RET_EINVAL;
190 if (bundle_add_str_array(b, key, value, len) != 0)
191 return AUL_SVC_RET_ERROR;
193 _D("__set_bundle_array");
195 return AUL_SVC_RET_OK;
198 static void __aul_cb(bundle *b, int is_cancel, void *data)
200 const char *val = NULL;
201 aul_svc_cb_info_t* cb_info;
205 res = AUL_SVC_RES_CANCEL;
207 /* get result_code from bundle */
208 val = bundle_get_val(b, AUL_SVC_K_RES_VAL);
209 res = (val == NULL) ? AUL_SVC_RES_NOT_OK : atoi(val);
212 /* remove result_code from bundle */
213 bundle_del(b, AUL_SVC_K_RES_VAL);
215 /* find corresponding callback */
216 cb_info = (aul_svc_cb_info_t*)data;
218 cb_info->cb_func(b, cb_info->request_code,
219 (aul_svc_result_val)res, cb_info->data);
220 __remove_rescb(cb_info);
225 static int __error_convert(int res)
229 return AUL_SVC_RET_EILLACC;
231 return AUL_SVC_RET_EINVAL;
232 case AUL_R_ETERMINATING:
233 return AUL_SVC_RET_ETERMINATING;
234 case AUL_R_EREJECTED:
235 return AUL_SVC_RET_EREJECTED;
237 return AUL_SVC_RET_ENOMATCH;
239 return AUL_SVC_RET_ELAUNCH;
243 static void __aul_error_cb(int err, void *data)
245 aul_svc_cb_info_t *cb_info = (aul_svc_cb_info_t *)data;
248 _E("Critical error!");
253 err = __error_convert(err);
255 if (cb_info->err_cb) {
256 cb_info->err_cb(cb_info->request_code, err, cb_info->data);
257 cb_info->err_cb = NULL;
261 static int __run_svc_with_pkgname(char *pkgname, bundle *b, int request_code,
262 aul_svc_res_fn cbfunc, aul_svc_err_cb err_cb,
263 void *data, uid_t uid, bool sync)
265 aul_svc_cb_info_t *cb_info = NULL;
268 if (bundle_get_type(b, AUL_SVC_K_SELECTOR_EXTRA_LIST) != BUNDLE_TYPE_NONE) {
269 if (!aul_svc_get_pkgname(b))
270 pkgname = APP_SELECTOR;
273 if (bundle_get_val(b, AUL_K_FORCE_LAUNCH_APP_SELECTOR))
274 pkgname = APP_SELECTOR;
276 if (__is_special_app(pkgname) || __is_special_operation(b)) {
277 bundle_del(b, AUL_SVC_K_CAN_BE_LEADER);
278 bundle_add_str(b, AUL_SVC_K_CAN_BE_LEADER, "true");
279 bundle_del(b, AUL_SVC_K_REROUTE);
280 bundle_add_str(b, AUL_SVC_K_REROUTE, "true");
281 bundle_del(b, AUL_SVC_K_RECYCLE);
282 bundle_add_str(b, AUL_SVC_K_RECYCLE, "true");
286 SECURE_LOGD("pkg_name : %s - with result", pkgname);
288 cb_info = __create_rescb(request_code, cbfunc, err_cb, data);
290 ret = aul_launch_app_with_result_for_uid(pkgname, b,
291 __aul_cb, cb_info, uid);
294 ret = aul_send_launch_request_for_uid(pkgname,
296 __aul_error_cb, cb_info);
298 ret = aul_launch_app_with_result_async_for_uid(
299 pkgname, b, __aul_cb,
304 SECURE_LOGD("pkg_name : %s - no result", pkgname);
306 #ifdef _APPFW_FEATURE_MULTI_INSTANCE
307 const char* data = bundle_get_val(b, AUL_SVC_K_MULTI_INSTANCE);
309 SECURE_LOGD("multi_instance value = %s", data);
311 if (data && strncmp(data, "TRUE", strlen("TRUE")) == 0) {
313 ret = aul_launch_app_for_multi_instance(pkgname,
316 ret = aul_launch_app_for_multi_instance_async(
321 ret = aul_launch_app(pkgname, b);
323 ret = aul_launch_app_async(pkgname, b, uid);
327 ret = aul_launch_app_for_uid(pkgname, b, uid);
329 ret = aul_launch_app_async_for_uid(pkgname, b, uid);
334 ret = __error_convert(ret);
339 static int __get_resolve_info(bundle *b, aul_svc_resolve_info_t *info)
342 char *saveptr = NULL;
343 char *strtok_buf = NULL;
346 info->op = (char *)aul_svc_get_operation(b);
347 info->uri = (char *)aul_svc_get_uri(b);
349 if ((info->uri) && (strcmp(info->uri, "") == 0)) {
351 return AUL_SVC_RET_EINVAL;
354 info->origin_mime = info->mime = (char *)aul_svc_get_mime(b);
355 info->pkgname = (char *)aul_svc_get_pkgname(b);
356 info->category = (char *)aul_svc_get_category(b);
357 info->win_id = (char *)bundle_get_val(b, AUL_SVC_K_WIN_ID);
359 SECURE_LOGD("getting resolve info for: operation - %s / uri - %s / mime - %s",
360 info->op, info->uri, info->mime);
363 if (strncmp(info->uri, "/", 1) == 0) {
365 info->origin_mime = info->mime = malloc(MAX_MIME_STR_SIZE);
366 if (info->mime == NULL) {
368 return AUL_SVC_RET_ERROR;
371 ret = aul_get_mime_from_file(info->uri, info->mime, MAX_MIME_STR_SIZE);
375 } else if (strncmp(info->uri, "file:///", 8) == 0) {
377 info->origin_mime = info->mime = malloc(MAX_MIME_STR_SIZE);
378 if (info->mime == NULL) {
380 return AUL_SVC_RET_ERROR;
383 ret = aul_get_mime_from_file(&info->uri[7], info->mime, MAX_MIME_STR_SIZE);
386 } else if (strncmp(info->uri, "file:/", 6) == 0) {
388 info->origin_mime = info->mime = malloc(MAX_MIME_STR_SIZE);
389 if (info->mime == NULL) {
391 return AUL_SVC_RET_ERROR;
394 ret = aul_get_mime_from_file(&info->uri[5], info->mime, MAX_MIME_STR_SIZE);
399 if (info->mime_set == 1 && ret < 0) {
400 _E("aul_get_mime_from_file : %d", ret);
402 info->origin_mime = info->mime = NULL;
409 GMatchInfo *match_info;
410 GError *error = NULL;
412 regex = g_regex_new("^(([^:/?#]+):)?(//([^/?#]*))?", 0, 0, &error);
413 if (g_regex_match(regex, info->uri, 0, &match_info) == FALSE) {
414 g_regex_unref(regex);
415 return AUL_SVC_RET_EINVAL;
418 info->scheme = g_match_info_fetch(match_info, 2);
419 info->host = g_match_info_fetch(match_info, 4);
421 if (info->scheme && info->host) {
422 info->uri_r_info = malloc(MAX_SCHEME_STR_SIZE + MAX_HOST_STR_SIZE + 2);
423 if (info->uri_r_info == NULL) {
425 g_match_info_free(match_info);
426 g_regex_unref(regex);
427 return AUL_SVC_RET_ERROR;
430 snprintf(info->uri_r_info, MAX_SCHEME_STR_SIZE + MAX_HOST_STR_SIZE + 1,
431 "%s://%s", info->scheme, info->host);
434 g_match_info_free(match_info);
435 g_regex_unref(regex);
438 info->scheme = strdup("NULL");
442 info->mime = strdup("NULL");
446 info->m_type = calloc(1, MAX_LOCAL_BUFSZ);
447 if (info->m_type == NULL) {
449 return AUL_SVC_RET_ERROR;
452 info->s_type = calloc(1, MAX_LOCAL_BUFSZ);
453 if (info->s_type == NULL) {
456 return AUL_SVC_RET_ERROR;
459 tmp = strdup(info->mime);
464 return AUL_SVC_RET_ERROR;
467 strtok_buf = strtok_r(tmp, "/", &saveptr);
469 strncpy(info->m_type, strtok_buf, MAX_LOCAL_BUFSZ - 1);
470 strtok_buf = strtok_r(NULL, "/", &saveptr);
472 strncpy(info->s_type, strtok_buf, MAX_LOCAL_BUFSZ - 1);
475 if (strncmp(info->m_type, "*", 1) == 0)
476 strncpy(info->m_type, "%", MAX_LOCAL_BUFSZ - 1);
477 if (strncmp(info->s_type, "*", 1) == 0)
478 strncpy(info->s_type, "%", MAX_LOCAL_BUFSZ - 1);
480 info->mime = malloc(MAX_MIME_STR_SIZE);
481 if (info->mime == NULL) {
485 return AUL_SVC_RET_ERROR;
488 snprintf(info->mime, MAX_MIME_STR_SIZE - 1,
489 "%s/%s", info->m_type, info->s_type);
494 static int __free_resolve_info_data(aul_svc_resolve_info_t *info)
506 if (info->uri_r_info)
507 free(info->uri_r_info);
509 free(info->origin_mime);
514 static char* __get_alias_appid(char *appid)
516 char *alias_id = NULL;
518 char key_string[MAX_PACKAGE_STR_SIZE + 5];
521 dic = iniparser_load("/usr/share/appsvc/alias.ini");
526 snprintf(key_string, sizeof(key_string), "Alias:%s", appid);
527 pthread_mutex_lock(&iniparser_lock);
528 val = iniparser_getstring(dic, key_string, NULL);
529 pthread_mutex_unlock(&iniparser_lock);
531 SECURE_LOGD("alias_id : %s", val);
534 alias_id = malloc(MAX_PACKAGE_STR_SIZE);
535 if (alias_id == NULL) {
537 iniparser_freedict(dic);
541 strncpy(alias_id, val, MAX_PACKAGE_STR_SIZE - 1);
544 iniparser_freedict(dic);
549 static char* __make_query(char *query, char *op, char *uri,
550 char *mime, char *m_type, char *s_type)
552 char tmp[MAX_MIME_STR_SIZE] = { 0, };
554 query = _svc_db_query_builder_add(query, op, uri, mime, false);
555 if ((mime && strncmp(mime, "NULL", 4) != 0) &&
556 (s_type && strncmp(s_type, "%", 1) != 0)) {
557 snprintf(tmp, MAX_MIME_STR_SIZE - 1, "%s/*", m_type);
558 query = _svc_db_query_builder_add(query, op, uri, tmp, false);
561 if ((mime && strncmp(mime, "NULL", 4) != 0) &&
562 (m_type && strncmp(m_type, "%", 1) != 0)) {
563 snprintf(tmp, MAX_MIME_STR_SIZE - 1, "*/*");
564 query = _svc_db_query_builder_add(query, op, uri, tmp, false);
570 static char* __make_query_with_collation(char *op, char *uri, char *mime, char *m_type, char *s_type)
572 char tmp[MAX_MIME_STR_SIZE];
575 query = _svc_db_query_builder_add(query, op, uri, mime, true);
577 if (mime && (strncmp(mime, "NULL", 4) != 0) &&
578 s_type && (strncmp(s_type, "%", 1) != 0)) {
579 snprintf(tmp, MAX_MIME_STR_SIZE - 1, "%s/*", m_type);
580 query = _svc_db_query_builder_add(query, op, uri, tmp, true);
582 if (mime && (strncmp(mime, "NULL", 4) != 0) &&
583 m_type && (strncmp(m_type, "%", 1) != 0)) {
584 snprintf(tmp, MAX_MIME_STR_SIZE - 1, "*/*");
585 query = _svc_db_query_builder_add(query, op, uri, tmp, true);
588 query = _svc_db_query_builder_in("ac.app_control collate appsvc_collation ", query);
594 static int __app_list_cb(pkgmgrinfo_appinfo_h handle, void *user_data)
597 GSList **app_list = (GSList **)user_data;
601 pkgmgrinfo_appinfo_get_appid(handle, &str);
602 _D("Matching application is %s", str);
604 for (iter = tmp_list; iter != NULL; iter = g_slist_next(iter)) {
605 if (strncmp(str, (char *)iter->data, MAX_PACKAGE_STR_SIZE - 1) == 0) {
607 *app_list = g_slist_append(*app_list, (void *)appid);
608 _D("%s is added", appid);
615 static int __get_list_with_category(char *category, GSList **pkg_list, uid_t uid)
618 pkgmgrinfo_appinfo_filter_h handle;
619 GSList *app_list = NULL;
621 char *list_item = NULL;
623 ret = pkgmgrinfo_appinfo_filter_create(&handle);
624 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
625 PMINFO_APPINFO_PROP_APP_CATEGORY, category);
627 tmp_list = *pkg_list;
628 ret = pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle,
629 __app_list_cb, &app_list, uid);
630 if (ret != PMINFO_R_OK) {
631 pkgmgrinfo_appinfo_filter_destroy(handle);
634 pkgmgrinfo_appinfo_filter_destroy(handle);
636 for (iter = *pkg_list; iter != NULL; iter = g_slist_next(iter)) {
637 list_item = (char *)iter->data;
640 g_slist_free(*pkg_list);
642 *pkg_list = app_list;
647 static int __check_mainapp_mode(char *operation)
652 static int __get_list_with_submode(char *operation, char *win_id,
653 GSList **pkg_list, uid_t uid)
656 int mainapp_mode = 0;
658 mainapp_mode = __check_mainapp_mode(operation);
660 SECURE_LOGD("mainapp_mode : %d", mainapp_mode);
662 ret = _svc_db_adjust_list_with_submode(mainapp_mode, win_id, pkg_list, uid);
665 _E("error: %d", ret);
672 static void __free_pkg_list(GSList *list)
680 for (iter = list; iter != NULL; iter = g_slist_next(iter)) {
681 list_item = (char *)iter->data;
687 static gchar *__make_checksum(const char *op, const char *uri, const char *mime)
689 char buf[MAX_CHECKSUM_BUF];
692 snprintf(buf, sizeof(buf), "%s:%s:%s", op, uri, mime);
693 checksum = g_compute_checksum_for_string(G_CHECKSUM_MD5, buf, -1);
698 static char *__get_cache(const char *checksum, uid_t uid)
700 app_pkt_t *pkt = NULL;
704 char buf[MAX_PID_STR_BUFSZ];
713 snprintf(buf, sizeof(buf), "%d", uid);
714 bundle_add(b, AUL_K_TARGET_UID, buf);
715 bundle_add(b, AUL_K_CHECKSUM, checksum);
717 fd = aul_sock_send_bundle(AUL_UTIL_PID, uid, APP_GET_APPID_FROM_CACHE,
723 ret = aul_sock_recv_reply_pkt(fd, &pkt);
727 if (pkt->cmd == APP_GET_APPID_FROM_CACHE) {
728 if (pkt->data[0] == 0) {
732 appid = strdup((const char *)(pkt->data));
741 static void __put_cache(const char *checksum, const char *appid, uid_t uid)
745 char buf[MAX_PID_STR_BUFSZ];
753 snprintf(buf, sizeof(buf), "%d", uid);
754 bundle_add(b, AUL_K_TARGET_UID, buf);
755 bundle_add(b, AUL_K_CHECKSUM, checksum);
756 bundle_add(b, AUL_K_APPID, appid);
758 ret = app_send_cmd_for_uid(AUL_UTIL_PID, uid, APP_SET_CACHE, b);
761 _E("Failed to set cache : %d", ret);
766 static void __put_cache_with_info(const char *checksum, const char *info, uid_t uid)
770 snprintf(buf, sizeof(buf), "@APP_SELECTOR %s", info);
771 __put_cache(checksum, buf, uid);
774 static void __invalidate_cache(uid_t uid)
778 char buf[MAX_PID_STR_BUFSZ];
786 snprintf(buf, sizeof(buf), "%d", uid);
787 bundle_add(b, AUL_K_TARGET_UID, buf);
788 ret = app_send_cmd_for_uid(AUL_UTIL_PID, uid, APP_INVALIDATE_CACHE, b);
791 _E("Failed to invalidate cache : %d", ret);
796 API int aul_svc_set_operation(bundle *b, const char *operation)
799 _E("bundle is NULL");
800 return AUL_SVC_RET_EINVAL;
803 return __set_bundle(b, AUL_SVC_K_OPERATION, operation);
806 API int aul_svc_set_uri(bundle *b, const char *uri)
809 _E("bundle is NULL");
810 return AUL_SVC_RET_EINVAL;
813 return __set_bundle(b, AUL_SVC_K_URI, uri);
816 API int aul_svc_set_mime(bundle *b, const char *mime)
819 _E("bundle is NULL");
820 return AUL_SVC_RET_EINVAL;
823 return __set_bundle(b, AUL_SVC_K_MIME, mime);
826 API int aul_svc_add_data(bundle *b, const char *key, const char *val)
828 if (b == NULL || key == NULL)
829 return AUL_SVC_RET_EINVAL;
831 /* check key for data */
834 return __set_bundle(b, key, val);
837 API int aul_svc_add_data_array(bundle *b, const char *key,
838 const char **val_array, int len)
840 if (b == NULL || key == NULL)
841 return AUL_SVC_RET_EINVAL;
843 /* check key for data */
846 return __set_bundle_array(b, key, val_array, len);
849 API int aul_svc_set_pkgname(bundle *b, const char *pkg_name)
852 _E("bundle is NULL");
853 return AUL_SVC_RET_EINVAL;
856 return __set_bundle(b, AUL_SVC_K_PKG_NAME, pkg_name);
859 API int aul_svc_set_appid(bundle *b, const char *appid)
861 char *alias_id = NULL;
864 if (b == NULL || appid == NULL) {
865 _E("bundle is NULL");
866 return AUL_SVC_RET_EINVAL;
869 alias_id = __get_alias_appid((char *)appid);
870 if (alias_id == NULL) {
871 ret = __set_bundle(b, AUL_SVC_K_PKG_NAME, appid);
873 ret = __set_bundle(b, AUL_SVC_K_PKG_NAME, alias_id);
881 API int aul_svc_set_category(bundle *b, const char *category)
884 _E("bundle is NULL");
885 return AUL_SVC_RET_EINVAL;
888 return __set_bundle(b, AUL_SVC_K_CATEGORY, category);
891 API int aul_svc_set_launch_mode(bundle *b, const char *mode)
894 _E("bundle is NULL");
895 return AUL_SVC_RET_EINVAL;
898 return __set_bundle(b, AUL_SVC_K_LAUNCH_MODE, mode);
901 static int __run_service(bundle *b, int request_code,
902 aul_svc_res_fn cbfunc, aul_svc_err_cb err_cb,
903 void *data, uid_t uid, bool sync)
905 aul_svc_resolve_info_t info;
912 GSList *pkg_list = NULL;
917 _E("bundle is NULL");
918 return AUL_SVC_RET_EINVAL;
921 pkgname = (char *)aul_svc_get_pkgname(b);
922 operation = (char *)aul_svc_get_operation(b);
926 if (operation == NULL)
927 aul_svc_set_operation(b, AUL_SVC_OPERATION_DEFAULT);
928 ret = __run_svc_with_pkgname(pkgname, b, request_code, cbfunc,
929 err_cb, data, uid, sync);
934 if (TIZEN_FEATURE_SHARE_PANEL
935 && (operation && (strcmp(operation, AUL_SVC_OPERATION_SHARE) == 0
936 || strcmp(operation, AUL_SVC_OPERATION_MULTI_SHARE) == 0
937 || strcmp(operation, AUL_SVC_OPERATION_SHARE_TEXT) == 0))) {
938 ret = __run_svc_with_pkgname(SHARE_PANEL, b, request_code,
939 cbfunc, err_cb, data, uid, sync);
943 memset(&info, 0, sizeof(aul_svc_resolve_info_t));
944 ret = __get_resolve_info(b, &info);
946 __free_resolve_info_data(&info);
950 SECURE_LOGD("op - %s / mime - %s / scheme - %s",
951 info.op, info.origin_mime, info.scheme);
953 checksum = __make_checksum(info.op, info.uri, info.origin_mime);
954 appid = __get_cache(checksum, uid);
957 _D("Hit! %s / %s", checksum, appid);
958 l = strlen("@APP_SELECTOR ");
959 if (!strncmp("@APP_SELECTOR ", appid, l)) {
960 bundle_add(b, AUL_SVC_K_URI_R_INFO, &appid[l]);
961 ret = __run_svc_with_pkgname(APP_SELECTOR, b,
962 request_code, cbfunc, err_cb,
964 } else if (!strcmp(appid, "^")) {
965 ret = AUL_SVC_RET_ENOMATCH;
967 ret = __run_svc_with_pkgname(appid, b, request_code,
968 cbfunc, err_cb, data, uid, sync);
972 __free_resolve_info_data(&info);
976 ret = _svc_db_check_perm(uid, true);
978 _E("permission error : %d", ret);
979 ret = AUL_SVC_RET_EILLACC;
984 pkgname = _svc_db_get_app(info.op, info.origin_mime, info.uri, uid);
985 if (pkgname != NULL) {
986 __put_cache(checksum, pkgname, uid);
987 ret = __run_svc_with_pkgname(pkgname, b, request_code,
988 cbfunc, err_cb, data, uid, sync);
993 query = __make_query_with_collation(info.op, info.uri,
994 info.mime, info.m_type, info.s_type);
996 query = _svc_db_query_builder_build(query);
997 _svc_db_exec_query(query, &pkg_list, uid);
1003 pkg_count = g_slist_length(pkg_list);
1004 if (pkg_count > 0) {
1005 __free_pkg_list(pkg_list);
1007 if (info.uri_r_info) {
1008 query = __make_query(query, info.op, info.uri_r_info,
1009 info.mime, info.m_type, info.s_type);
1012 query = __make_query(query, info.op, info.scheme,
1013 info.mime, info.m_type, info.s_type);
1015 query = __make_query(query, info.op, "*",
1016 info.mime, info.m_type, info.s_type);
1018 if (info.scheme && (strcmp(info.scheme, "file") == 0)
1019 && info.mime && (strcmp(info.mime, "NULL") != 0)) {
1020 query = __make_query(query, info.op, "NULL",
1021 info.mime, info.m_type, info.s_type);
1024 query = _svc_db_query_builder_build(query);
1025 _svc_db_exec_query(query, &pkg_list, uid);
1032 __get_list_with_category(info.category, &pkg_list, uid);
1034 __get_list_with_submode(info.op, info.win_id, &pkg_list, uid);
1036 pkg_count = g_slist_length(pkg_list);
1037 _D("pkg_count : %d", pkg_count);
1039 if (pkg_count == 1) {
1040 pkgname = (char *)pkg_list->data;
1041 if (pkgname != NULL) {
1042 __put_cache(checksum, pkgname, uid);
1043 ret = __run_svc_with_pkgname(pkgname, b, request_code,
1044 cbfunc, err_cb, data, uid, sync);
1047 } else if (pkg_count > 1) {
1048 bundle_add(b, AUL_SVC_K_URI_R_INFO, info.uri);
1049 __put_cache_with_info(checksum, info.uri, uid);
1050 ret = __run_svc_with_pkgname(APP_SELECTOR, b, request_code,
1051 cbfunc, err_cb, data, uid, sync);
1054 __free_pkg_list(pkg_list);
1059 if (info.uri_r_info) {
1060 pkgname = _svc_db_get_app(info.op, info.origin_mime, info.uri_r_info, uid);
1062 if (pkgname != NULL) {
1063 __put_cache(checksum, pkgname, uid);
1064 ret = __run_svc_with_pkgname(pkgname, b, request_code,
1065 cbfunc, err_cb, data, uid, sync);
1070 query = __make_query(query, info.op, info.uri_r_info,
1071 info.mime, info.m_type, info.s_type);
1072 query = _svc_db_query_builder_build(query);
1073 _svc_db_exec_query(query, &pkg_list, uid);
1079 pkg_count = g_slist_length(pkg_list);
1080 if (pkg_count > 0) {
1081 __free_pkg_list(pkg_list);
1083 query = __make_query(query, info.op, "*",
1084 info.mime, info.m_type, info.s_type);
1086 if (info.scheme && (strcmp(info.scheme, "file") == 0)
1087 && info.mime && (strcmp(info.mime, "NULL") != 0)) {
1088 query = __make_query(query, info.op, "NULL",
1089 info.mime, info.m_type, info.s_type);
1092 query = _svc_db_query_builder_build(query);
1093 _svc_db_exec_query(query, &pkg_list, uid);
1100 __get_list_with_category(info.category, &pkg_list, uid);
1102 __get_list_with_submode(info.op, info.win_id, &pkg_list, uid);
1104 pkg_count = g_slist_length(pkg_list);
1105 _D("pkg_count : %d", pkg_count);
1107 if (pkg_count == 1) {
1108 pkgname = (char *)pkg_list->data;
1109 if (pkgname != NULL) {
1110 __put_cache(checksum, pkgname, uid);
1111 ret = __run_svc_with_pkgname(pkgname, b, request_code,
1112 cbfunc, err_cb, data, uid, sync);
1115 } else if (pkg_count > 1) {
1116 bundle_add(b, AUL_SVC_K_URI_R_INFO, info.uri_r_info);
1117 __put_cache_with_info(checksum, info.uri_r_info, uid);
1118 ret = __run_svc_with_pkgname(APP_SELECTOR, b, request_code,
1119 cbfunc, err_cb, data, uid, sync);
1123 __free_pkg_list(pkg_list);
1129 pkgname = _svc_db_get_app(info.op, info.origin_mime, info.scheme, uid);
1131 if (pkgname != NULL) {
1132 __put_cache(checksum, pkgname, uid);
1133 ret = __run_svc_with_pkgname(pkgname, b, request_code,
1134 cbfunc, err_cb, data, uid, sync);
1139 query = __make_query(query, info.op, info.scheme,
1140 info.mime, info.m_type, info.s_type);
1142 query = __make_query(query, info.op, "*",
1143 info.mime, info.m_type, info.s_type);
1145 if (info.scheme && (strcmp(info.scheme, "file") == 0)
1146 && info.mime && (strcmp(info.mime, "NULL") != 0)) {
1147 query = __make_query(query, info.op, "NULL",
1148 info.mime, info.m_type, info.s_type);
1151 query = _svc_db_query_builder_build(query);
1152 _svc_db_exec_query(query, &pkg_list, uid);
1160 __get_list_with_category(info.category, &pkg_list, uid);
1162 __get_list_with_submode(info.op, info.win_id, &pkg_list, uid);
1164 pkg_count = g_slist_length(pkg_list);
1165 _D("pkg_count : %d", pkg_count);
1167 if (pkg_count == 1) {
1168 pkgname = (char *)pkg_list->data;
1169 if (pkgname != NULL) {
1170 __put_cache(checksum, pkgname, uid);
1171 ret = __run_svc_with_pkgname(pkgname, b, request_code,
1172 cbfunc, err_cb, data, uid, sync);
1174 } else if (pkg_count < 1) {
1175 __free_resolve_info_data(&info);
1176 __put_cache(checksum, "^", uid);
1178 return AUL_SVC_RET_ENOMATCH;
1180 bundle_add(b, AUL_SVC_K_URI_R_INFO, info.scheme);
1181 __put_cache_with_info(checksum, info.scheme, uid);
1182 ret = __run_svc_with_pkgname(APP_SELECTOR, b, request_code,
1183 cbfunc, err_cb, data, uid, sync);
1187 __free_pkg_list(pkg_list);
1188 __free_resolve_info_data(&info);
1194 API int aul_svc_run_service(bundle *b, int request_code,
1195 aul_svc_res_fn cbfunc, void *data)
1197 return __run_service(b, request_code, cbfunc, NULL, data,
1201 API int aul_svc_run_service_for_uid(bundle *b, int request_code,
1202 aul_svc_res_fn cbfunc, void *data, uid_t uid)
1204 return __run_service(b, request_code, cbfunc, NULL, data, uid, true);
1207 API int aul_svc_get_list(bundle *b, aul_svc_info_iter_fn iter_fn,
1210 return aul_svc_get_list_for_uid(b, iter_fn, data, getuid());
1213 API int aul_svc_get_list_for_uid(bundle *b, aul_svc_info_iter_fn iter_fn,
1214 void *data, uid_t uid)
1216 aul_svc_resolve_info_t info;
1217 char *pkgname = NULL;
1221 GSList *pkg_list = NULL;
1222 GSList *iter = NULL;
1224 char *query2 = NULL;
1227 _E("bundle is NULL");
1228 return AUL_SVC_RET_EINVAL;
1231 if (iter_fn == NULL) {
1232 _E("iter_fn is NULL");
1233 return AUL_SVC_RET_EINVAL;
1238 memset(&info, 0, sizeof(aul_svc_resolve_info_t));
1239 ret = __get_resolve_info(b, &info);
1241 __free_resolve_info_data(&info);
1245 _D("operation - %s / shceme - %s / mime - %s", info.op, info.scheme,
1248 query2 = __make_query_with_collation(info.op, info.uri,
1249 info.mime, info.m_type, info.s_type);
1251 if (info.uri_r_info) {
1252 query = __make_query(query, info.op, info.uri_r_info,
1253 info.mime, info.m_type, info.s_type);
1256 query = __make_query(query, info.op, info.scheme,
1257 info.mime, info.m_type, info.s_type);
1259 query = __make_query(query, info.op, "*",
1260 info.mime, info.m_type, info.s_type);
1262 if (info.scheme && (strcmp(info.scheme, "file") == 0)
1263 && info.mime && (strcmp(info.mime, "NULL") != 0)) {
1264 query = __make_query(query, info.op, "NULL",
1265 info.mime, info.m_type, info.s_type);
1268 query = _svc_db_query_builder_or(query2, query);
1269 query = _svc_db_query_builder_build(query);
1270 _svc_db_exec_query(query, &pkg_list, uid);
1277 __get_list_with_category(info.category, &pkg_list, uid);
1279 __get_list_with_submode(info.op, info.win_id, &pkg_list, uid);
1281 pkg_count = g_slist_length(pkg_list);
1282 if (pkg_count == 0) {
1283 _E("Cannot find associated application");
1285 __free_resolve_info_data(&info);
1286 return AUL_SVC_RET_ENOMATCH;
1289 for (iter = pkg_list; iter != NULL; iter = g_slist_next(iter)) {
1290 pkgname = iter->data;
1291 SECURE_LOGD("PKGNAME : %s", pkgname);
1292 if (iter_fn(pkgname, data) != 0)
1297 g_slist_free(pkg_list);
1298 __free_resolve_info_data(&info);
1300 return AUL_SVC_RET_OK;
1303 API int aul_svc_get_all_defapps(aul_svc_info_iter_fn iter_fn, void *data)
1305 return aul_svc_get_all_defapps_for_uid(iter_fn, data, getuid());
1308 API int aul_svc_get_all_defapps_for_uid(aul_svc_info_iter_fn iter_fn,
1309 void *data, uid_t uid)
1311 char *pkgname = NULL;
1314 GSList *pkg_list = NULL;
1315 GSList *iter = NULL;
1318 ret = _svc_db_check_perm(uid, true);
1320 _E("permission error : %d", ret);
1321 return AUL_SVC_RET_EILLACC;
1324 ret = _svc_db_get_list_with_all_defapps(&pkg_list, uid);
1328 for (iter = pkg_list; iter != NULL; iter = g_slist_next(iter)) {
1329 pkgname = iter->data;
1330 if (iter_fn(pkgname, data) != 0)
1335 g_slist_free(pkg_list);
1337 return AUL_SVC_RET_OK;
1340 API const char *aul_svc_get_operation(bundle *b)
1342 return bundle_get_val(b, AUL_SVC_K_OPERATION);
1345 API const char *aul_svc_get_uri(bundle *b)
1347 return bundle_get_val(b, AUL_SVC_K_URI);
1350 API const char *aul_svc_get_mime(bundle *b)
1352 return bundle_get_val(b, AUL_SVC_K_MIME);
1355 API const char *aul_svc_get_data(bundle *b, const char *key)
1357 return bundle_get_val(b, key);
1360 API const char **aul_svc_get_data_array(bundle *b, const char *key, int *len)
1362 return bundle_get_str_array(b, key, len);
1365 API const char *aul_svc_get_pkgname(bundle *b)
1367 return bundle_get_val(b, AUL_SVC_K_PKG_NAME);
1370 API const char *aul_svc_get_appid(bundle *b)
1372 return bundle_get_val(b, AUL_SVC_K_PKG_NAME);
1375 API const char *aul_svc_get_category(bundle *b)
1377 return bundle_get_val(b, AUL_SVC_K_CATEGORY);
1380 API const char *aul_svc_get_launch_mode(bundle *b)
1382 return bundle_get_val(b, AUL_SVC_K_LAUNCH_MODE);
1385 API int aul_svc_create_result_bundle(bundle *inb, bundle **outb)
1389 if (inb == NULL || outb == NULL) {
1390 _E("bundle is NULL");
1391 return AUL_SVC_RET_EINVAL;
1394 ret = aul_create_result_bundle(inb, outb);
1396 /* add additional bundle */
1397 /* bundle_add(outb, " ", " "); */
1399 if (ret == AUL_R_OK)
1400 ret = AUL_SVC_RET_OK;
1401 else if (ret == AUL_R_EINVAL)
1402 ret = AUL_SVC_RET_EINVAL;
1403 else if (ret == AUL_R_ECANCELED)
1404 ret = AUL_SVC_RET_ECANCELED;
1406 ret = AUL_SVC_RET_ERROR;
1411 API int aul_svc_send_result(bundle *b, aul_svc_result_val result)
1414 char tmp[MAX_LOCAL_BUFSZ];
1417 _E("aul_svc_send_result is NULL");
1418 return AUL_SVC_RET_EINVAL;
1421 /* add result_code to bundle */
1422 snprintf(tmp, MAX_LOCAL_BUFSZ, "%d", (int)result);
1423 ret = __set_bundle(b, AUL_SVC_K_RES_VAL, tmp);
1425 return AUL_SVC_RET_ERROR;
1427 if (result == AUL_SVC_RES_CANCEL)
1428 ret = aul_send_result(b, 1);
1430 ret = aul_send_result(b, 0);
1432 /* remove result_code from bundle */
1433 bundle_del(b, AUL_SVC_K_RES_VAL);
1438 API int aul_svc_set_defapp(const char *op, const char *mime_type,
1439 const char *uri, const char *defapp)
1441 return aul_svc_set_defapp_for_uid(op, mime_type, uri, defapp, getuid());
1444 API int aul_svc_set_defapp_for_uid(const char *op, const char *mime_type,
1445 const char *uri, const char *defapp, uid_t uid)
1449 if (op == NULL || defapp == NULL)
1450 return AUL_SVC_RET_EINVAL;
1452 ret = _svc_db_check_perm(uid, false);
1454 _E("permission error : %d", ret);
1455 return AUL_SVC_RET_EILLACC;
1458 ret = _svc_db_add_app(op, mime_type, uri, defapp, uid);
1460 return AUL_SVC_RET_ERROR;
1462 return AUL_SVC_RET_OK;
1465 API int aul_svc_unset_defapp(const char *defapp)
1467 return aul_svc_unset_defapp_for_uid(defapp, getuid());
1470 API int aul_svc_unset_defapp_for_uid(const char *defapp, uid_t uid)
1475 return AUL_SVC_RET_EINVAL;
1477 ret = _svc_db_check_perm(uid, false);
1479 _E("permission error : %d", ret);
1480 return AUL_SVC_RET_EILLACC;
1483 ret = _svc_db_delete_with_pkgname(defapp, uid);
1486 return AUL_SVC_RET_ERROR;
1488 return AUL_SVC_RET_OK;
1491 API int aul_svc_unset_all_defapps()
1493 return aul_svc_unset_all_defapps_for_uid(getuid());
1496 API int aul_svc_unset_all_defapps_for_uid(uid_t uid)
1500 ret = _svc_db_check_perm(uid, false);
1502 _E("permission error : %d", ret);
1503 return AUL_SVC_RET_EILLACC;
1506 ret = _svc_db_delete_all(uid);
1509 return AUL_SVC_RET_ERROR;
1511 __invalidate_cache(uid);
1512 return AUL_SVC_RET_OK;
1515 API int aul_svc_is_defapp(const char *pkg_name)
1517 return aul_svc_is_defapp_for_uid(pkg_name, getuid());
1520 API int aul_svc_is_defapp_for_uid(const char *pkg_name, uid_t uid)
1524 ret = _svc_db_check_perm(uid, true);
1526 _E("permission error : %d", ret);
1527 return AUL_SVC_RET_EILLACC;
1530 return _svc_db_is_defapp(pkg_name, uid);
1533 API int aul_svc_data_is_array(bundle *b, const char *key)
1536 type = bundle_get_type(b, key);
1541 if (type & BUNDLE_TYPE_ARRAY)
1546 API int aul_svc_allow_transient_app(bundle *b, int wid)
1548 char win_id[MAX_LOCAL_BUFSZ];
1550 snprintf(win_id, MAX_LOCAL_BUFSZ, "%d", wid);
1553 _E("bundle is NULL");
1554 return AUL_SVC_RET_EINVAL;
1557 return __set_bundle(b, AUL_SVC_K_WIN_ID, win_id);
1560 API int aul_svc_request_transient_app(bundle *b, int callee_wid,
1561 aul_svc_host_res_fn cbfunc, void *data)
1566 API int aul_svc_subapp_terminate_request_pid(int pid)
1568 int cpid = getpid();
1573 aul_app_group_get_leader_pids(&lcnt, &lpids);
1574 for (i = 0; i < lcnt; i++) {
1575 if (lpids[i] == cpid) {
1579 aul_app_group_get_group_pids(cpid, &cnt, &pids);
1586 return aul_subapp_terminate_request_pid(pid);
1598 return aul_app_group_clear_top();
1601 API int aul_send_service_result(bundle *b)
1603 return aul_send_result(b, 0);
1606 API int aul_svc_subscribe_launch_result(bundle *b, const char *result)
1609 _E("bundle is NULL");
1610 return AUL_SVC_RET_EINVAL;
1613 return __set_bundle(b, result, "1");
1616 API int aul_svc_set_loader_id(bundle *b, int loader_id)
1618 char tmp[MAX_LOCAL_BUFSZ];
1621 _E("bundle is NULL");
1622 return AUL_SVC_RET_EINVAL;
1625 if (loader_id <= 0) {
1626 _E("invalid loader id");
1627 return AUL_SVC_RET_EINVAL;
1630 snprintf(tmp, sizeof(tmp), "%d", loader_id);
1631 return __set_bundle(b, AUL_K_LOADER_ID, tmp);
1634 API int aul_svc_set_loader_name(bundle *b, const char *loader_name)
1637 _E("bundle is NULL");
1638 return AUL_SVC_RET_EINVAL;
1642 _E("invalid loader name");
1643 return AUL_SVC_RET_EINVAL;
1646 return __set_bundle(b, AUL_K_LOADER_NAME, loader_name);
1649 API int aul_svc_set_background_launch(bundle *b, int enabled)
1652 return AUL_R_EINVAL;
1654 if (bundle_get_type(b, AUL_SVC_K_BG_LAUNCH) != BUNDLE_TYPE_NONE)
1655 bundle_del(b, AUL_SVC_K_BG_LAUNCH);
1658 bundle_add_str(b, AUL_SVC_K_BG_LAUNCH, "enable");
1663 API int aul_svc_set_alias_appid(const char *alias_appid, const char *appid)
1665 return aul_svc_set_alias_appid_for_uid(alias_appid, appid, getuid());
1668 API int aul_svc_set_alias_appid_for_uid(const char *alias_appid,
1669 const char *appid, uid_t uid)
1673 ret = _svc_db_check_perm(uid, false);
1675 _E("Permission error: %d", ret);
1676 return AUL_SVC_RET_EILLACC;
1679 ret = _svc_db_add_alias_appid(alias_appid, appid, uid);
1681 return AUL_SVC_RET_ERROR;
1683 return AUL_SVC_RET_OK;
1686 API int aul_svc_unset_alias_appid(const char *alias_appid)
1688 return aul_svc_unset_alias_appid_for_uid(alias_appid, getuid());
1691 API int aul_svc_unset_alias_appid_for_uid(const char *alias_appid, uid_t uid)
1695 ret = _svc_db_check_perm(uid, false);
1697 _E("Permission error: %d", ret);
1698 return AUL_SVC_RET_EILLACC;
1701 ret = _svc_db_delete_alias_appid(alias_appid, uid);
1703 return AUL_SVC_RET_ERROR;
1705 return AUL_SVC_RET_OK;
1708 API int aul_svc_foreach_alias_info(void (*callback)(const char *alias_appid,
1709 const char *appid, void *data), void *user_data)
1711 return aul_svc_foreach_alias_info_for_uid(callback, getuid(),
1715 API int aul_svc_foreach_alias_info_for_uid(void (*callback)(
1716 const char *alias_appid, const char *appid,
1717 void *data), uid_t uid, void *user_data)
1721 if (callback == NULL) {
1722 _E("Invalid parameter");
1723 return AUL_SVC_RET_EINVAL;
1726 ret = _svc_db_check_perm(uid, true);
1728 _E("Permission error: %d", ret);
1729 return AUL_SVC_RET_EILLACC;
1732 ret = _svc_db_foreach_alias_info(callback, uid, user_data);
1734 return AUL_SVC_RET_ERROR;
1736 return AUL_SVC_RET_OK;
1739 API int aul_svc_enable_alias_info(const char *appid)
1741 return aul_svc_enable_alias_info_for_uid(appid, getuid());
1744 API int aul_svc_enable_alias_info_for_uid(const char *appid, uid_t uid)
1748 ret = _svc_db_check_perm(uid, false);
1750 _E("Permission error: %d", ret);
1751 return AUL_SVC_RET_EILLACC;
1754 ret = _svc_db_enable_alias_info(appid, uid);
1756 return AUL_SVC_RET_ERROR;
1758 return AUL_SVC_RET_OK;
1761 API int aul_svc_disable_alias_info(const char *appid)
1763 return aul_svc_disable_alias_info_for_uid(appid, getuid());
1766 API int aul_svc_disable_alias_info_for_uid(const char *appid, uid_t uid)
1770 ret = _svc_db_check_perm(uid, false);
1772 _E("Permission error: %d", ret);
1773 return AUL_SVC_RET_EILLACC;
1776 ret = _svc_db_disable_alias_info(appid, uid);
1778 return AUL_SVC_RET_ERROR;
1780 return AUL_SVC_RET_OK;
1783 API int aul_svc_get_appid_by_alias_appid(const char *alias_appid, char **appid)
1785 return aul_svc_get_appid_by_alias_appid_for_uid(alias_appid,
1789 API int aul_svc_get_appid_by_alias_appid_for_uid(const char *alias_appid,
1790 char **appid, uid_t uid)
1794 ret = _svc_db_check_perm(uid, true);
1796 _E("Permission error: %d", ret);
1797 return AUL_SVC_RET_EILLACC;
1800 ret = _svc_db_get_appid_from_alias_info(alias_appid, appid, uid);
1802 return AUL_SVC_RET_ERROR;
1804 return AUL_SVC_RET_OK;
1807 API int aul_svc_foreach_alias_info_by_appid(int (*callback)(
1808 const char *alias_appid, const char *appid, void *data),
1809 const char *appid, void *user_data)
1811 return aul_svc_foreach_alias_info_by_appid_for_uid(callback, appid,
1812 getuid(), user_data);
1815 API int aul_svc_foreach_alias_info_by_appid_for_uid(int (*callback)(
1816 const char *alias_appid, const char *appid, void *data),
1817 const char *appid, uid_t uid, void *user_data)
1821 if (callback == NULL || appid == NULL) {
1822 _E("Invalid parameter");
1823 return AUL_SVC_RET_EINVAL;
1826 ret = _svc_db_check_perm(uid, true);
1828 _E("Permission error: %d", ret);
1829 return AUL_SVC_RET_EILLACC;
1832 ret = _svc_db_foreach_alias_info_by_appid(callback, appid,
1835 return AUL_SVC_RET_ERROR;
1837 return AUL_SVC_RET_OK;
1840 API int aul_svc_foreach_allowed_info(int (*callback)(const char *appid,
1841 const char *allowed_appid, void *data), void *user_data)
1843 return aul_svc_foreach_allowed_info_for_uid(callback,
1844 getuid(), user_data);
1847 API int aul_svc_foreach_allowed_info_for_uid(int (*callback)(const char *appid,
1848 const char *allowed_appid, void *data),
1849 uid_t uid, void *user_data)
1853 if (callback == NULL) {
1854 _E("Invalid parameter");
1855 return AUL_SVC_RET_EINVAL;
1858 ret = _svc_db_check_perm(uid, true);
1860 _E("Permission error: %d", ret);
1861 return AUL_SVC_RET_EILLACC;
1864 ret = _svc_db_foreach_allowed_info(callback, uid, user_data);
1866 return AUL_SVC_RET_ERROR;
1868 return AUL_SVC_RET_OK;
1871 API int aul_svc_foreach_allowed_info_by_appid(int (*callback)(
1872 const char *appid, const char *allowed_appid, void *data),
1873 const char *appid, void *user_data)
1875 return aul_svc_foreach_allowed_info_by_appid_for_uid(callback,
1876 appid, getuid(), user_data);
1879 API int aul_svc_foreach_allowed_info_by_appid_for_uid(int (*callback)(
1880 const char *appid, const char *allowed_appid, void *data),
1881 const char *appid, uid_t uid, void *user_data)
1885 if (callback == NULL || appid == NULL) {
1886 _E("Invalid parameter");
1887 return AUL_SVC_RET_EINVAL;
1890 ret = _svc_db_check_perm(uid, true);
1892 _E("Permission error: %d", ret);
1893 return AUL_SVC_RET_EILLACC;
1896 ret = _svc_db_foreach_allowed_info_by_appid(callback, appid,
1899 return AUL_SVC_RET_ERROR;
1901 return AUL_SVC_RET_OK;
1904 API const char *aul_svc_get_instance_id(bundle *b)
1906 return bundle_get_val(b, AUL_K_INSTANCE_ID);
1909 API int aul_svc_set_instance_id(bundle *b, const char *instance_id)
1911 if (b == NULL || instance_id == NULL) {
1912 _E("Invalid parameter");
1913 return AUL_SVC_RET_EINVAL;
1916 return __set_bundle(b, AUL_K_INSTANCE_ID, instance_id);
1919 API int aul_svc_run_service_async(bundle *b, int request_code,
1920 aul_svc_res_fn cbfunc, void *data)
1922 return __run_service(b, request_code, cbfunc, NULL, data,
1926 API int aul_svc_run_service_async_for_uid(bundle *b, int request_code,
1927 aul_svc_res_fn cbfunc, void *data, uid_t uid)
1929 return __run_service(b, request_code, cbfunc, NULL, data, uid, false);
1932 API int aul_svc_send_launch_request(bundle *b, int request_code,
1933 aul_svc_res_fn cbfunc, aul_svc_err_cb err_cb,
1936 return aul_svc_send_launch_request_for_uid(b, request_code,
1937 cbfunc, err_cb, user_data, getuid());
1940 API int aul_svc_send_launch_request_for_uid(bundle *b, int request_code,
1941 aul_svc_res_fn cbfunc, aul_svc_err_cb err_cb,
1942 void *user_data, uid_t uid)
1944 return __run_service(b, request_code, cbfunc, err_cb, user_data,