diff options
author | Junghoon Park <jh9216.park@samsung.com> | 2015-12-07 16:57:45 +0900 |
---|---|---|
committer | Junghoon Park <jh9216.park@samsung.com> | 2015-12-08 12:09:19 +0900 |
commit | 89d277a52c3319747d5f4f010aa9b61994f4959c (patch) | |
tree | 1644a22fa306161149b13201f41f23b78aca23fe | |
parent | 5d733d5578bbf79f1057a2206bb0b4527d6d0ca2 (diff) | |
download | aul-1-89d277a52c3319747d5f4f010aa9b61994f4959c.tar.gz aul-1-89d277a52c3319747d5f4f010aa9b61994f4959c.tar.bz2 aul-1-89d277a52c3319747d5f4f010aa9b61994f4959c.zip |
Add APIs for dynamic loadersubmit/tizen/20151208.055026accepted/tizen/wearable/20151208.125833accepted/tizen/tv/20151208.125817accepted/tizen/mobile/20151208.125757
Change-Id: Ibdf2a4a2a81e5809223ea26e5c1a463ffde9ac85
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
-rw-r--r-- | am_daemon/amd_request.c | 42 | ||||
-rw-r--r-- | include/app_sock.h | 4 | ||||
-rw-r--r-- | include/aul.h | 37 | ||||
-rwxr-xr-x | include/aul_svc.h | 5 | ||||
-rw-r--r-- | src/launch.c | 34 | ||||
-rwxr-xr-x | src/service.c | 19 |
6 files changed, 141 insertions, 0 deletions
diff --git a/am_daemon/amd_request.c b/am_daemon/amd_request.c index 690c4471..e33c144f 100644 --- a/am_daemon/amd_request.c +++ b/am_daemon/amd_request.c @@ -47,6 +47,7 @@ #include "amd_status.h" #include "amd_app_group.h" #include "amd_cynara.h" +#include "launch.h" #define INHOUSE_UID tzplatform_getuid(TZ_USER_NAME) #define REGULAR_UID_MIN 5000 @@ -935,6 +936,45 @@ static int __dispatch_app_get_status(int clifd, const app_pkt_t *pkt, struct ucr return 0; } +static int __dispatch_app_add_loader(int clifd, const app_pkt_t *pkt, struct ucred *cr) +{ + bundle *kb; + int ret; + char tmpbuf[MAX_PID_STR_BUFSZ]; + + kb = bundle_decode(pkt->data, pkt->len); + if (kb == NULL) { + close(clifd); + return -1; + } + + snprintf(tmpbuf, sizeof(tmpbuf), "%d", getpgid(cr->pid)); + bundle_add(kb, AUL_K_CALLER_PID, tmpbuf); + ret = app_agent_send_cmd(cr->uid, PAD_CMD_ADD_LOADER, kb); + bundle_free(kb); + __send_result_to_client(clifd, ret); + + return ret; +} + +static int __dispatch_app_remove_loader(int clifd, const app_pkt_t *pkt, struct ucred *cr) +{ + bundle *kb; + int ret; + + kb = bundle_decode(pkt->data, pkt->len); + if (kb == NULL) { + close(clifd); + return -1; + } + + ret = app_agent_send_cmd(cr->uid, PAD_CMD_REMOVE_LOADER, kb); + bundle_free(kb); + __send_result_to_client(clifd, ret); + + return ret; +} + static int __dispatch_agent_dead_signal(int clifd, const app_pkt_t *pkt, struct ucred *cr) { _D("AMD_AGENT_DEAD_SIGNAL"); @@ -1013,6 +1053,8 @@ static app_cmd_dispatch_func dispatch_table[APP_CMD_MAX] = { [APP_GROUP_LOWER] = __dispatch_app_group_lower, [APP_GROUP_CLEAR_TOP] = __dispatch_app_group_clear_top, [APP_GET_STATUS] = __dispatch_app_get_status, + [APP_ADD_LOADER] = __dispatch_app_add_loader, + [APP_REMOVE_LOADER] = __dispatch_app_remove_loader, [AMD_RELOAD_APPINFO] = __dispatch_amd_reload_appinfo, [AGENT_DEAD_SIGNAL] = __dispatch_agent_dead_signal, }; diff --git a/include/app_sock.h b/include/app_sock.h index d9a4594f..65c9aace 100644 --- a/include/app_sock.h +++ b/include/app_sock.h @@ -68,6 +68,8 @@ enum app_cmd { APP_GROUP_CLEAR_TOP, APP_GET_STATUS, APP_GET_SOCKET_PAIR, + APP_ADD_LOADER, + APP_REMOVE_LOADER, /* for special purpose */ AMD_RELOAD_APPINFO, @@ -89,6 +91,8 @@ enum app_cmd { #define PAD_CMD_LAUNCH 0 #define PAD_CMD_VISIBILITY 10 +#define PAD_CMD_ADD_LOADER 11 +#define PAD_CMD_REMOVE_LOADER 12 typedef struct _app_pkt_t { int cmd; diff --git a/include/aul.h b/include/aul.h index 52a6d454..ec4708f2 100644 --- a/include/aul.h +++ b/include/aul.h @@ -157,6 +157,10 @@ typedef enum _aul_type{ #define AUL_TEP_PATH "_AUL_TEP_PATH_" /** AUL internal private key */ #define AUL_K_COMP_TYPE "__AUL_COMP_TYPE__" +/** AUL internal private key */ +#define AUL_K_LOADER_ID "__AUL_LOADER_ID__" +/** AUL internal private key */ +#define AUL_K_LOADER_PATH "__AUL_LOADER_PATH__" /** * @brief This is callback function for aul_launch_init @@ -1880,6 +1884,39 @@ int aul_is_tep_mount_dbus_done(const char *tep_string); */ int aul_forward_app(const char *appid, bundle *kb); +/** + * @par Description: + * This API create custom launchpad-loader + * @par Purpose: + * This API's purpose is to make a slot for custom loader. + * Once it is made, added loader will make a candidate process to use. + * + * @param[in] loader_path The file name of the custom loader binary including full path + * @return Loader ID if success, negative value(<0) if fail + * + * @remark + * This API is only for Appfw internally. + * This API is only available in User Session. +*/ +int aul_add_loader(const char *loader_path); + +/** + * @par Description: + * This API destroy custom launchpad-loader + * @par Purpose: + * This API's purpose is to remove a slot for custom loader. + * Once it is removed, the prepared process will be removed as well. + * + * @param[in] loader_id Loader ID + * @return 0 if success, negative value(<0) if fail + * + * @remark + * This API is only for Appfw internally. + * This API is only available in User Session. +*/ +int aul_remove_loader(int loader_id); + + #ifdef __cplusplus } #endif diff --git a/include/aul_svc.h b/include/aul_svc.h index 5bff303d..debb2429 100755 --- a/include/aul_svc.h +++ b/include/aul_svc.h @@ -1089,6 +1089,11 @@ int aul_svc_request_transient_app(bundle *b, int callee_wid, int aul_svc_subscribe_launch_result(bundle *b, const char *event); +/* + * This API is only for Appfw internally. + */ +int aul_svc_set_loader_id(bundle *b, int loader_id); + #ifdef __cplusplus } #endif diff --git a/src/launch.c b/src/launch.c index 97356c37..fe79d807 100644 --- a/src/launch.c +++ b/src/launch.c @@ -898,4 +898,38 @@ SLPAPI int aul_check_tep_mount(const char *tep_path) return 0; } +SLPAPI int aul_add_loader(const char *loader_path) +{ + int ret; + bundle *b; + + if (loader_path == NULL) + return AUL_R_EINVAL; + + b = bundle_create(); + bundle_add_str(b, AUL_K_LOADER_PATH, loader_path); + ret = app_send_cmd(AUL_UTIL_PID, APP_ADD_LOADER, b); + bundle_free(b); + + return ret; +} + +SLPAPI int aul_remove_loader(int loader_id) +{ + char lid[MAX_PID_STR_BUFSZ]; + int ret; + bundle *b; + + if (loader_id <= 0) + return AUL_R_EINVAL; + + b = bundle_create(); + snprintf(lid, MAX_PID_STR_BUFSZ, "%d", loader_id); + bundle_add_str(b, AUL_K_LOADER_ID, lid); + ret = app_send_cmd(AUL_UTIL_PID, APP_REMOVE_LOADER, b); + bundle_free(b); + + return ret; +} + diff --git a/src/service.c b/src/service.c index 243fb1f5..198d9519 100755 --- a/src/service.c +++ b/src/service.c @@ -1331,3 +1331,22 @@ SLPAPI int aul_svc_subscribe_launch_result(bundle *b, const char *result) return __set_bundle(b, result, "1"); } + +SLPAPI int aul_svc_set_loader_id(bundle *b, int loader_id) +{ + char tmp[MAX_LOCAL_BUFSZ]; + + if (b == NULL) { + _E("bundle for aul_svc_set_loader_id is NULL"); + return AUL_SVC_RET_EINVAL; + } + + if (loader_id <= 0) { + _E("invalid loader id"); + return AUL_SVC_RET_EINVAL; + } + + snprintf(tmp, sizeof(tmp),"%d", loader_id); + return __set_bundle(b, AUL_K_LOADER_ID, tmp); +} + |