Add a new function to update status
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 04:01:42 +0000 (13:01 +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 44d6b7c..441da0e 100644 (file)
@@ -190,6 +190,7 @@ enum app_cmd {
        APP_GROUP_REMOVE = 150,
 
        APP_GET_APPID_LIST = 151,
+       APP_STATUS_UPDATE_V2 = 152,
 
        APP_CMD_MAX
 };
index 4913eaa..30315c8 100755 (executable)
@@ -192,6 +192,7 @@ API const char *aul_cmd_convert_to_string(int cmd)
                "APP_GROUP_REMOVE",
 
                "APP_GET_APPID_LIST",
+               "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;
+}