Add APIs for dynamic loader 81/53481/6 accepted/tizen/mobile/20151208.125757 accepted/tizen/tv/20151208.125817 accepted/tizen/wearable/20151208.125833 submit/tizen/20151208.055026
authorJunghoon Park <jh9216.park@samsung.com>
Mon, 7 Dec 2015 07:57:45 +0000 (16:57 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Tue, 8 Dec 2015 03:09:19 +0000 (12:09 +0900)
Change-Id: Ibdf2a4a2a81e5809223ea26e5c1a463ffde9ac85
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
am_daemon/amd_request.c
include/app_sock.h
include/aul.h
include/aul_svc.h
src/launch.c
src/service.c

index 690c447..e33c144 100644 (file)
@@ -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,
 };
index d9a4594..65c9aac 100644 (file)
@@ -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;
index 52a6d45..ec4708f 100644 (file)
@@ -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
index 5bff303..debb242 100755 (executable)
@@ -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
index 97356c3..fe79d80 100644 (file)
@@ -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;
+}
+
 
index 243fb1f..198d951 100755 (executable)
@@ -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);
+}
+