From b32027554fee85a5ac0690d30de95f0ceadf1fa8 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 13 Feb 2020 15:38:36 +0900 Subject: [PATCH] Add a new function for app-defined loader feature Adds: - app_control_prepare_app_defined_loader() Requires: - https://review.tizen.org/gerrit/#/c/platform/core/appfw/aul-1/+/224466/ - https://review.tizen.org/gerrit/#/c/platform/core/appfw/amd/+/224634/ - https://review.tizen.org/gerrit/#/c/platform/core/api/app-control/+/224798/ - https://review.tizen.org/gerrit/#/c/platform/core/appfw/launchpad/+/224161/ Change-Id: I595e9b50fda1a38ef17bde7c3da3b694582e5af7 Signed-off-by: Hwankyu Jhun --- include/app_control_internal.h | 16 +++++++++++++ src/app_control.c | 42 ++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/include/app_control_internal.h b/include/app_control_internal.h index 743f6a4..993b3ba 100644 --- a/include/app_control_internal.h +++ b/include/app_control_internal.h @@ -278,6 +278,22 @@ int app_control_set_caller_instance_id(app_control_h app_control, const char *in */ int app_control_send_resume_request(app_control_h app_control, app_control_result_cb callback, void *user_data); +/** + * @brief Sends the preparation request for the app-defined loader. + * + * @since_tizen 5.5 + * @param[in] app_control The app_control handle + * @param[in] loader_id The app-defined loader ID + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_CONTROL_ERROR_NONE Successful + * @retval #APP_CONTROL_ERROR_PERMISSION_DENIED Permission denied + * @retval #APP_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_CONTROL_ERROR_OUT_OF_MEMORY Out of memory + * @retval #APP_CONTROL_ERROR_IO_ERROR I/O error + */ +int app_control_prepare_app_defined_loader(app_control_h app_control, const char *loader_id); + /** * @} */ diff --git a/src/app_control.c b/src/app_control.c index 6237923..a9ed623 100644 --- a/src/app_control.c +++ b/src/app_control.c @@ -71,6 +71,7 @@ struct app_control_s { app_control_type_e type; bundle *data; int launch_pid; + int loader_id; }; typedef struct app_control_request_context_s { @@ -2442,3 +2443,44 @@ int app_control_send_resume_request(app_control_h app_control, return __send_resume_request(app_control, result_cb, user_data); } + +static int __convert_aul_error(int result) +{ + switch (result) { + case AUL_R_EINVAL: + return APP_CONTROL_ERROR_INVALID_PARAMETER; + case AUL_R_ENOMEM: + return APP_CONTROL_ERROR_OUT_OF_MEMORY; + case AUL_R_EILLACC: + return APP_CONTROL_ERROR_PERMISSION_DENIED; + default: + return APP_CONTROL_ERROR_IO_ERROR; + } +} + +int app_control_prepare_app_defined_loader(app_control_h app_control, + const char *loader_id) +{ + int ret; + + if (!app_control || !loader_id) { + return app_control_error(APP_CONTROL_ERROR_INVALID_PARAMETER, + __FUNCTION__, "Inivalid parameter"); + } + + if (app_control_validate(app_control)) { + return app_control_error(APP_CONTROL_ERROR_INVALID_PARAMETER, + __FUNCTION__, "Invalid parameter"); + } + + ret = aul_prepare_app_defined_loader(loader_id); + if (ret < 0) { + return app_control_error(__convert_aul_error(ret), + __FUNCTION__, + "Failed to prepare app defined loader"); + } + + app_control->loader_id = ret; + + return APP_CONTROL_ERROR_NONE; +} -- 2.34.1