Fix app_control_prepare_app_defined_loader() function 57/225157/4
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 18 Feb 2020 01:12:01 +0000 (10:12 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 18 Feb 2020 02:18:17 +0000 (11:18 +0900)
- Fixes description
- Sets loader id to the bundle object

Requires:
 - https://review.tizen.org/gerrit/#/c/platform/core/appfw/aul-1/+/225161/
 - https://review.tizen.org/gerrit/#/c/platform/core/appfw/amd/+/225160/
 - https://review.tizen.org/gerrit/#/c/platform/core/api/app-control/+/225157/

Change-Id: I09b9cc036b90d6cccf34e29e246e0792b46f9075
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/app_control_internal.h
src/app_control.c

index 993b3baa92a67e76b7f74d7787178576ba47b883..b4bd9057e419641b3246632f15b955626511037d 100644 (file)
@@ -291,6 +291,8 @@ int app_control_send_resume_request(app_control_h app_control, app_control_resul
  * @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
+ *
+ * @remarks This function is only available for platform level signed applications.
  */
 int app_control_prepare_app_defined_loader(app_control_h app_control, const char *loader_id);
 
index a9ed623ae6a1891fbede688ad37aaafc619ac052..cf5fa55d2edfb1dfc2c6c7db8729849e1ae1298a 100644 (file)
@@ -71,7 +71,6 @@ struct app_control_s {
        app_control_type_e type;
        bundle *data;
        int launch_pid;
-       int loader_id;
 };
 
 typedef struct app_control_request_context_s {
@@ -2461,9 +2460,10 @@ static int __convert_aul_error(int result)
 int app_control_prepare_app_defined_loader(app_control_h app_control,
                const char *loader_id)
 {
+       const char *loader_name = loader_id; /* for readability */
        int ret;
 
-       if (!app_control || !loader_id) {
+       if (!app_control || !loader_name) {
                return app_control_error(APP_CONTROL_ERROR_INVALID_PARAMETER,
                                __FUNCTION__, "Inivalid parameter");
        }
@@ -2473,14 +2473,26 @@ int app_control_prepare_app_defined_loader(app_control_h app_control,
                                __FUNCTION__, "Invalid parameter");
        }
 
-       ret = aul_prepare_app_defined_loader(loader_id);
+       ret = aul_prepare_app_defined_loader(loader_name);
        if (ret < 0) {
                return app_control_error(__convert_aul_error(ret),
                                __FUNCTION__,
                                "Failed to prepare app defined loader");
        }
 
-       app_control->loader_id = ret;
+       bundle_del(app_control->data, AUL_K_APP_DEFINED_LOADER);
+       bundle_add(app_control->data, AUL_K_APP_DEFINED_LOADER, loader_name);
+
+       ret = aul_svc_set_loader_id(app_control->data, ret);
+       if (ret < 0) {
+               if (ret == AUL_SVC_RET_EINVAL)
+                       ret = APP_CONTROL_ERROR_INVALID_PARAMETER;
+               else
+                       ret = APP_CONTROL_ERROR_OUT_OF_MEMORY;
+
+               return app_control_error(ret, __FUNCTION__,
+                               "Failed to set loader id");
+       }
 
        return APP_CONTROL_ERROR_NONE;
 }