#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
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");
[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,
};
APP_GROUP_CLEAR_TOP,
APP_GET_STATUS,
APP_GET_SOCKET_PAIR,
+ APP_ADD_LOADER,
+ APP_REMOVE_LOADER,
/* for special purpose */
AMD_RELOAD_APPINFO,
#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;
#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
*/
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
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
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;
+}
+
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);
+}
+