From f7b629713ffae4dd33540c20dc72d54c1a78004b Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 4 Nov 2019 20:12:19 +0900 Subject: [PATCH] Create & use running context If the application is already running, frame-broker creates the running context while sending the launch request. And then, uses it when getting the tzsh launcher service events. Change-Id: I609f445817bd1fe8ed5efb46577b156cb416c9ad Signed-off-by: Hwankyu Jhun --- frame-broker/src/frame_broker.c | 76 +++++++++++++++++++++++++++++--- frame-broker/src/frame_context.c | 12 +++++ frame-broker/src/frame_context_private.h | 2 + 3 files changed, 83 insertions(+), 7 deletions(-) diff --git a/frame-broker/src/frame_broker.c b/frame-broker/src/frame_broker.c index 82b640c..545fb01 100644 --- a/frame-broker/src/frame_broker.c +++ b/frame-broker/src/frame_broker.c @@ -40,6 +40,7 @@ struct frame_broker_s { aul_launcher_service_h als; screen_connector_launcher_service_evas_h scls_evas; frame_context_h context; + frame_context_h pre_context; }; static GList *__win_list; @@ -92,6 +93,19 @@ 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, @@ -100,10 +114,27 @@ static void __aul_launcher_service_cb(const char *app_id, { frame_broker_h broker = user_data; frame_context_h context; + int ctx_pid = -1; + uint32_t ctx_serial = 0; int ret; _D("app_id(%s), inst_id(%s), pid(%d), serial(%u)", app_id, inst_id, pid, serial); + + if (broker->pre_context) { + __check_pre_context(broker); + return; + } + + if (broker->context) { + frame_context_get_pid(broker->context, &ctx_pid); + frame_context_get_serial(broker->context, &ctx_serial); + if (ctx_pid == pid && ctx_serial == serial) { + _D("Frame context already exists"); + return; + } + } + ret = frame_context_create(broker, app_id, inst_id, pid, serial, &broker->callback, broker->user_data, &context); @@ -137,8 +168,12 @@ static void __scls_evas_prepare_cb(Evas_Object *image, _D("[__SCLS_EVAS__] Prepare"); if (context == NULL) { - _E("Invalid context"); - return; + if (broker->pre_context) { + __check_pre_context(broker); + } else { + _E("Invalid context"); + return; + } } frame_context_set_serial(context, serial); @@ -162,8 +197,12 @@ static void __scls_evas_stop_cb(uint32_t serial, void *user_data) _D("[__SCLS_EVAS__] Stop"); if (context == NULL) { - _E("Invalid context"); - return; + if (broker->pre_context) { + __check_pre_context(broker); + } else { + _E("Invalid context"); + return; + } } _D("Destroy context"); @@ -193,8 +232,12 @@ static void __scls_evas_error_cb( _D("[__SCLS_EVAS__] Error"); if (context == NULL) { - _E("Invalid context"); - return; + if (broker->pre_context) { + __check_pre_context(broker); + } else { + _E("Invalid context"); + return; + } } frame_context_on_error(context, __convert_error(error)); @@ -382,16 +425,31 @@ static int __send_launch_request(frame_broker_h handle, ret = frame_broker_launch(handle, app_id, inst_id, pid, &serial); } + + if (inst_id && pid > 0) { + frame_context_destroy(handle->pre_context); + handle->pre_context = NULL; + + frame_context_create(handle, app_id, inst_id, pid, serial, + &handle->callback, handle->user_data, + &handle->pre_context); + } + aul_running_context_destroy(context); free(app_id); - if (ret != FRAME_BROKER_ERROR_NONE) + if (ret != FRAME_BROKER_ERROR_NONE) { + frame_context_destroy(handle->pre_context); + handle->pre_context = NULL; return ret; + } snprintf(buf, sizeof(buf), "%u", serial); ret = app_control_add_extra_data(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(handle->pre_context); + handle->pre_context = NULL; return ret; } @@ -399,6 +457,8 @@ static int __send_launch_request(frame_broker_h handle, AUL_K_LAUNCHER_SERVICE, handle->name); if (ret != APP_CONTROL_ERROR_NONE) { _E("Failed to add extra data. error(%d)", ret); + frame_context_destroy(handle->pre_context); + handle->pre_context = NULL; return ret; } @@ -406,6 +466,8 @@ static int __send_launch_request(frame_broker_h handle, result_cb, reply_cb, user_data); if (ret != APP_CONTROL_ERROR_NONE) { _E("Failed to send launch request. error(%d)", ret); + frame_context_destroy(handle->pre_context); + handle->pre_context = NULL; return ret; } diff --git a/frame-broker/src/frame_context.c b/frame-broker/src/frame_context.c index ba72b84..b7e5c64 100644 --- a/frame-broker/src/frame_context.c +++ b/frame-broker/src/frame_context.c @@ -207,6 +207,18 @@ API int frame_context_finish_animation(frame_context_h handle) return FRAME_BROKER_ERROR_NONE; } +int frame_context_get_pid(frame_context_h handle, int *pid) +{ + if (!handle || !pid) { + _E("Invalid parameter"); + return FRAME_BROKER_ERROR_INVALID_PARAMETER; + } + + *pid = handle->pid; + + return FRAME_BROKER_ERROR_NONE; +} + int frame_context_set_serial(frame_context_h handle, uint32_t serial) { if (!handle) { diff --git a/frame-broker/src/frame_context_private.h b/frame-broker/src/frame_context_private.h index e4e6aef..66c964e 100644 --- a/frame-broker/src/frame_context_private.h +++ b/frame-broker/src/frame_context_private.h @@ -41,6 +41,8 @@ int frame_context_create(frame_broker_h broker, int frame_context_destroy(frame_context_h handle); +int frame_context_get_pid(frame_context_h handle, int *pid); + int frame_context_set_serial(frame_context_h handle, uint32_t serial); int frame_context_get_serial(frame_context_h handle, uint32_t *serial); -- 2.7.4