Support instance termination 08/206708/1
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 23 May 2019 10:21:02 +0000 (19:21 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 23 May 2019 10:23:05 +0000 (19:23 +0900)
From Tizen 5.5, the component-based application is supported.
To terminate each running instance, app_control_send_terminate_request()
is modified. It calls aul_svc_subapp_terminate_request() instead of
aul_svc_subapp_terminate_request_pid().

Change-Id: I9ecdb8263990320bb51b28ebe54c07517f01045c
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/app_control.c

index a3f2c2e960b677716a5ea5f69e7aae2c58ce966b..b899a4f958cde5de79cfb43b68b9de4fb362a23e 100644 (file)
@@ -942,7 +942,6 @@ static void __handle_launch_result(int launched_pid, void *data)
        app_control_reply_cb reply_cb;
        void *user_data;
        char callee[255] = {0, };
-       char instance_id[256] = {0,};
        int ret;
 
        if (data == NULL)
@@ -958,17 +957,11 @@ static void __handle_launch_result(int launched_pid, void *data)
        ret = aul_app_get_appid_bypid(launched_pid, callee, sizeof(callee));
        if (ret < 0)
                LOGE("aul_app_get_appid_bypid failed: %d", launched_pid);
+       else
+               app_control_set_app_id(reply, callee);
 
-       app_control_set_app_id(reply, callee);
        LOGI("app control async result callback callee pid:%d", launched_pid);
 
-       ret = aul_app_get_instance_id_bypid(launched_pid, instance_id,
-                       sizeof(instance_id));
-       if (ret == AUL_R_OK) {
-               app_control_set_instance_id(reply, instance_id);
-               LOGI("instance id(%s)", instance_id);
-       }
-
        result = APP_CONTROL_RESULT_APP_STARTED;
        request = request_context->app_control;
        user_data = request_context->user_data;
@@ -1164,11 +1157,34 @@ static int __launch_request_send(struct launch_request_s *req)
        return APP_CONTROL_ERROR_NONE;
 }
 
+static void __copy_callee_info(app_control_h dst, app_control_h src)
+{
+       const char *id;
+
+       if (!dst || !src)
+               return;
+
+       id = bundle_get_val(src->data, AUL_K_APPID);
+       if (id) {
+               bundle_del(dst->data, AUL_K_APPID);
+               bundle_add(dst->data, AUL_K_APPID, id);
+       }
+
+       id = bundle_get_val(src->data, AUL_K_INSTANCE_ID);
+       if (id) {
+               bundle_del(dst->data, AUL_K_INSTANCE_ID);
+               bundle_add(dst->data, AUL_K_INSTANCE_ID, id);
+       }
+}
+
 static int __launch_request_complete(struct launch_request_s *req)
 {
        app_control_h app_control = req->app_control;
        app_control_request_context_h request_context = req->request_context;
 
+       if (request_context)
+               __copy_callee_info(request_context->app_control, app_control);
+
        if (req->result_cb)
                return APP_CONTROL_ERROR_NONE;
 
@@ -1246,7 +1262,8 @@ int app_control_send_terminate_request(app_control_h app_control)
        if (app_control->type != APP_CONTROL_TYPE_REQUEST || app_control->launch_pid < 0)
                return app_control_error(APP_CONTROL_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
 
-       aul_svc_subapp_terminate_request_pid(app_control->launch_pid);
+       aul_svc_subapp_terminate_request(app_control->data,
+                       app_control->launch_pid);
 
        return APP_CONTROL_ERROR_NONE;
 }