summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2017-01-13 12:50:26 +0900
committerHwankyu Jhun <h.jhun@samsung.com>2017-01-13 13:38:38 +0900
commit98611a8be02f7efe394abf0ddc24349d1c81a427 (patch)
treea076c6afde45af8c99b2db221bbd6c6ede6c43fc
parent50ff945bad0cfbdd32e89af5da66c5eeccddcc9b (diff)
downloadapp-manager-98611a8be02f7efe394abf0ddc24349d1c81a427.tar.gz
app-manager-98611a8be02f7efe394abf0ddc24349d1c81a427.tar.bz2
app-manager-98611a8be02f7efe394abf0ddc24349d1c81a427.zip
Support multiple instance launch
- Adds a new API to get the app context handle by using instance ID - Requires: [aul] https://review.tizen.org/gerrit/#/c/108620/ [amd] https://review.tizen.org/gerrit/#/c/109746/ [rua] https://review.tizen.org/gerrit/#/c/109906/ [application] https://review.tizen.org/gerrit/#/c/108805/ Change-Id: I1e778636f4abba4759b3b419066374a25d8e8b70 Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--include/app_manager_extension.h17
-rw-r--r--src/app_context.c48
-rw-r--r--src/app_manager.c10
-rw-r--r--src/app_manager_internal.h2
4 files changed, 75 insertions, 2 deletions
diff --git a/include/app_manager_extension.h b/include/app_manager_extension.h
index f66c814..671ef18 100644
--- a/include/app_manager_extension.h
+++ b/include/app_manager_extension.h
@@ -104,6 +104,23 @@ int app_manager_set_splash_screen_display(const char *app_id, bool display);
int app_manager_set_app_context_status_cb(app_manager_app_context_status_cb callback, const char *appid, void *user_data);
/**
+ * @brief Gets the application context for the given IDs of the application.
+ * @since_tizen 3.0
+ * @remarks This function returns #APP_MANAGER_ERROR_NO_SUCH_APP if the application with the given application IDs is not running. \n
+ * You must release @a app_context using app_context_destroy().
+ * @param[in] app_id The ID of the application
+ * @param[in] instance_id The Instance ID of the application
+ * @param[out] app_context The application context of the given application IDs
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #APP_MANAGER_ERROR_NONE Successful
+ * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application
+ */
+int app_manager_get_app_context_by_instance_id(const char *app_id, const char *instance_id, app_context_h *app_context);
+
+/**
* @}
*/
diff --git a/src/app_context.c b/src/app_context.c
index 04d06c8..7014c47 100644
--- a/src/app_context.c
+++ b/src/app_context.c
@@ -62,6 +62,7 @@ typedef struct _retrieval_context_ {
app_state_e app_state;
bool is_sub_app;
bool matched;
+ const char *instance_id;
} retrieval_context_s;
static app_manager_app_context_status_cb _status_cb;
@@ -198,7 +199,19 @@ static int app_context_retrieve_app_context(const aul_app_info *aul_app_context,
app_state_e app_state;
if (aul_app_context != NULL && retrieval_context != NULL && retrieval_context->matched == false) {
- if (!strcmp(aul_app_context->appid, retrieval_context->app_id)) {
+ if (retrieval_context->instance_id &&
+ !strcmp(aul_app_context->instance_id, retrieval_context->instance_id) &&
+ !strcmp(aul_app_context->appid, retrieval_context->app_id)) {
+ app_state = app_context_get_app_status(aul_app_context->status);
+
+ retrieval_context->pid = aul_app_context->pid;
+ retrieval_context->pkg_id = strdup(aul_app_context->pkgid);
+ retrieval_context->app_state = app_state;
+ if (aul_app_context->is_sub_app)
+ retrieval_context->is_sub_app = true;
+ retrieval_context->matched = true;
+ } else if (retrieval_context->instance_id == NULL &&
+ !strcmp(aul_app_context->appid, retrieval_context->app_id)) {
app_state = app_context_get_app_status(aul_app_context->status);
retrieval_context->pid = aul_app_context->pid;
@@ -222,7 +235,8 @@ int app_context_get_app_context(const char *app_id, app_context_h *app_context)
.pkg_id = NULL,
.app_state = APP_STATE_UNDEFINED,
.is_sub_app = false,
- .matched = false
+ .matched = false,
+ .instance_id = NULL
};
if (app_id == NULL || app_context == NULL)
@@ -634,3 +648,33 @@ int app_context_set_status_cb(app_manager_app_context_status_cb callback, const
return ret;
}
+int app_context_get_app_context_by_instance_id(const char *app_id, const char *instance_id, app_context_h *app_context)
+{
+ int ret;
+ retrieval_context_s retrieval_context = {
+ .app_id = app_id,
+ .pid = 0,
+ .pkg_id = NULL,
+ .app_state = APP_STATE_UNDEFINED,
+ .is_sub_app = false,
+ .matched = false,
+ .instance_id = instance_id
+ };
+
+ if (app_id == NULL || instance_id == NULL || app_context == NULL)
+ return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+
+ aul_app_get_running_app_instance_info(app_context_retrieve_app_context, &retrieval_context);
+ if (retrieval_context.matched == false)
+ return app_manager_error(APP_MANAGER_ERROR_NO_SUCH_APP, __FUNCTION__, NULL);
+
+ ret = app_context_create(retrieval_context.app_id,
+ retrieval_context.pid,
+ retrieval_context.pkg_id,
+ retrieval_context.app_state,
+ retrieval_context.is_sub_app,
+ app_context);
+ free(retrieval_context.pkg_id);
+
+ return ret;
+}
diff --git a/src/app_manager.c b/src/app_manager.c
index 0c0a60d..f6fc27f 100644
--- a/src/app_manager.c
+++ b/src/app_manager.c
@@ -551,3 +551,13 @@ API int app_manager_set_app_context_status_cb(app_manager_app_context_status_cb
return APP_MANAGER_ERROR_NONE;
}
+API int app_manager_get_app_context_by_instance_id(const char *app_id, const char *instance_id, app_context_h *app_context)
+{
+ int ret;
+
+ ret = app_context_get_app_context_by_instance_id(app_id, instance_id, app_context);
+ if (ret != APP_MANAGER_ERROR_NONE)
+ return app_manager_error(ret, __FUNCTION__, NULL);
+
+ return APP_MANAGER_ERROR_NONE;
+}
diff --git a/src/app_manager_internal.h b/src/app_manager_internal.h
index 5dc4fe6..d6192f7 100644
--- a/src/app_manager_internal.h
+++ b/src/app_manager_internal.h
@@ -56,6 +56,8 @@ int app_info_foreach_app_info(app_manager_app_info_cb callback, void *user_data)
int app_info_get_app_info(const char *app_id, app_info_h *app_info);
+int app_context_get_app_context_by_instance_id(const char *app_id, const char *instance_id, app_context_h *app_context);
+
/**
* @}
*/