From: Hwankyu Jhun Date: Thu, 16 Apr 2020 01:50:01 +0000 (+0900) Subject: [Frame-Broker] Remove precreated context handle X-Git-Tag: submit/tizen/20200417.051505~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F99%2F230899%2F2;p=platform%2Fcore%2Fappfw%2Fwidget-viewer.git [Frame-Broker] Remove precreated context handle Change-Id: I8831d67fc36434993ad53fd064ab0db4afbdad25 Signed-off-by: Hwankyu Jhun --- diff --git a/frame-broker/src/frame_broker.c b/frame-broker/src/frame_broker.c index d09aa9c1..d1670498 100644 --- a/frame-broker/src/frame_broker.c +++ b/frame-broker/src/frame_broker.c @@ -41,7 +41,6 @@ struct frame_broker_s { aul_launcher_service_h als; screen_connector_launcher_service_h scls; frame_context_h context; - frame_context_h pre_context; }; struct request_s { @@ -105,19 +104,6 @@ static uint32_t __generate_serial(void) return (uint32_t)serial; } -static void __check_pre_context(frame_broker_h broker) -{ - if (broker->context) { - _D("Destroy previous context"); - frame_context_destroy(broker->context); - } - - broker->context = broker->pre_context; - broker->pre_context = NULL; - - frame_context_on_create(broker->context); -} - static void __aul_launcher_service_cb(const char *app_id, const char *inst_id, const int pid, @@ -125,17 +111,13 @@ static void __aul_launcher_service_cb(const char *app_id, void *user_data) { frame_broker_h broker = user_data; + frame_context_h context = broker->context; _D("app_id(%s), inst_id(%s), pid(%d), serial(%u)", app_id, inst_id, pid, serial); - if (!broker->pre_context) { - _W("Previous context is nullptr"); - return; - } - - frame_context_set_inst_id(broker->pre_context, inst_id); - frame_context_set_pid(broker->pre_context, pid); + frame_context_set_inst_id(context, inst_id); + frame_context_set_pid(context, pid); } static void __scls_prepare_cb(screen_connector_launcher_service_image_h image, @@ -144,29 +126,16 @@ static void __scls_prepare_cb(screen_connector_launcher_service_image_h image, { frame_broker_h broker = user_data; frame_context_h context = broker->context; - frame_h frame; + frame_h frame = NULL; int ret; _D("[__SCLS__] Prepare"); - if (context == NULL) { - if (broker->pre_context) { - __check_pre_context(broker); - context = broker->context; - } else { - _E("Invalid context"); - return; - } - } - + frame_context_on_create(context); frame_context_set_serial(context, serial); ret = frame_create(image, &frame); - if (ret != FRAME_BROKER_ERROR_NONE) { + if (ret != FRAME_BROKER_ERROR_NONE) _E("Failed to create frame. error(%d)", ret); - frame_context_on_error(context, - FRAME_CONTEXT_ERROR_WRONG_REQUEST); - return; - } frame_context_on_resume(context, frame); } @@ -178,16 +147,6 @@ static void __scls_stop_cb(uint32_t serial, void *user_data) uint32_t ctx_serial = 0; _D("[__SCLS__] Stop"); - if (context == NULL) { - if (broker->pre_context) { - __check_pre_context(broker); - context = broker->context; - } else { - _E("Invalid context"); - return; - } - } - frame_context_get_serial(context, &ctx_serial); if (ctx_serial != serial) { _W("Skip! serial(%u:%u)", ctx_serial, serial); @@ -220,18 +179,14 @@ static void __scls_error_cb(screen_connector_launcher_service_error_e error, frame_context_h context = broker->context; _D("[__SCLS__] Error"); - if (context == NULL) { - if (broker->pre_context) { - __check_pre_context(broker); - context = broker->context; - } else { - _W("Invoke error callback directly"); - broker->callback.error(NULL, __convert_error(error), - broker->user_data); - return; - } + if (!context) { + _W("Invoke error callback directly"); + broker->callback.error(NULL, __convert_error(error), + broker->user_data); + return; } + frame_context_on_create(context); frame_context_on_error(context, __convert_error(error)); } @@ -382,9 +337,6 @@ API int frame_broker_destroy(frame_broker_h handle) if (handle->context) frame_context_destroy(handle->context); - if (handle->pre_context) - frame_context_destroy(handle->pre_context); - screen_connector_launcher_service_destroy(handle->scls); aul_launcher_service_destroy(handle->als); free(handle->name); @@ -430,6 +382,11 @@ static int __send_request(struct request_s *req) aul_running_context_get_inst_id(context, (const char **)&inst_id); aul_running_context_get_pid(context, &pid); + if (broker->context) { + frame_context_destroy(broker->context); + broker->context = NULL; + } + if (req->shared_widget) { ret = frame_broker_launch_with_shared_widget(broker, app_id, inst_id, pid, &serial); @@ -438,40 +395,22 @@ static int __send_request(struct request_s *req) &serial); } - if (ret == FRAME_BROKER_ERROR_NONE) { - frame_context_destroy(broker->pre_context); - broker->pre_context = NULL; - - frame_context_create(broker, app_id, inst_id, pid, serial, - &broker->callback, broker->user_data, - &broker->pre_context); - } - - aul_running_context_destroy(context); - free(app_id); - if (ret != FRAME_BROKER_ERROR_NONE) { - frame_context_destroy(broker->pre_context); - broker->pre_context = NULL; - return ret; - } + if (ret != FRAME_BROKER_ERROR_NONE) + goto end; snprintf(buf, sizeof(buf), "%u", serial); ret = app_control_add_extra_data(req->app_control, AUL_K_LAUNCHER_SERVICE_SERIAL, buf); if (ret != APP_CONTROL_ERROR_NONE) { _E("Failed to add extra data. error(%d)", ret); - frame_context_destroy(broker->pre_context); - broker->pre_context = NULL; - return ret; + goto end; } ret = app_control_add_extra_data(req->app_control, AUL_K_LAUNCHER_SERVICE, broker->name); if (ret != APP_CONTROL_ERROR_NONE) { _E("Failed to add extra data. error(%d)", ret); - frame_context_destroy(broker->pre_context); - broker->pre_context = NULL; - return ret; + goto end; } if (req->resume_request) { @@ -484,12 +423,20 @@ static int __send_request(struct request_s *req) if (ret != APP_CONTROL_ERROR_NONE) { _E("Failed to send launch request. error(%d)", ret); - frame_context_destroy(broker->pre_context); - broker->pre_context = NULL; - return ret; + goto end; } - return FRAME_BROKER_ERROR_NONE; + ret = frame_context_create(broker, app_id, inst_id, pid, serial, + &broker->callback, broker->user_data, + &broker->context); + if (ret != FRAME_BROKER_ERROR_NONE) + _E("Failed to create frame context handle. error(%d)", ret); + +end: + aul_running_context_destroy(context); + free(app_id); + + return ret; } API int frame_broker_send_launch_request(frame_broker_h handle,