From 5f284d7b029b57035b9bcc651dd6245fefe3ccdb Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 12 Feb 2020 10:02:43 +0900 Subject: [PATCH] Add a new function for sending resumption request Adds: - frame_broker_send_resume_request() Requires: - https://review.tizen.org/gerrit/#/c/platform/core/appfw/aul-1/+/224527/ - https://review.tizen.org/gerrit/#/c/platform/core/appfw/amd/+/224529/ - https://review.tizen.org/gerrit/#/c/platform/core/api/app-control/+/224549/ - https://review.tizen.org/gerrit/#/c/platform/core/appfw/widget-viewer/+/224590/ Change-Id: I6c3bf5db05661adb68b5c1b6e0ec29d4cd7bffdd Signed-off-by: Hwankyu Jhun --- frame-broker/include/frame_broker_extension.h | 28 ++++++ frame-broker/src/frame_broker.c | 120 ++++++++++++++++++-------- 2 files changed, 112 insertions(+), 36 deletions(-) diff --git a/frame-broker/include/frame_broker_extension.h b/frame-broker/include/frame_broker_extension.h index 538201c..1e774a4 100644 --- a/frame-broker/include/frame_broker_extension.h +++ b/frame-broker/include/frame_broker_extension.h @@ -88,6 +88,34 @@ int frame_broker_add_event_handler(const char *app_id, frame_broker_event_cb cal */ int frame_broker_remove_event_handler(frame_broker_event_h handle); +/** + * @brief Sends the resume request asynchronously. + * @since_tizen 5.5 + * + * @privlevel public + * @privilege %http://tizen.org/privilege/appmanager.launch + * + * @param[in] handle The frame broker handle + * @param[in] app_control The app_control handle + * @param[in] result_cb The callback function to be called when the result is delivered + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #FRAME_BROKER_ERROR_NONE Successful + * @retval #FRAME_BROKER_ERROR_APP_NOT_FOUND The application to run the given launch request is not found + * @retval #FRAME_BROKER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #FRAME_BROKER_ERROR_IO_ERROR I/O error + * @retval #FRAME_BROKER_ERROR_LAUNCH_REJECTED Failed to launch the application + * @retval #FRAME_BROKER_ERROR_PERMISSION_DENIED Permission denied + * + * @see app_control_result_cb() + */ +int frame_broker_send_resume_request(frame_broker_h handle, + app_control_h app_control, + app_control_result_cb result_cb, + void *user_data); + #ifdef __cplusplus } #endif diff --git a/frame-broker/src/frame_broker.c b/frame-broker/src/frame_broker.c index 12b0de6..82022b9 100644 --- a/frame-broker/src/frame_broker.c +++ b/frame-broker/src/frame_broker.c @@ -44,6 +44,16 @@ struct frame_broker_s { frame_context_h pre_context; }; +struct request_s { + frame_broker_h broker; + app_control_h app_control; + app_control_result_cb result_cb; + app_control_reply_cb reply_cb; + void *user_data; + bool shared_widget; + bool resume_request; +}; + static GList *__win_list; static gint __compare_win(gconstpointer a, gconstpointer b) @@ -381,13 +391,9 @@ API int frame_broker_destroy(frame_broker_h handle) return FRAME_BROKER_ERROR_NONE; } -static int __send_launch_request(frame_broker_h handle, - app_control_h app_control, - app_control_result_cb result_cb, - app_control_reply_cb reply_cb, - void *user_data, - bool shared_widget) +static int __send_request(struct request_s *req) { + frame_broker_h broker = req->broker; aul_running_context_h context = NULL; char buf[12]; uint32_t serial; @@ -397,19 +403,19 @@ static int __send_launch_request(frame_broker_h handle, int pid = -1; int ret; - if (!handle || !app_control || !result_cb) { + if (!req->broker || !req->app_control || !req->result_cb) { _E("Invalid parameter"); return FRAME_BROKER_ERROR_INVALID_PARAMETER; } - ret = app_control_get_app_id(app_control, &app_id); + ret = app_control_get_app_id(req->app_control, &app_id); if (ret != APP_CONTROL_ERROR_NONE) { _E("Failed to get app id. error(%d)", ret); return ret; } - app_control_get_component_id(app_control, &comp_id); - app_control_get_instance_id(app_control, &inst_id); + app_control_get_component_id(req->app_control, &comp_id); + app_control_get_instance_id(req->app_control, &inst_id); ret = aul_running_context_create(app_id, comp_id, inst_id, &context); if (ret != AUL_R_OK) @@ -422,56 +428,62 @@ static int __send_launch_request(frame_broker_h handle, aul_running_context_get_inst_id(context, (const char **)&inst_id); aul_running_context_get_pid(context, &pid); - if (shared_widget) { - ret = frame_broker_launch_with_shared_widget(handle, app_id, - inst_id, pid, &serial); + if (req->shared_widget) { + ret = frame_broker_launch_with_shared_widget(broker, + app_id, inst_id, pid, &serial); } else { - ret = frame_broker_launch(handle, app_id, inst_id, pid, + ret = frame_broker_launch(broker, app_id, inst_id, pid, &serial); } if (inst_id && pid > 0) { - frame_context_destroy(handle->pre_context); - handle->pre_context = NULL; + frame_context_destroy(broker->pre_context); + broker->pre_context = NULL; - frame_context_create(handle, app_id, inst_id, pid, serial, - &handle->callback, handle->user_data, - &handle->pre_context); + 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(handle->pre_context); - handle->pre_context = NULL; + frame_context_destroy(broker->pre_context); + broker->pre_context = NULL; return ret; } snprintf(buf, sizeof(buf), "%u", serial); - ret = app_control_add_extra_data(app_control, + 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(handle->pre_context); - handle->pre_context = NULL; + frame_context_destroy(broker->pre_context); + broker->pre_context = NULL; return ret; } - ret = app_control_add_extra_data(app_control, - AUL_K_LAUNCHER_SERVICE, handle->name); + 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(handle->pre_context); - handle->pre_context = NULL; + frame_context_destroy(broker->pre_context); + broker->pre_context = NULL; return ret; } - ret = app_control_send_launch_request_async(app_control, - result_cb, reply_cb, user_data); + if (req->resume_request) { + ret = app_control_send_resume_request(req->app_control, + req->result_cb, req->user_data); + } else { + ret = app_control_send_launch_request_async(req->app_control, + req->result_cb, req->reply_cb, req->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; + frame_context_destroy(broker->pre_context); + broker->pre_context = NULL; return ret; } @@ -484,8 +496,17 @@ API int frame_broker_send_launch_request(frame_broker_h handle, app_control_reply_cb reply_cb, void *user_data) { - return __send_launch_request(handle, app_control, result_cb, reply_cb, - user_data, false); + struct request_s req = { + .broker = handle, + .app_control = app_control, + .result_cb = result_cb, + .reply_cb = reply_cb, + .user_data = user_data, + .shared_widget = false, + .resume_request = false + }; + + return __send_request(&req); } API int frame_broker_send_launch_request_to_provider( @@ -495,8 +516,35 @@ API int frame_broker_send_launch_request_to_provider( app_control_reply_cb reply_cb, void *user_data) { - return __send_launch_request(handle, app_control, result_cb, reply_cb, - user_data, true); + struct request_s req = { + .broker = handle, + .app_control = app_control, + .result_cb = result_cb, + .reply_cb = reply_cb, + .user_data = user_data, + .shared_widget = true, + .resume_request = false + }; + + return __send_request(&req); +} + +API int frame_broker_send_resume_request(frame_broker_h handle, + app_control_h app_control, + app_control_result_cb result_cb, + void *user_data) +{ + struct request_s req = { + .broker = handle, + .app_control = app_control, + .result_cb = result_cb, + .reply_cb = NULL, + .user_data = user_data, + .shared_widget = false, + .resume_request = true + }; + + return __send_request(&req); } void frame_broker_set_frame_context(frame_broker_h handle, -- 2.7.4