Add new functions for app-defined loader feature 66/224466/5
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 11 Feb 2020 00:43:11 +0000 (09:43 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 17 Feb 2020 09:20:14 +0000 (18:20 +0900)
Adds:
 - aul_prepare_app_defined_loader()
 - aul_prepare_app_defined_loader_for_uid()

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: I1d49468985fa04c0dd6a3d70a45347d4ffecc0a4
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/aul.h
include/aul_cmd.h
src/aul_cmd.c
src/launch.c

index aabbd4c..4bf4483 100644 (file)
@@ -2990,6 +2990,19 @@ int aul_terminate_app_for_uid(const char *appid, uid_t uid);
 int aul_app_is_running_with_instance_id(const char *appid,
                const char *instance_id, bool *running);
 
+/**
+ * @brief Sends a preparation request for an app-defined loader.
+ * @since_tizen 5.5
+ *
+ * @param[in]   loader_name     The loader name
+ * @return      @c the loader ID on success,
+ *              otherwise a negative error value
+ *
+ * @remarks This function is only for App Framework internally.
+ */
+int aul_prepare_app_defined_loader(const char *loader_name);
+int aul_prepare_app_defined_loader_for_uid(const char *loader_name, uid_t uid);
+
 #ifdef __cplusplus
        }
 #endif
index e926a23..bf7160a 100755 (executable)
@@ -176,6 +176,7 @@ enum app_cmd {
        LAUNCHER_SERVICE_NOTIFY_ANIMATION_STARTED = 137,
        LAUNCHER_SERVICE_NOTIFY_ANIMATION_FINISHED = 138,
        APP_SEND_RESUME_REQUEST = 139,
+       APP_PREPARE_APP_DEFINED_LOADER = 140,
 
        APP_CMD_MAX
 };
index 5cf98e7..46d071c 100755 (executable)
@@ -304,6 +304,8 @@ API const char *aul_cmd_convert_to_string(int cmd)
                return "LAUNCHER_SERVICE_NOTIFY_ANIMATION_FINISHED";
        case APP_SEND_RESUME_REQUEST:
                return "APP_SEND_RESUME_REQUEST";
+       case APP_PREPARE_APP_DEFINED_LOADER:
+               return "APP_PREPARE_APP_DEFINED_LOADER";
        default:
                return "CUSTOM_COMMAND";
        }
index 08b03d3..927a0c3 100755 (executable)
@@ -1021,3 +1021,42 @@ API int aul_terminate_app_for_uid(const char *appid, uid_t uid)
 
        return __send_request(APP_TERMINATE, uid, appid, NULL);
 }
+
+API int aul_prepare_app_defined_loader(const char *loader_name)
+{
+       return aul_prepare_app_defined_loader_for_uid(loader_name, getuid());
+}
+
+API int aul_prepare_app_defined_loader_for_uid(const char *loader_name,
+               uid_t uid)
+{
+       char buf[MAX_PID_STR_BUFSZ];
+       bundle *b;
+       int ret;
+
+       if (!loader_name) {
+               _E("Invalid parameter");
+               return AUL_R_EINVAL;
+       }
+
+       b = bundle_create();
+       if (!b) {
+               _E("Out of memory");
+               return AUL_R_ENOMEM;
+       }
+
+       bundle_add(b, AUL_K_LOADER_NAME, loader_name);
+       snprintf(buf, sizeof(buf), "%u", uid);
+       bundle_add(b, AUL_K_TARGET_UID, buf);
+
+       ret = app_send_cmd_for_uid(AUL_UTIL_PID, uid,
+                       APP_PREPARE_APP_DEFINED_LOADER, b);
+       bundle_free(b);
+       if (ret < 0) {
+               _E("Failed to prepare app-defined loader. error(%d)", ret);
+               return ret;
+       }
+
+       _I("loader id(%d)", ret);
+       return ret;
+}