From 5fcd501b0d36ec45ef6ca7f178ae158f9ff0f2ff Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 15 Feb 2017 08:37:24 +0900 Subject: [PATCH] Fix launching apps If the application is running, the task-manager should send the resume request to the running application. Requires: - https://review.tizen.org/gerrit/#/c/114723/ - https://review.tizen.org/gerrit/#/c/114725/ Change-Id: I07a076cf268deee1086418fa581e59ae16c6987e Signed-off-by: Hwankyu Jhun --- inc/util.h | 4 +++- src/item.c | 2 +- src/util.c | 20 +++++++++++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/inc/util.h b/inc/util.h index d30ec5b..b9ead16 100644 --- a/inc/util.h +++ b/inc/util.h @@ -78,11 +78,13 @@ extern Eina_Bool util_kill_app(const char *appid, const char *instance_id); * @brief Resumes the given application. * * @param[in] appid The ID of the application + * @param[in] instance_id The instance ID of the application * @param[in] uri The URI of the data * * @return EINA_TRUE or EINA_FALSE on failure */ -extern Eina_Bool util_launch_app(const char *appid, const char *uri); +extern Eina_Bool util_launch_app(const char *appid, const char *instance_id, + const char *uri); /** * @brief Returns absolute path to resource file located in applications directory diff --git a/src/item.c b/src/item.c index 597c345..a450099 100644 --- a/src/item.c +++ b/src/item.c @@ -590,7 +590,7 @@ static void _clicked_cb(void *data, Evas_Object *obj, void *event_info) appid = info->appid; ret_if(!appid); - util_launch_app(appid, info->uri); + util_launch_app(appid, info->instance_id, info->uri); /* layout_hide_with_timer(); */ } diff --git a/src/util.c b/src/util.c index 609f80f..21add37 100644 --- a/src/util.c +++ b/src/util.c @@ -53,16 +53,34 @@ Eina_Bool util_kill_app(const char *appid, const char *instance_id) return ret; } -Eina_Bool util_launch_app(const char *appid, const char *uri) +Eina_Bool util_launch_app(const char *appid, const char *instance_id, + const char *uri) { int ret; app_control_h service = NULL; + app_context_h context = NULL; if (!appid || strlen(appid) == 0) { _E("Fail to launch, due to Null appid."); return EINA_FALSE; } + if (instance_id) + app_manager_get_app_context_by_instance_id(appid, instance_id, &context); + else + app_manager_get_app_context(appid, &context); + + if (context) { + _D("Application(%s) is running. Resuming...", appid); + ret = app_manager_resume_app(context); + app_context_destroy(context); + if (ret == APP_MANAGER_ERROR_NONE) + return EINA_TRUE; + else + _E("Failed to resume application(%s)", appid); + } + + _D("Application(%s) is not running. Launching...", appid); ret = app_control_create(&service); if (ret != APP_CONTROL_ERROR_NONE) { _E("Failed to create app_control handle"); -- 2.7.4