Add a new function for app-defined loader feature 98/224798/2
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 13 Feb 2020 06:38:36 +0000 (15:38 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 17 Feb 2020 09:22:08 +0000 (18:22 +0900)
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 <h.jhun@samsung.com>
include/app_control_internal.h
src/app_control.c

index 743f6a4..993b3ba 100644 (file)
@@ -279,6 +279,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);
+
+/**
  * @}
  */
 
index 6237923..a9ed623 100644 (file)
@@ -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;
+}