#define APPID_MAX 128
-static int app_context_create(const char *app_id, pid_t pid, const char *pkg_id, app_state_e app_state, bool is_sub_app, app_context_h *app_context);
+static int app_context_create(const char *app_id, pid_t pid, const char *pkg_id, app_state_e app_state, bool is_sub_app, const char *instance_id, app_context_h *app_context);
struct app_context_s {
char *app_id;
char *pkg_id;
app_state_e app_state;
bool is_sub_app;
+ char *instance_id;
};
typedef struct _foreach_context_ {
aul_app_context->pkgid,
app_state,
is_sub_app,
+ aul_app_context->instance_id,
&app_context) == APP_MANAGER_ERROR_NONE) {
foreach_context->iteration = foreach_context->callback(app_context, foreach_context->user_data);
app_context_destroy(app_context);
aul_app_context->pkgid,
app_state,
is_sub_app,
+ aul_app_context->instance_id,
&app_context) == APP_MANAGER_ERROR_NONE) {
foreach_context->iteration = foreach_context->callback(app_context, foreach_context->user_data);
app_context_destroy(app_context);
retrieval_context.pkg_id,
retrieval_context.app_state,
retrieval_context.is_sub_app,
- app_context);
+ retrieval_context.instance_id,
+ app_context);
free(retrieval_context.pkg_id);
return ret;
}
-static int app_context_create(const char *app_id, pid_t pid, const char *pkg_id, app_state_e app_state, bool is_sub_app, app_context_h *app_context)
+static int app_context_create(const char *app_id, pid_t pid, const char *pkg_id, app_state_e app_state, bool is_sub_app, const char *instance_id, app_context_h *app_context)
{
app_context_h app_context_created;
return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
}
+ if (instance_id) {
+ app_context_created->instance_id = strdup(instance_id);
+ if (app_context_created->instance_id == NULL) {
+ free(app_context_created->pkg_id);
+ free(app_context_created->app_id);
+ free(app_context_created);
+ return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+ }
+ }
+
app_context_created->pid = pid;
app_context_created->app_state = app_state;
app_context_created->is_sub_app = is_sub_app;
free(app_context->app_id);
free(app_context->pkg_id);
+ free(app_context->instance_id);
free(app_context);
return APP_MANAGER_ERROR_NONE;
app_context->pkg_id,
app_context->app_state,
app_context->is_sub_app,
+ app_context->instance_id,
clone);
if (retval != APP_MANAGER_ERROR_NONE)
return app_manager_error(retval, __FUNCTION__, NULL);
app_context_lock_event_cb_context();
- if (app_context_create(app_id, pid, pkg_id, APP_STATE_UNDEFINED, false, &app_context) == APP_MANAGER_ERROR_NONE) {
+ if (app_context_create(app_id, pid, pkg_id, APP_STATE_UNDEFINED, false, NULL, &app_context) == APP_MANAGER_ERROR_NONE) {
if (event_cb_context != NULL && event_cb_context->pid_table != NULL) {
g_hash_table_insert(event_cb_context->pid_table, GINT_TO_POINTER(&(app_context->pid)), app_context);
event_cb_context->callback(app_context, APP_CONTEXT_EVENT_LAUNCHED, event_cb_context->user_data);
else
context_status = APP_CONTEXT_STATUS_LAUNCHED;
- ret = app_context_create(appid, pid, pkgid, state, is_subapp, &app_context);
+ ret = app_context_create(appid, pid, pkgid, state, is_subapp, NULL, &app_context);
if (ret != APP_MANAGER_ERROR_NONE)
return app_manager_error(ret, __FUNCTION__, NULL);
retrieval_context.pkg_id,
retrieval_context.app_state,
retrieval_context.is_sub_app,
+ retrieval_context.instance_id,
app_context);
free(retrieval_context.pkg_id);
return ret;
}
+
+int app_context_get_instance_id(app_context_h app_context, char **instance_id)
+{
+ if (app_context == NULL || app_context->instance_id == NULL || instance_id == NULL)
+ return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+
+ *instance_id = strdup(app_context->instance_id);
+ if (*instance_id == NULL)
+ return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+
+ return APP_MANAGER_ERROR_NONE;
+}
API int app_manager_resume_app(app_context_h app_context)
{
- char *app_id;
+ char *app_id = NULL;
+ char *instance_id = NULL;
int retval = APP_MANAGER_ERROR_NONE;
if (app_context == NULL)
if (app_context_get_app_id(app_context, &app_id) != APP_MANAGER_ERROR_NONE)
return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, "failed to get the application ID");
- if (aul_app_is_running(app_id) == 0) {
- if (app_id) {
- free(app_id);
- app_id = NULL;
+ app_context_get_instance_id(app_context, &instance_id);
+ if (instance_id) {
+ retval = aul_resume_app_by_instance_id(app_id, instance_id);
+ free(instance_id);
+ } else {
+ if (aul_app_is_running(app_id) == 0) {
+ if (app_id) {
+ free(app_id);
+ app_id = NULL;
+ }
+ return app_manager_error(APP_MANAGER_ERROR_APP_NO_RUNNING, __FUNCTION__, NULL);
}
- return app_manager_error(APP_MANAGER_ERROR_APP_NO_RUNNING, __FUNCTION__, NULL);
- }
- retval = aul_resume_app(app_id);
+ retval = aul_resume_app(app_id);
+ }
if (app_id)
free(app_id);