From: Hwankyu Jhun Date: Mon, 5 Dec 2016 13:05:42 +0000 (+0900) Subject: AMD moves to system session X-Git-Tag: accepted/tizen/3.0/common/20161222.075003^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=33237247adaa7a38c0963bb4f026b8dfe864b811;p=platform%2Fcore%2Fappfw%2Faul-1.git AMD moves to system session The amd socket path is changed to "/run/aul/daemons/.amd-sock". The for_uid APIs use the bundle data for adding the target uid. - Requires https://review.tizen.org/gerrit/#/c/102397/ Change-Id: Ib6371ed0248f265e6ad88d7be04e2c5918f64d46 Signed-off-by: Hwankyu Jhun --- diff --git a/include/aul_cmd.h b/include/aul_cmd.h index d3df0e6..a064d50 100644 --- a/include/aul_cmd.h +++ b/include/aul_cmd.h @@ -86,7 +86,7 @@ enum app_cmd { APP_SUSPEND = 59, AMD_RELOAD_APPINFO = 60, - AGENT_DEAD_SIGNAL = 61, + LAUNCHPAD_DEAD_SIGNAL = 61, APP_ALL_RUNNING_INFO = 62, APP_SET_APP_CONTROL_DEFAULT_APP = 63, APP_UNSET_APP_CONTROL_DEFAULT_APP = 64, @@ -112,8 +112,7 @@ enum app_cmd { UPDATE_APP_SCREEN = 82, ADD_SCREEN_VIEWER = 83, REMOVE_SCREEN_VIEWER = 84, + LAUNCHPAD_LAUNCH_SIGNAL = 85, APP_CMD_MAX }; - - diff --git a/src/aul_sock.c b/src/aul_sock.c index b60e1ba..2437a0f 100644 --- a/src/aul_sock.c +++ b/src/aul_sock.c @@ -37,6 +37,7 @@ #define MAX_NR_OF_DESCRIPTORS 2 #define MAX_PAYLOAD_SIZE (1024 * 1024 * 1) +#define PATH_AMD_SOCK "/run/aul/daemons/.amd-sock" #ifdef TIZEN_FEATURE_DEFAULT_USER #define REGULAR_UID_MIN 5000 @@ -266,7 +267,7 @@ static int __create_client_sock(int pid, uid_t uid) saddr.sun_family = AF_UNIX; if (pid == AUL_UTIL_PID) { snprintf(saddr.sun_path, sizeof(saddr.sun_path), - "/run/aul/daemons/%d/.amd-sock", uid); + "%s", PATH_AMD_SOCK); } else { snprintf(saddr.sun_path, sizeof(saddr.sun_path), "/run/aul/apps/%d/%d/.app-sock", uid, pid); diff --git a/src/launch.c b/src/launch.c index 10247cf..07c018e 100644 --- a/src/launch.c +++ b/src/launch.c @@ -294,9 +294,10 @@ int app_request_to_launchpad_for_uid(int cmd, const char *appid, bundle *kb, uid int must_free = 0; int ret = 0; bundle *b; + char buf[MAX_PID_STR_BUFSZ]; traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "AUL:REQ_TO_PAD"); - SECURE_LOGD("launch request : %s", appid); + SECURE_LOGD("launch request : appid(%s), target_uid(%d)", appid, uid); if (kb == NULL) { kb = bundle_create(); must_free = 1; @@ -307,6 +308,9 @@ int app_request_to_launchpad_for_uid(int cmd, const char *appid, bundle *kb, uid bundle_del(kb, AUL_K_APPID); bundle_add(kb, AUL_K_APPID, appid); __set_stime(kb); + snprintf(buf, sizeof(buf), "%d", uid); + bundle_del(kb, AUL_K_TARGET_UID); + bundle_add(kb, AUL_K_TARGET_UID, buf); switch (cmd) { case APP_PAUSE: @@ -999,6 +1003,7 @@ API int aul_add_loader_for_uid(const char *loader_path, bundle *kb, uid_t uid) bundle *b; bundle_raw *kb_raw = NULL; int len; + char buf[MAX_PID_STR_BUFSZ]; if (loader_path == NULL) return AUL_R_EINVAL; @@ -1007,6 +1012,8 @@ API int aul_add_loader_for_uid(const char *loader_path, bundle *kb, uid_t uid) if (b == NULL) return AUL_R_ERROR; + snprintf(buf, sizeof(buf), "%d", uid); + bundle_add_str(b, AUL_K_TARGET_UID, buf); bundle_add_str(b, AUL_K_LOADER_PATH, loader_path); if (kb) { @@ -1034,7 +1041,7 @@ API int aul_remove_loader(int loader_id) API int aul_remove_loader_for_uid(int loader_id, uid_t uid) { - char lid[MAX_PID_STR_BUFSZ]; + char buf[MAX_PID_STR_BUFSZ]; int ret; bundle *b; @@ -1047,8 +1054,10 @@ API int aul_remove_loader_for_uid(int loader_id, uid_t uid) return AUL_R_ERROR; } - snprintf(lid, sizeof(lid), "%d", loader_id); - bundle_add_str(b, AUL_K_LOADER_ID, lid); + snprintf(buf, sizeof(buf), "%d", loader_id); + bundle_add_str(b, AUL_K_LOADER_ID, buf); + snprintf(buf, sizeof(buf), "%d", uid); + bundle_add_str(b, AUL_K_TARGET_UID, buf); ret = app_send_cmd_for_uid(AUL_UTIL_PID, uid, APP_REMOVE_LOADER, b); bundle_free(b); diff --git a/src/pkginfo.c b/src/pkginfo.c index be0df27..18eb0e9 100644 --- a/src/pkginfo.c +++ b/src/pkginfo.c @@ -44,13 +44,26 @@ API int aul_app_get_pid(const char *appid) API int aul_app_get_pid_for_uid(const char *appid, uid_t uid) { - int ret = 0; + int ret; + char buf[MAX_PID_STR_BUFSZ]; + bundle *b; if (appid == NULL) return -1; - ret = aul_sock_send_raw(AUL_UTIL_PID, uid, APP_GET_PID, - (unsigned char *)appid, strlen(appid), AUL_SOCK_NONE); + b = bundle_create(); + if (b == NULL) { + _E("out of memory"); + return -1; + } + + snprintf(buf, sizeof(buf), "%d", uid); + bundle_add(b, AUL_K_APPID, appid); + bundle_add(b, AUL_K_TARGET_UID, buf); + + ret = aul_sock_send_bundle(AUL_UTIL_PID, uid, APP_GET_PID, + b, AUL_SOCK_NONE); + bundle_free(b); return ret; } @@ -62,14 +75,9 @@ API int aul_app_is_running(const char *appid) API int aul_app_is_running_for_uid(const char *appid, uid_t uid) { - int ret = 0; - - if (appid == NULL) - return 0; - - ret = aul_sock_send_raw(AUL_UTIL_PID, uid, APP_IS_RUNNING, - (unsigned char*)appid, strlen(appid), AUL_SOCK_NONE); + int ret; + ret = aul_app_get_pid_for_uid(appid, uid); if (ret > 0) return true; @@ -141,6 +149,8 @@ API int aul_app_get_running_app_info_for_uid(aul_app_info_iter_fn enum_fn, { int ret; int fd; + bundle *b; + char buf[MAX_PID_STR_BUFSZ]; internal_param_t param = { enum_fn, user_param @@ -149,8 +159,18 @@ API int aul_app_get_running_app_info_for_uid(aul_app_info_iter_fn enum_fn, if (enum_fn == NULL) return AUL_R_EINVAL; - fd = aul_sock_send_raw(AUL_UTIL_PID, uid, APP_RUNNING_INFO, NULL, - 0, AUL_SOCK_ASYNC); + b = bundle_create(); + if (b == NULL) { + _E("out of memory"); + return AUL_R_ERROR; + } + + snprintf(buf, sizeof(buf), "%d", uid); + bundle_add(b, AUL_K_TARGET_UID, buf); + + fd = aul_sock_send_bundle(AUL_UTIL_PID, uid, APP_RUNNING_INFO, + b, AUL_SOCK_ASYNC); + bundle_free(b); if (fd < 0) return aul_error_convert(fd); @@ -173,6 +193,8 @@ API int aul_app_get_all_running_app_info_for_uid(aul_app_info_iter_fn enum_fn, { int ret; int fd; + bundle *b; + char buf[MAX_PID_STR_BUFSZ]; internal_param_t param = { enum_fn, user_param @@ -181,8 +203,18 @@ API int aul_app_get_all_running_app_info_for_uid(aul_app_info_iter_fn enum_fn, if (enum_fn == NULL) return AUL_R_EINVAL; - fd = aul_sock_send_raw(AUL_UTIL_PID, uid, APP_ALL_RUNNING_INFO, NULL, - 0, AUL_SOCK_ASYNC); + b = bundle_create(); + if (b == NULL) { + _E("out of memory"); + return AUL_R_ERROR; + } + + snprintf(buf, sizeof(buf), "%d", uid); + bundle_add(b, AUL_K_TARGET_UID, buf); + + fd = aul_sock_send_bundle(AUL_UTIL_PID, uid, APP_ALL_RUNNING_INFO, + b, AUL_SOCK_ASYNC); + bundle_free(b); if (fd < 0) return aul_error_convert(fd); @@ -262,6 +294,8 @@ API int aul_app_get_appid_bypid_for_uid(int pid, char *appid, int len, int fd; int ret; const char *preinit_appid; + bundle *b; + char buf[MAX_PID_STR_BUFSZ]; if (pid <= 0 || appid == NULL) { _E("Invalid parameter"); @@ -276,8 +310,20 @@ API int aul_app_get_appid_bypid_for_uid(int pid, char *appid, int len, } } - fd = aul_sock_send_raw(AUL_UTIL_PID, uid, APP_GET_APPID_BYPID, - (unsigned char *)&pid, sizeof(pid), AUL_SOCK_ASYNC); + 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_APPID_BYPID, + b, AUL_SOCK_ASYNC); + bundle_free(b); if (fd <= 0) return AUL_R_ERROR; @@ -329,6 +375,8 @@ API int aul_app_get_pkgid_bypid_for_uid(int pid, char *pkgid, int len, int fd; int ret; const char *preinit_pkgid; + bundle *b; + char buf[MAX_PID_STR_BUFSZ]; if (pid <= 0 || pkgid == NULL) { _E("Invalid parameter"); @@ -348,8 +396,20 @@ API int aul_app_get_pkgid_bypid_for_uid(int pid, char *pkgid, int len, } } - fd = aul_sock_send_raw(AUL_UTIL_PID, uid, APP_GET_PKGID_BYPID, - (unsigned char *)&pid, sizeof(pid), AUL_SOCK_ASYNC); + 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_PKGID_BYPID, + b, AUL_SOCK_ASYNC); + bundle_free(b); if (fd <= 0) return AUL_R_ERROR; @@ -374,6 +434,16 @@ API int aul_app_get_pkgid_bypid(int pid, char *pkgid, int len) API int aul_update_rua_stat_for_uid(bundle *b, uid_t uid) { int ret; + char buf[MAX_PID_STR_BUFSZ]; + + if (b == NULL) { + _E("Invalid parameter"); + return AUL_R_EINVAL; + } + + snprintf(buf, sizeof(buf), "%d", uid); + bundle_del(b, AUL_K_TARGET_UID); + bundle_add(b, AUL_K_TARGET_UID, buf); ret = aul_sock_send_bundle(AUL_UTIL_PID, uid, APP_UPDATE_RUA_STAT, b, AUL_SOCK_NONE); @@ -383,11 +453,17 @@ API int aul_update_rua_stat_for_uid(bundle *b, uid_t uid) API int aul_add_rua_history_for_uid(bundle *b, uid_t uid) { int ret; + char buf[MAX_PID_STR_BUFSZ]; if (b == NULL) { SECURE_LOGE("invalid param"); return AUL_R_EINVAL; } + + snprintf(buf, sizeof(buf), "%d", uid); + bundle_del(b, AUL_K_TARGET_UID); + bundle_add(b, AUL_K_TARGET_UID, buf); + ret = aul_sock_send_bundle(AUL_UTIL_PID, uid, APP_ADD_HISTORY, b, AUL_SOCK_NONE); return ret; @@ -396,18 +472,27 @@ API int aul_add_rua_history_for_uid(bundle *b, uid_t uid) API int aul_delete_rua_history_for_uid(bundle *b, uid_t uid) { int ret; - bundle_raw *br = NULL; - int datalen = 0; + char buf[MAX_PID_STR_BUFSZ]; + bundle *kb = NULL; + + if (b == NULL) { + kb = bundle_create(); + if (kb == NULL) { + _E("out of memory"); + return AUL_R_ERROR; + } - /* b can be NULL if b is NULL delete all rua history */ - if (b != NULL) - bundle_encode(b, &br, &datalen); + b = kb; + } - ret = aul_sock_send_raw(AUL_UTIL_PID, uid, - APP_REMOVE_HISTORY, br, datalen, AUL_SOCK_NONE); + snprintf(buf, sizeof(buf), "%d", uid); + bundle_del(b, AUL_K_TARGET_UID); + bundle_add(b, AUL_K_TARGET_UID, buf); - if (br != NULL) - free(br); + ret = aul_sock_send_bundle(AUL_UTIL_PID, uid, APP_REMOVE_HISTORY, + b, AUL_SOCK_NONE); + if (kb) + bundle_free(kb); return ret; } @@ -458,15 +543,28 @@ API int aul_app_get_last_caller_pid(int pid) API int aul_app_get_last_caller_pid_for_uid(int pid, uid_t uid) { int ret; + char buf[MAX_PID_STR_BUFSZ]; + bundle *b; if (pid < 0) { _E("Invalid parameter"); return AUL_R_EINVAL; } - ret = aul_sock_send_raw(AUL_UTIL_PID, uid, APP_GET_LAST_CALLER_PID, - (unsigned char *)&pid, sizeof(int), - AUL_SOCK_NONE); + b = bundle_create(); + if (b == NULL) { + _E("Failed to create bundle"); + 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); + + ret = aul_sock_send_bundle(AUL_UTIL_PID, uid, APP_GET_LAST_CALLER_PID, + b, AUL_SOCK_NONE); + bundle_free(b); if (ret < 0) return aul_error_convert(ret); diff --git a/src/status.c b/src/status.c index 003a6d2..ab1f0dd 100644 --- a/src/status.c +++ b/src/status.c @@ -77,12 +77,26 @@ API int aul_app_get_status_bypid(int pid) API int aul_app_get_status_bypid_for_uid(int pid, uid_t uid) { int ret; + char buf[MAX_PID_STR_BUFSZ]; + bundle *b; if (pid == getpid()) return app_status; - ret = aul_sock_send_raw(AUL_UTIL_PID, uid, APP_GET_STATUS, - (unsigned char *)&pid, sizeof(pid), AUL_SOCK_NONE); + 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); + + ret = aul_sock_send_bundle(AUL_UTIL_PID, uid, APP_GET_STATUS, + b, AUL_SOCK_NONE); + bundle_free(b); return ret; } @@ -96,6 +110,7 @@ API int aul_app_get_status_for_uid(const char *appid, uid_t uid) { int ret; bundle *kb; + char buf[MAX_PID_STR_BUFSZ]; if (appid == NULL) return AUL_R_EINVAL; @@ -106,7 +121,9 @@ API int aul_app_get_status_for_uid(const char *appid, uid_t uid) return AUL_R_ERROR; } + snprintf(buf, sizeof(buf), "%d", uid); bundle_add(kb, AUL_K_APPID, appid); + bundle_add(kb, AUL_K_TARGET_UID, buf); ret = app_send_cmd_for_uid(AUL_UTIL_PID, uid, APP_GET_STATUS_BY_APPID, kb); bundle_free(kb); diff --git a/tool/app_launcher.c b/tool/app_launcher.c index e842b71..de867ac 100644 --- a/tool/app_launcher.c +++ b/tool/app_launcher.c @@ -42,6 +42,7 @@ #include "aul_svc.h" #include "launch.h" +#define PATH_RUN "/run" #define AMD_READY ".amd_ready" #define LAUNCHPAD_PROCESS_POOL_SOCK ".launchpad-process-pool-sock" #define APP_TYPE_UI "uiapp" @@ -373,11 +374,8 @@ static void __watch_destroy_cb(gpointer data) static void __watch_amd_ready(const char *appid, int pid) { - char buf[PATH_MAX]; struct amd_watch *watch; - snprintf(buf, sizeof(buf), "/run/user/%d", uid); - watch = (struct amd_watch *)calloc(1, sizeof(struct amd_watch)); if (watch == NULL) return; @@ -397,7 +395,7 @@ static void __watch_amd_ready(const char *appid, int pid) return; } - watch->wd = inotify_add_watch(watch->fd, buf, IN_CREATE); + watch->wd = inotify_add_watch(watch->fd, PATH_RUN, IN_CREATE); if (watch->wd < 0) { close(watch->fd); free(watch->appid); @@ -423,7 +421,7 @@ static void __register_appinfo(const char *appid, int pid) { char buf[PATH_MAX]; - snprintf(buf, sizeof(buf), "/run/user/%d/%s", uid, AMD_READY); + snprintf(buf, sizeof(buf), "/run/%s", AMD_READY); if (access(buf, F_OK) == 0) { aul_app_register_pid(appid, pid); return; @@ -784,8 +782,7 @@ int main(int argc, char **argv) return -1; } - snprintf(path, sizeof(path), "/run/user/%d/%s", - uid, AMD_READY); + snprintf(path, sizeof(path), "/run/%s", AMD_READY); if (access(path, F_OK) == 0) g_idle_add(run_func, args.appid); else