Add a new function to update status 04/254204/4
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 25 Feb 2021 03:36:25 +0000 (12:36 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 25 Feb 2021 03:38:21 +0000 (12:38 +0900)
The function is to update status synchronously.

Adds:
 - aul_status_update_v2()

Requires:
 - https://review.tizen.org/gerrit/#/c/platform/core/appfw/aul-1/+/254204/
 - https://review.tizen.org/gerrit/#/c/platform/core/appfw/appcore-agent/+/254205/
 - https://review.tizen.org/gerrit/#/c/platform/core/appfw/amd/+/254206/

Change-Id: I5ee199c1dd576fb8d19e4c40d132ce4649f7d3cb
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/aul.h
include/aul_cmd.h
src/aul_cmd.c
src/status.c

index 4bf4483..20b978d 100644 (file)
@@ -3003,6 +3003,11 @@ int aul_app_is_running_with_instance_id(const char *appid,
 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);
 
+/**
+ * @remarks This function is only for App Framework internally.
+ */
+int aul_status_update_v2(int status);
+
 #ifdef __cplusplus
        }
 #endif
index ee316bb..089cee1 100644 (file)
@@ -195,6 +195,8 @@ enum app_cmd {
        COMP_PORT_DESTROY = 154,
        APP_LIFECYCLE_UPDATE_STATE = 155,
 
+       APP_STATUS_UPDATE_V2 = 156,
+
        APP_CMD_MAX
 };
 
index e9e98fb..3d80c35 100755 (executable)
@@ -197,6 +197,8 @@ API const char *aul_cmd_convert_to_string(int cmd)
                "COMP_PORT_DESTROY",
                "APP_LIFECYCLE_UPDATE_STATE",
 
+               "APP_STATUS_UPDATE_V2",
+
                "CUSTOM_COMMAND"
        };
 
index 78d24fb..e8d683b 100644 (file)
@@ -27,6 +27,7 @@
 #include "aul_api.h"
 #include "launch.h"
 #include "aul_app_com.h"
+#include "aul_error.h"
 
 typedef struct _app_status_cb_info_t {
        int (*handler)(int status, void *data);
@@ -417,3 +418,40 @@ API const char *aul_app_status_convert_to_string(int status)
                return "Unknown status";
        }
 }
+
+API int aul_status_update_v2(int status)
+{
+       char buf[12];
+       bundle *b;
+       int ret;
+
+       if (status < 0) {
+               _E("Invalid parameter");
+               return AUL_R_EINVAL;
+       }
+
+       if (app_status == status)
+               return AUL_R_OK;
+
+       app_status = status;
+
+       b = bundle_create();
+       if (!b) {
+               _E("Out of memory");
+               return AUL_R_ENOMEM;
+       }
+
+       snprintf(buf, sizeof(buf), "%d", status);
+       bundle_add(b, AUL_K_STATUS, buf);
+
+       ret = aul_sock_send_bundle(AUL_UTIL_PID, getuid(), APP_STATUS_UPDATE_V2,
+                       b, AUL_SOCK_NONE);
+       if (ret != 0) {
+               _E("Failed to update app status. error(%d)", ret);
+               return aul_error_convert(ret);
+       } else {
+               aul_invoke_status_local_cb(status);
+       }
+
+       return AUL_R_OK;
+}