aul_launcher_service_h als;
screen_connector_launcher_service_h scls;
frame_context_h context;
- frame_context_h pre_context;
};
struct request_s {
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,
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,
{
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);
}
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);
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));
}
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);
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);
&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) {
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,