Fix widget command check 16/252416/1
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 27 Jan 2021 22:33:50 +0000 (07:33 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 28 Jan 2021 00:24:32 +0000 (09:24 +0900)
If the widget application status is STATUS_DYING and the operation is
not "create", the launch request is rejected.

Change-Id: I26def5bc459977d21c8e650d9f0878473b64001e
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/amd_launch.c
src/lib/api/amd_api_noti_msg.h
src/modules/widget/src/amd_widget.c

index f0d7fc12555c8fb63d889bce57da6b965b85a4c1..a53898b26a13e72aa89a61956db15ac77e2029df 100644 (file)
@@ -2981,8 +2981,9 @@ static int __prepare_starting_app(struct launch_s *handle, request_h req,
                                        0, 0, req, NULL) < 0)
                        return -1;
        } else if (caller_appid && strcmp(comp_type, APP_TYPE_WIDGET) == 0) {
+               status = _app_status_get_status(handle->app_status);
                if (_noti_send(AMD_NOTI_MSG_LAUNCH_PREPARE_WIDGET,
-                                       0, 0, req, NULL) < 0)
+                                       handle->pid, status, req, NULL) < 0)
                        return -1;
        } else if (strcmp(comp_type, APP_TYPE_COMPONENT_BASED) == 0) {
                status = _app_status_get_status(handle->app_status);
index bfa8f4522e6bf9eab6e6604c3d634b43568adef3..8b97ad63ce64d2afe33a59454794c4e5b9bcaaeb 100644 (file)
@@ -520,7 +520,9 @@ extern "C" {
 /**
  * @brief Definition for the notification message: Preparing the launch request that is launching the Widget application is.
  * @details If the return value is less than AMD_NOTI_STOP, the launch request is stopped. And then, the caller process gets a negative error value.
- * @details Input: arg3(amd_request_h) The request handle.\n
+ * @details Input: arg1(int) The process ID.(Since Tizen 6.0)\n
+ *          Input: arg2(int) The status of the application.(Since Tizen 6.0)\n
+ *          Input: arg3(amd_request_h) The request handle.\n
  * @since_tizen 5.5
  *
  * @see __prepare_starting_app()
index 140251ce4586794143baff63d7b65f90167d9c77..2885a3f4c0f359b5ddab05e14abb9692be2f5752 100644 (file)
@@ -620,7 +620,7 @@ static int __widget_count(const char *widget_id, uid_t uid)
        return count;
 }
 
-static int __widget_verify_cmd(amd_request_h req)
+static int __widget_verify_cmd(amd_request_h req, int pid, int status)
 {
        bundle *kb = amd_request_get_bundle(req);
        const char *command;
@@ -653,6 +653,13 @@ static int __widget_verify_cmd(amd_request_h req)
        if (strcmp(command, "create") == 0)
                return 0;
 
+       if (status == STATUS_DYING || status == -1) {
+               LOGE("Invalid request(%s). pid(%d), status(%d)",
+                               command, pid, status);
+               error_desc = "invalid status";
+               goto error;
+       }
+
        instance_id = bundle_get_val(kb, AUL_K_WIDGET_INSTANCE_ID);
        if (instance_id == NULL) {
                /*
@@ -1793,9 +1800,11 @@ static int __on_app_status_destroy(const char *msg, int arg1, int arg2,
 static int __on_launching_widget(const char *msg, int arg1, int arg2,
                void *arg3, bundle *data)
 {
+       int pid = arg1;
+       int status = arg2;
        amd_request_h req = arg3;
 
-       if (__widget_verify_cmd(req) < 0)
+       if (__widget_verify_cmd(req, pid, status) < 0)
                return -1;
 
        return 0;