Support updating status synchronously
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 25 Feb 2021 03:12:36 +0000 (12:12 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 25 Feb 2021 04:02:26 +0000 (13:02 +0900)
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: Iaa205f3f38623344158960bb9c4bdae49d944a08
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/amd_app_status.c

index 5389bbe0928f5b71deafa7620ae3af5c5247e16e..f20f1962750a84ce076b427f16a5d9133e083452 100644 (file)
@@ -2392,6 +2392,57 @@ static int __dispatch_app_context_get_by_pid(request_h req)
        return 0;
 }
 
+static int __dispatch_app_status_update_v2(request_h req)
+{
+       app_status_h app_status;
+       struct appinfo *ai;
+       const char *appid;
+       const char *val;
+       int status = -1;
+       bundle *b;
+       int pid;
+       int ret;
+
+       pid = _request_get_pid(req);
+       app_status = _app_status_find_v2(pid);
+       if (!app_status) {
+               _E("Failed to find app status. pid(%d)", pid);
+               _request_send_result(req, -EINVAL);
+               return -1;
+       }
+
+       b = _request_get_bundle(req);
+       if (!b) {
+               _E("Failed to get bundle");
+               _request_send_result(req, -EINVAL);
+               return -1;
+       }
+
+       val = bundle_get_val(b, AUL_K_STATUS);
+       if (!val) {
+               _E("Failed to get status");
+               _request_send_result(req, -EINVAL);
+               return -1;
+       }
+
+       if (isdigit(*val))
+               status = atoi(val);
+
+       if (status == STATUS_NORESTART) {
+               appid = _app_status_get_appid(app_status);
+               ai = _appinfo_find(_request_get_target_uid(req), appid);
+               ret = _appinfo_set_value(ai, AIT_STATUS, "norestart");
+       } else {
+               ret = _app_status_update_status(app_status, status,
+                               false, true);
+       }
+
+       _request_send_result(req, ret);
+       _W("[APP_STATUS_UPDATE_V2] pid(%d), status(%d), result(%d)",
+                       pid, status, ret);
+       return 0;
+}
+
 static request_cmd_dispatch __dispatch_table[] = {
        {
                .cmd = APP_RUNNING_INFO,
@@ -2473,6 +2524,10 @@ static request_cmd_dispatch __dispatch_table[] = {
                .cmd = APP_CONTEXT_GET_BY_PID,
                .callback = __dispatch_app_context_get_by_pid
        },
+       {
+               .cmd = APP_STATUS_UPDATE_V2,
+               .callback = __dispatch_app_status_update_v2
+       },
 };
 
 static cynara_checker __cynara_checkers[] = {