diff options
author | Hwankyu Jhun <h.jhun@samsung.com> | 2015-12-15 16:04:45 +0900 |
---|---|---|
committer | Hwankyu Jhun <h.jhun@samsung.com> | 2015-12-15 16:43:54 +0900 |
commit | 8a0850e2b006f30b086289c23eb484610509b76a (patch) | |
tree | 5f95362326847f90da804daf3678b5718ce4f675 | |
parent | f49a588b4579c887770c0e2dad9bcd16d8e3c79f (diff) | |
download | aul-1-8a0850e2b006f30b086289c23eb484610509b76a.tar.gz aul-1-8a0850e2b006f30b086289c23eb484610509b76a.tar.bz2 aul-1-8a0850e2b006f30b086289c23eb484610509b76a.zip |
Apply coding rulesubmit/tizen/20151215.075536
Change-Id: I5b8da34229519e331f43ea6bf94a2323fb54fd9f
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r-- | am_daemon/amd_app_group.c | 503 | ||||
-rw-r--r-- | am_daemon/amd_appinfo.c | 8 | ||||
-rw-r--r-- | am_daemon/amd_launch.c | 57 | ||||
-rw-r--r-- | am_daemon/amd_request.c | 2 | ||||
-rw-r--r-- | am_daemon/amd_status.c | 8 | ||||
-rwxr-xr-x | src/aul_rsc_mgr.c | 279 | ||||
-rw-r--r-- | src/launch.c | 167 | ||||
-rw-r--r-- | src/launch_glib.c | 8 | ||||
-rw-r--r-- | src/launch_with_result.c | 33 | ||||
-rw-r--r-- | src/mime.c | 6 | ||||
-rw-r--r-- | src/pkginfo.c | 3 | ||||
-rwxr-xr-x | src/service.c | 2 | ||||
-rw-r--r-- | src/status.c | 7 | ||||
-rw-r--r-- | test/open_app.c | 14 | ||||
-rw-r--r-- | tool/app_group_info.c | 23 |
15 files changed, 558 insertions, 562 deletions
diff --git a/am_daemon/amd_app_group.c b/am_daemon/amd_app_group.c index 6ae08117..9025e71c 100644 --- a/am_daemon/amd_app_group.c +++ b/am_daemon/amd_app_group.c @@ -110,7 +110,7 @@ static void __attach_window(int parent_wid, int child_wid) wl_registry_destroy(reg); wl_display_disconnect(dpy); #else - //ecore_x_icccm_transient_for_set(child_wid, parent_wid); + /* ecore_x_icccm_transient_for_set(child_wid, parent_wid); */ #endif } @@ -139,13 +139,13 @@ static void __detach_window(int child_wid) wl_registry_destroy(reg); wl_display_disconnect(dpy); #else - //ecore_x_icccm_transient_for_unset(child_wid); + /* ecore_x_icccm_transient_for_unset(child_wid); */ #endif } static gint __comp_pid(gconstpointer a, gconstpointer b) { - app_group_context_t *ac1 = (app_group_context_t*) a; + app_group_context_t *ac1 = (app_group_context_t *)a; return ac1->pid - GPOINTER_TO_INT(b); } @@ -159,13 +159,13 @@ static gboolean __hash_table_cb(gpointer key, gpointer value, gpointer user_data) { int pid = GPOINTER_TO_INT(user_data); - GList *list = (GList*) value; + GList *list = (GList *)value; GList *itr = g_list_first(list); + app_group_context_t *ac; while (itr != NULL) { - app_group_context_t *ac = (app_group_context_t*) itr->data; - - if (ac->pid == pid) { + ac = (app_group_context_t *)itr->data; + if (ac && ac->pid == pid) { free(ac); list = g_list_remove_link(list, itr); if (g_list_length(list) == 0) { @@ -186,15 +186,14 @@ static GList* __find_removable_apps(int from) int *pids = NULL; GList *list = NULL; gboolean found = FALSE; + int i; + int j; + int *gpids = NULL; + int gcnt; app_group_get_leader_pids(&cnt, &pids); - int i, j; - for (i = 0; i < cnt; i++) { - int *gpids = NULL; - int gcnt; - app_group_get_group_pids(pids[i], &gcnt, &gpids); for (j = 0; j < gcnt; j++) { if (gpids[j] == from) { @@ -202,9 +201,8 @@ static GList* __find_removable_apps(int from) continue; } - if (found) { + if (found) list = g_list_append(list, GINT_TO_POINTER(gpids[j])); - } } if (gpids != NULL) @@ -239,26 +237,26 @@ static void __set_fg_flag(int cpid, int flag, gboolean force) { int lpid = app_group_get_leader_pid(cpid); GHashTableIter iter; - gpointer key, value; + gpointer key; + gpointer value; + const char *appid = NULL; + const char *pkgid = NULL; + const struct appinfo *ai = NULL; + GList *list; + GList *i; + app_group_context_t *ac; /* BG management int bg_category = 0x00; */ g_hash_table_iter_init(&iter, app_group_hash); while (g_hash_table_iter_next(&iter, &key, &value)) { - GList *list = (GList*) value; - GList *i = g_list_first(list); - app_group_context_t *ac = (app_group_context_t*) i->data; - - if (ac->pid == lpid) { - + list = (GList *)value; + i = g_list_first(list); + ac = (app_group_context_t *)i->data; + if (ac && ac->pid == lpid) { while (i != NULL) { ac = (app_group_context_t*) i->data; - - if (ac->fg != flag || force == TRUE) { - const char *appid = NULL; - const char *pkgid = NULL; - const struct appinfo *ai = NULL; - + if ((ac && ac->fg != flag) || force == TRUE) { appid = _status_app_get_appid_bypid(ac->pid); ai = appinfo_find(getuid(), appid); pkgid = appinfo_get_value(ai, AIT_PKGID); @@ -300,19 +298,21 @@ static gboolean __is_visible(int cpid) { int lpid = app_group_get_leader_pid(cpid); GHashTableIter iter; - gpointer key, value; + gpointer key; + gpointer value; + GList *list; + GList *i; + app_group_context_t *ac; g_hash_table_iter_init(&iter, app_group_hash); while (g_hash_table_iter_next(&iter, &key, &value)) { - GList *list = (GList*) value; - GList *i = g_list_first(list); - app_group_context_t *ac = (app_group_context_t*) i->data; - - if (ac->pid == lpid) { + list = (GList *)value; + i = g_list_first(list); + ac = (app_group_context_t *)i->data; + if (ac && ac->pid == lpid) { while (i != NULL) { ac = (app_group_context_t*) i->data; - - if (ac->status == STATUS_VISIBLE) + if (ac && ac->status == STATUS_VISIBLE) return TRUE; i = g_list_next(i); @@ -345,21 +345,18 @@ static gboolean __can_attach_window(bundle *b, const char *appid, app_group_laun *launch_mode = APP_GROUP_LAUNCH_MODE_SINGLETON; switch (*launch_mode) { - case APP_GROUP_LAUNCH_MODE_CALLER: - case APP_GROUP_LAUNCH_MODE_SINGLETON: - _D("launch mode from db is caller or singleton"); - - bundle_get_str(b, APP_SVC_K_LAUNCH_MODE, &str); - if (str != NULL && strncmp(str, "group", 5) == 0) { - return TRUE; - } - break; + case APP_GROUP_LAUNCH_MODE_CALLER: + case APP_GROUP_LAUNCH_MODE_SINGLETON: + _D("launch mode from db is caller or singleton"); - case APP_GROUP_LAUNCH_MODE_GROUP: + bundle_get_str(b, APP_SVC_K_LAUNCH_MODE, &str); + if (str != NULL && strncmp(str, "group", 5) == 0) return TRUE; - - case APP_GROUP_LAUNCH_MODE_SINGLE: - return FALSE; + break; + case APP_GROUP_LAUNCH_MODE_GROUP: + return TRUE; + case APP_GROUP_LAUNCH_MODE_SINGLE: + return FALSE; } return FALSE; @@ -379,21 +376,24 @@ static gboolean __can_be_leader(bundle *b) static int __get_previous_pid(int pid) { + int previous_pid = -1; GHashTableIter iter; - gpointer key, value; + gpointer key; + gpointer value; + GList *list; + GList *i; + app_group_context_t *ac; g_hash_table_iter_init(&iter, app_group_hash); while (g_hash_table_iter_next(&iter, &key, &value)) { - GList *list = (GList*) value; - GList *i = g_list_first(list); + list = (GList *)value; + i = g_list_first(list); - int previous_pid = -1; while (i != NULL) { - app_group_context_t *ac = (app_group_context_t*) i->data; - - if (ac->pid == pid) { + ac = (app_group_context_t*)i->data; + if (ac && ac->pid == pid) return previous_pid; - } + previous_pid = ac->pid; i = g_list_next(i); } @@ -408,7 +408,7 @@ static int __get_caller_pid(bundle *kb) int pid; pid_str = bundle_get_val(kb, AUL_K_ORG_CALLER_PID); - if(pid_str) + if (pid_str) goto end; pid_str = bundle_get_val(kb, AUL_K_CALLER_PID); @@ -426,11 +426,11 @@ end: static app_group_context_t* __detach_context_from_recycle_bin(int pid) { GList *iter = recycle_bin; + app_group_context_t *ac; while (iter) { - app_group_context_t *ac = (app_group_context_t*) iter->data; - - if (ac->pid == pid) { + ac = (app_group_context_t *)iter->data; + if (ac && ac->pid == pid) { recycle_bin = g_list_remove_link(recycle_bin, iter); return ac; } @@ -446,10 +446,10 @@ static void __group_add(int leader_pid, int pid, int wid, app_group_launch_mode int caller_pid, int can_shift, int recycle) { app_group_context_t *ac = NULL; + GList *list; if ((ac = __detach_context_from_recycle_bin(pid)) == NULL) { ac = malloc(sizeof(app_group_context_t)); - if (ac == NULL) { _E("out of memory"); return; @@ -472,7 +472,7 @@ static void __group_add(int leader_pid, int pid, int wid, app_group_launch_mode dead_pid = -1; - GList *list = (GList*) g_hash_table_lookup(app_group_hash, + list = (GList *)g_hash_table_lookup(app_group_hash, GINT_TO_POINTER(leader_pid)); if (list != NULL) { if (g_list_find_custom(list, GINT_TO_POINTER(pid), __comp_pid) != NULL) { @@ -492,30 +492,32 @@ static void __group_add(int leader_pid, int pid, int wid, app_group_launch_mode static void __group_remove(int pid) { int ppid = __get_previous_pid(pid); + g_hash_table_foreach_remove(app_group_hash, __hash_table_cb, GINT_TO_POINTER(pid)); - if (ppid != -1) { + if (ppid != -1) app_group_set_status(ppid, -1, false); - } } static app_group_context_t* __get_context(int pid) { GHashTableIter iter; - gpointer key, value; + gpointer key; + gpointer value; + GList *list; + GList *i; + app_group_context_t *ac; g_hash_table_iter_init(&iter, app_group_hash); while (g_hash_table_iter_next(&iter, &key, &value)) { - GList *list = (GList*) value; - GList *i = g_list_first(list); - + list = (GList *)value; + i = g_list_first(list); while (i != NULL) { - app_group_context_t *ac = (app_group_context_t*) i->data; - - if (ac->pid == pid) { + ac = (app_group_context_t *)i->data; + if (ac && ac->pid == pid) return ac; - } + i = g_list_next(i); } } @@ -543,9 +545,9 @@ static int __can_reroute(int pid) return 0; } -static app_group_context_t* __context_dup(const app_group_context_t *context) +static app_group_context_t *__context_dup(const app_group_context_t *context) { - app_group_context_t* dup; + app_group_context_t *dup; if (!context) { _E("context is NULL."); @@ -564,11 +566,11 @@ static app_group_context_t* __context_dup(const app_group_context_t *context) static void __do_recycle(app_group_context_t *context) { - if (context->fg) { - const char *appid = NULL; - const char *pkgid = NULL; - const struct appinfo *ai = NULL; + const char *appid = NULL; + const char *pkgid = NULL; + const struct appinfo *ai = NULL; + if (context->fg) { appid = _status_app_get_appid_bypid(context->pid); ai = appinfo_find(getuid(), appid); pkgid = appinfo_get_value(ai, AIT_PKGID); @@ -577,11 +579,11 @@ static void __do_recycle(app_group_context_t *context) aul_send_app_status_change_signal(context->pid, appid, pkgid, STATUS_BACKGROUND, APP_TYPE_UI); -// _status_find_service_apps(context->pid, STATUS_BG, __prepare_to_suspend_services, true); + /* _status_find_service_apps(context->pid, STATUS_BG, __prepare_to_suspend_services, true); */ context->fg = 0; } recycle_bin = g_list_append(recycle_bin, context); -// _revoke_temporary_permission(context->pid); + /* _revoke_temporary_permission(context->pid); */ } void app_group_init() @@ -592,9 +594,10 @@ void app_group_init() void app_group_remove(int pid) { - __group_remove(pid); - app_group_context_t *context = __detach_context_from_recycle_bin(pid); + app_group_context_t *context; + __group_remove(pid); + context = __detach_context_from_recycle_bin(pid); if (context) free(context); } @@ -620,25 +623,27 @@ int app_group_get_window(int pid) int app_group_set_window(int pid, int wid) { GHashTableIter iter; - gpointer key, value; + gpointer key; + gpointer value; + GList *list; + GList *i; + int previous_wid; + int caller_wid; g_hash_table_iter_init(&iter, app_group_hash); while (g_hash_table_iter_next(&iter, &key, &value)) { - GList *list = (GList*) value; - GList *i = g_list_first(list); - - int previous_wid = 0; + list = (GList *)value; + i = g_list_first(list); + previous_wid = 0; while (i != NULL) { app_group_context_t *ac = (app_group_context_t*) i->data; - - if (ac->pid == pid) { + if (ac && ac->pid == pid) { ac->wid = wid; if (previous_wid != 0) __attach_window(previous_wid, wid); if (ac->can_shift && ac->caller_pid > 0) { - int caller_wid = app_group_get_window(ac->caller_pid); - + caller_wid = app_group_get_window(ac->caller_pid); if (caller_wid != 0) __attach_window(caller_wid, wid); } @@ -662,14 +667,14 @@ int app_group_set_window(int pid, int wid) void app_group_clear_top(int pid) { + int p; GList *list = __find_removable_apps(pid); if (list != NULL) { GList *itr = g_list_last(list); while (itr != NULL) { - int p = GPOINTER_TO_INT(itr->data); - + p = GPOINTER_TO_INT(itr->data); __detach_window(p); _term_sub_app(p); app_group_remove(p); @@ -681,14 +686,14 @@ void app_group_clear_top(int pid) gboolean app_group_is_group_app(bundle* kb) { - if (kb == NULL) - return FALSE; - char *str = NULL; const char *mode = NULL; char *appid = NULL; const struct appinfo *ai = NULL; + if (kb == NULL) + return FALSE; + bundle_get_str(kb, AUL_K_APPID, &appid); if (appid == NULL) @@ -701,9 +706,8 @@ gboolean app_group_is_group_app(bundle* kb) strncmp(mode, "singleton", 9) == 0)) { bundle_get_str(kb, APP_SVC_K_LAUNCH_MODE, &str); - if (str != NULL && strncmp(str, "group", 5) == 0) { + if (str != NULL && strncmp(str, "group", 5) == 0) return TRUE; - } } else if (mode != NULL && strncmp(mode, "group", 5) == 0) { return TRUE; } @@ -714,13 +718,14 @@ gboolean app_group_is_group_app(bundle* kb) void app_group_get_leader_pids(int *cnt, int **pids) { GHashTableIter iter; - gpointer key, value; - + gpointer key; + gpointer value; int size = g_hash_table_size(app_group_hash); int *leader_pids; + int i; if (size > 0) { - leader_pids = (int*) malloc(sizeof(int) * size); + leader_pids = (int*)malloc(sizeof(int) * size); if (leader_pids == NULL) { _E("out of memory"); *cnt = 0; @@ -729,7 +734,7 @@ void app_group_get_leader_pids(int *cnt, int **pids) } g_hash_table_iter_init(&iter, app_group_hash); - int i = 0; + i = 0; while (g_hash_table_iter_next(&iter, &key, &value)) { leader_pids[i] = GPOINTER_TO_INT(key); i++; @@ -751,7 +756,7 @@ gboolean app_group_is_leader_pid(int pid) app_group_get_leader_pids(&cnt, &pids); - for (i=0; i<cnt; i++) { + for (i = 0; i < cnt; i++) { if (pid == pids[i]) { free(pids); return TRUE; @@ -767,19 +772,24 @@ gboolean app_group_is_leader_pid(int pid) void app_group_get_group_pids(int leader_pid, int *cnt, int **pids) { GHashTableIter iter; - gpointer key, value; + gpointer key; + gpointer value; + GList *list; + GList *i; + int size; + int *pid_array; + int j; g_hash_table_iter_init(&iter, app_group_hash); while (g_hash_table_iter_next(&iter, &key, &value)) { if (GPOINTER_TO_INT(key) == leader_pid) { - GList *list = (GList*) value; - GList *i = g_list_first(list); - int size = g_list_length(list); + list = (GList *)value; + i = g_list_first(list); + size = g_list_length(list); if (size > 0) { - int *pid_array = (int*) malloc(sizeof(int) * size); - int j = 0; - + j = 0; + pid_array = (int *)malloc(sizeof(int) * size); if (pid_array == NULL) { _E("out of memory"); *cnt = 0; @@ -812,12 +822,16 @@ void app_group_get_group_pids(int leader_pid, int *cnt, int **pids) gboolean app_group_is_sub_app(int pid) { GHashTableIter iter; - gpointer key, value; + gpointer key; + gpointer value; + GList *list; + GList *found;; + g_hash_table_iter_init(&iter, app_group_hash); while (g_hash_table_iter_next(&iter, &key, &value)) { - GList *list = (GList*) value; - GList *found = NULL; + list = (GList *)value; + found = NULL; if (list != NULL) { if ((found = g_list_find_custom(list, GINT_TO_POINTER(pid), __comp_pid)) != NULL) { @@ -834,14 +848,19 @@ gboolean app_group_is_sub_app(int pid) void app_group_reroute(int pid) { GHashTableIter iter; - gpointer key, value; + gpointer key; + gpointer value; + GList *list; + GList *found = NULL; + GList *before = NULL; + GList *after = NULL; g_hash_table_iter_init(&iter, app_group_hash); while (g_hash_table_iter_next(&iter, &key, &value)) { - GList *list = (GList*) value; - GList *found = NULL; - GList *before = NULL; - GList *after = NULL; + list = (GList *)value; + found = NULL; + before = NULL; + after = NULL; if (list != NULL) { if ((found = g_list_find_custom(list, GINT_TO_POINTER(pid), __comp_pid)) != NULL) { @@ -866,15 +885,16 @@ void app_group_reroute(int pid) int app_group_get_leader_pid(int pid) { GHashTableIter iter; - gpointer key, value; + gpointer key; + gpointer value; + GList *list; int lpid = -1; int again = 0; repeat: g_hash_table_iter_init(&iter, app_group_hash); while (g_hash_table_iter_next(&iter, &key, &value)) { - GList *list = (GList*) value; - + list = (GList *)value; if (list != NULL) { if (g_list_find_custom(list, GINT_TO_POINTER(pid), __comp_pid) != NULL) { lpid = GPOINTER_TO_INT(key); @@ -909,17 +929,20 @@ void app_group_set_dead_pid(int pid) int app_group_get_status(int pid) { GHashTableIter iter; - gpointer key, value; + gpointer key; + gpointer value; + GList *list; + GList *i; + app_group_context_t *ac; g_hash_table_iter_init(&iter, app_group_hash); while (g_hash_table_iter_next(&iter, &key, &value)) { - GList *list = (GList*) value; - GList *i = g_list_first(list); + list = (GList *)value; + i = g_list_first(list); while (i != NULL) { - app_group_context_t *ac = (app_group_context_t*) i->data; - - if (ac->pid == pid) + ac = (app_group_context_t*) i->data; + if (ac && ac->pid == pid) return ac->status; i = g_list_next(i); @@ -931,30 +954,34 @@ int app_group_get_status(int pid) int app_group_set_status(int pid, int status, gboolean force) { GHashTableIter iter; - gpointer key, value; + gpointer key; + gpointer value; + GList *list; + GList *i; + app_group_context_t *ac; + GList *last; + app_group_context_t *last_ac; + char *appid = NULL; + const char *pkgid = NULL; + const struct appinfo *ai = NULL; g_hash_table_iter_init(&iter, app_group_hash); while (g_hash_table_iter_next(&iter, &key, &value)) { - GList *list = (GList*) value; - GList *i = g_list_first(list); + list = (GList *)value; + i = g_list_first(list); while (i != NULL) { - app_group_context_t *ac = (app_group_context_t*) i->data; - - if (ac->pid == pid) { + ac = (app_group_context_t*) i->data; + if (ac && ac->pid == pid) { if (status > 0) ac->status = status; - GList *last = g_list_last(list); - app_group_context_t *last_ac = (app_group_context_t*) last->data; + last = g_list_last(list); + last_ac = (app_group_context_t *)last->data; if (last_ac->wid != 0 || status == STATUS_VISIBLE || force == TRUE) { if (__is_visible(pid)) { __set_fg_flag(pid, 1, force); if (!ac->group_sig && GPOINTER_TO_INT(key) != pid) { - char *appid = NULL; - const char *pkgid = NULL; - const struct appinfo *ai = NULL; - appid = _status_app_get_appid_bypid(pid); ai = appinfo_find(getuid(), appid); pkgid = appinfo_get_value(ai, AIT_PKGID); @@ -963,8 +990,9 @@ int app_group_set_status(int pid, int status, gboolean force) aul_send_app_group_signal(GPOINTER_TO_INT(key), pid, pkgid); ac->group_sig = 1; } - } else + } else { __set_fg_flag(pid, 0, force); + } } return 0; } @@ -977,19 +1005,21 @@ int app_group_set_status(int pid, int status, gboolean force) int app_group_get_fg_flag(int pid) { GHashTableIter iter; - gpointer key, value; + gpointer key; + gpointer value; + GList *list; + GList *i; + app_group_context_t *ac; g_hash_table_iter_init(&iter, app_group_hash); while (g_hash_table_iter_next(&iter, &key, &value)) { - GList *list = (GList*) value; - GList *i = g_list_first(list); - + list = (GList*) value; + i = g_list_first(list); while (i != NULL) { - app_group_context_t *ac = (app_group_context_t*) i->data; - - if (ac->pid == pid) { + ac = (app_group_context_t*) i->data; + if (ac && ac->pid == pid) return ac->fg; - } + i = g_list_next(i); } } @@ -1001,6 +1031,12 @@ int app_group_set_hint(int pid, bundle *kb) { char *str_leader = NULL; char *str_reroute = NULL; + GHashTableIter iter; + gpointer key; + gpointer value; + GList *list; + GList *i; + app_group_context_t *ac; if (kb == NULL) return -1; @@ -1008,18 +1044,13 @@ int app_group_set_hint(int pid, bundle *kb) bundle_get_str(kb, AUL_SVC_K_CAN_BE_LEADER, &str_leader); bundle_get_str(kb, AUL_SVC_K_REROUTE, &str_reroute); - GHashTableIter iter; - gpointer key, value; - g_hash_table_iter_init(&iter, app_group_hash); while (g_hash_table_iter_next(&iter, &key, &value)) { - GList *list = (GList*) value; - GList *i = g_list_first(list); - + list = (GList *)value; + i = g_list_first(list); while (i != NULL) { - app_group_context_t *ac = (app_group_context_t*) i->data; - - if (ac->pid == pid) { + ac = (app_group_context_t *)i->data; + if (ac && ac->pid == pid) { if (str_leader != NULL && strcmp(str_leader, "true") == 0) ac->can_be_leader = 1; if (str_reroute != NULL && strcmp(str_reroute, "true") == 0) @@ -1035,14 +1066,14 @@ int app_group_set_hint(int pid, bundle *kb) int app_group_find_second_leader(int lpid) { - GList *list = (GList*) g_hash_table_lookup(app_group_hash, + app_group_context_t *ac; + GList *list = (GList *)g_hash_table_lookup(app_group_hash, GINT_TO_POINTER(lpid)); if (list != NULL) { list = g_list_next(list); - if (list != NULL) { - app_group_context_t *ac = (app_group_context_t*) list->data; - if (ac->can_be_leader) { + ac = (app_group_context_t*) list->data; + if (ac && ac->can_be_leader) { _W("found the second leader, lpid: %d, pid: %d", lpid, ac->pid); return ac->pid; } @@ -1054,18 +1085,20 @@ int app_group_find_second_leader(int lpid) void app_group_remove_leader_pid(int lpid) { + app_group_context_t *ac; + GList *next; GList *list = (GList*)g_hash_table_lookup(app_group_hash, - GINT_TO_POINTER(lpid)); + GINT_TO_POINTER(lpid)); if (list != NULL) { - GList *next = g_list_next(list); - + next = g_list_next(list); if (next != NULL) { - app_group_context_t *ac = (app_group_context_t*) list->data; - free(ac); + ac = (app_group_context_t *)list->data; + if (ac) + free(ac); list = g_list_remove_link(list, list); - ac = (app_group_context_t*) next->data; + ac = (app_group_context_t *)next->data; g_hash_table_insert(app_group_hash, GINT_TO_POINTER(ac->pid), next); g_hash_table_remove(app_group_hash, GINT_TO_POINTER(lpid)); } @@ -1084,9 +1117,8 @@ int app_group_can_start_app(const char *appid, bundle *b, gboolean *can_attach, *can_attach = TRUE; val = bundle_get_val(b, AUL_K_ORG_CALLER_PID); - if (val == NULL) { + if (val == NULL) val = bundle_get_val(b, AUL_K_CALLER_PID); - } if (val == NULL) { _E("no caller pid"); @@ -1150,17 +1182,16 @@ int app_group_find_singleton(const char *appid, int *found_pid, int *found_lpid) gpointer key = NULL; gpointer value = NULL; char *target = NULL; + GList *list; + app_group_context_t *ac; g_hash_table_iter_init(&iter, app_group_hash); while (g_hash_table_iter_next(&iter, &key, &value)) { - GList *list = (GList*) value; - + list = (GList *)value; while (list != NULL) { - app_group_context_t *ac = (app_group_context_t*) list->data; - - if (ac->launch_mode == APP_GROUP_LAUNCH_MODE_SINGLETON) { + ac = (app_group_context_t *)list->data; + if (ac && ac->launch_mode == APP_GROUP_LAUNCH_MODE_SINGLETON) { target = _status_app_get_appid_bypid(ac->pid); - if (appid != NULL && target != NULL && strcmp(appid, target) == 0) { *found_pid = ac->pid; *found_lpid = GPOINTER_TO_INT(key); @@ -1177,19 +1208,21 @@ int app_group_find_singleton(const char *appid, int *found_pid, int *found_lpid) int app_group_can_reroute(int pid) { GHashTableIter iter; - gpointer key, value; + gpointer key; + gpointer value; + GList *list; + GList *i; + app_group_context_t *ac; g_hash_table_iter_init(&iter, app_group_hash); while (g_hash_table_iter_next(&iter, &key, &value)) { - GList *list = (GList*) value; - GList *i = g_list_first(list); - + list = (GList *)value; + i = g_list_first(list); while (i != NULL) { - app_group_context_t *ac = (app_group_context_t*) i->data; - - if (ac->pid == pid) { + ac = (app_group_context_t *)i->data; + if (ac && ac->pid == pid) return ac->reroute; - } + i = g_list_next(i); } } @@ -1199,9 +1232,16 @@ int app_group_can_reroute(int pid) void app_group_lower(int pid, int *exit) { + app_group_context_t *ac; + GHashTableIter iter; + gpointer key; + gpointer value; + GList *list; + GList *i; + if (app_group_is_sub_app(pid)) { if (__can_recycle(pid) && __can_reroute(pid)) { - app_group_context_t *ac = __get_context(pid); + ac = __get_context(pid); if (ac) { if (ac->wid != 0) __detach_window(ac->wid); @@ -1217,53 +1257,50 @@ void app_group_lower(int pid, int *exit) return; } - GHashTableIter iter; - gpointer key, value; - *exit = 0; g_hash_table_iter_init(&iter, app_group_hash); while (g_hash_table_iter_next(&iter, &key, &value)) { - GList *list = (GList*) value; - GList *i = g_list_first(list); - + list = (GList *)value; + i = g_list_first(list); while (i != NULL) { - app_group_context_t *ac = (app_group_context_t*) i->data; - - if (ac->pid == pid) { - if (ac->can_shift) { - __detach_window(ac->wid); - ac->can_shift = 0; + ac = (app_group_context_t *)i->data; + if (ac && ac->can_shift) { + __detach_window(ac->wid); + ac->can_shift = 0; #ifdef WAYLAND - ecore_wl_window_lower((Ecore_Wl_Window *)ac->wid); + ecore_wl_window_lower((Ecore_Wl_Window *)ac->wid); #else - //ecore_x_window_lower(ac->wid); + /* ecore_x_window_lower(ac->wid); */ #endif - } - return; } - i = g_list_next(i); + return; } + i = g_list_next(i); } } void app_group_restart_app(int pid, bundle *b) { + const char *pid_str; + int cwid; + GList *list; + GList *i; + GHashTableIter iter; + gpointer key; + gpointer value; + app_group_context_t *ac; + if (b == NULL) return; - GHashTableIter iter; - gpointer key, value; - g_hash_table_iter_init(&iter, app_group_hash); while (g_hash_table_iter_next(&iter, &key, &value)) { - GList *list = (GList*) value; - GList *i = g_list_first(list); + list = (GList*) value; + i = g_list_first(list); while (i != NULL) { - app_group_context_t *ac = (app_group_context_t*) i->data; - - if (ac->pid == pid) { - const char *pid_str; + ac = (app_group_context_t *)i->data; + if (ac && ac->pid == pid) { ac->caller_pid = __get_caller_pid(b); if (ac->can_shift) { @@ -1277,17 +1314,14 @@ void app_group_restart_app(int pid, bundle *b) ac->can_shift = 1; if (ac->wid != 0) { if (ac->caller_pid > 0) { - int cwid = app_group_get_window(ac->caller_pid); - + cwid = app_group_get_window(ac->caller_pid); if (cwid != 0) __attach_window(cwid, ac->wid); else _E("invalid caller wid"); - - } else + } else { _E("invalid caller pid"); - - + } } } return; @@ -1299,15 +1333,15 @@ void app_group_restart_app(int pid, bundle *b) int app_group_find_pid_from_recycle_bin(const char *appid) { + app_group_context_t *ac; + const char *appid_from_bin; GList *iter = recycle_bin; while (iter) { - app_group_context_t *ac = (app_group_context_t*) iter->data; - const char *appid_from_bin = _status_app_get_appid_bypid(ac->pid); - - if (appid && appid_from_bin && strcmp(appid, appid_from_bin) == 0) { + ac = (app_group_context_t *)iter->data; + appid_from_bin = _status_app_get_appid_bypid(ac->pid); + if (appid && appid_from_bin && strcmp(appid, appid_from_bin) == 0) return ac->pid; - } iter = g_list_next(iter); } @@ -1319,6 +1353,9 @@ void app_group_get_idle_pids(int *cnt, int **pids) { GList *iter = recycle_bin; int idle_cnt = g_list_length(iter); + int *idle_pids = NULL; + int i = 0; + app_group_context_t *ac; if (idle_cnt <= 0) { *cnt = 0; @@ -1326,8 +1363,6 @@ void app_group_get_idle_pids(int *cnt, int **pids) return; } - int *idle_pids = NULL; - idle_pids = malloc(sizeof(int) * idle_cnt); if (idle_pids == NULL) { _E("Out-of-memory"); @@ -1336,9 +1371,8 @@ void app_group_get_idle_pids(int *cnt, int **pids) return; } - int i = 0; while (iter) { - app_group_context_t *ac = (app_group_context_t*) iter->data; + ac = (app_group_context_t *)iter->data; idle_pids[i] = ac->pid; iter = g_list_next(iter); i++; @@ -1350,23 +1384,26 @@ void app_group_get_idle_pids(int *cnt, int **pids) int app_group_get_next_caller_pid(int pid) { + GList *list; + GList *i; GHashTableIter iter; - gpointer key, value; + gpointer key; + gpointer value; + app_group_context_t *ac; g_hash_table_iter_init(&iter, app_group_hash); while (g_hash_table_iter_next(&iter, &key, &value)) { - GList *list = (GList*) value; - GList *i = g_list_first(list); + list = (GList*)value; + i = g_list_first(list); while (i != NULL) { - app_group_context_t *ac = (app_group_context_t*) i->data; - - if (ac->pid == pid) { + ac = (app_group_context_t *)i->data; + if (ac && ac->pid == pid) { i = g_list_next(i); if (i == NULL) return -1; - ac = (app_group_context_t*) i->data; + ac = (app_group_context_t *)i->data; return ac->caller_pid; } i = g_list_next(i); @@ -1375,5 +1412,3 @@ int app_group_get_next_caller_pid(int pid) return -1; } - - diff --git a/am_daemon/amd_appinfo.c b/am_daemon/amd_appinfo.c index 3daa8a54..a7c15f6d 100644 --- a/am_daemon/amd_appinfo.c +++ b/am_daemon/amd_appinfo.c @@ -173,7 +173,7 @@ static int __app_info_insert_handler (const pkgmgrinfo_appinfo_h handle, void *d } c->val[_AI_FILE] = strdup(appid); - c->val[_AI_NAME] = strdup(appid); //TODO : + c->val[_AI_NAME] = strdup(appid); if (pkgmgrinfo_appinfo_get_component(handle, &component)) { _E("failed to get component"); @@ -182,7 +182,7 @@ static int __app_info_insert_handler (const pkgmgrinfo_appinfo_h handle, void *d } if (component == PMINFO_UI_APP) { - c->val[_AI_COMP] = strdup("ui"); //TODO : + c->val[_AI_COMP] = strdup("ui"); if (pkgmgrinfo_appinfo_is_multiple(handle, &multiple)) { _E("failed to get multiple"); _free_appinfo(c); @@ -272,7 +272,7 @@ static int __app_info_insert_handler (const pkgmgrinfo_appinfo_h handle, void *d else c->val[_AI_POOL] = strdup("true"); - if (pkgmgrinfo_pkginfo_get_tep_name((pkgmgrinfo_pkginfo_h)info->extra_data, &tep_name)){ + if (pkgmgrinfo_pkginfo_get_tep_name((pkgmgrinfo_pkginfo_h)info->extra_data, &tep_name)) { _E("failed to get tep_name"); c->val[_AI_TEP] = NULL; } else { @@ -527,7 +527,7 @@ int appinfo_init(void) struct user_appinfo *global_appinfo; fp = fopen("/proc/cmdline", "r"); - if (fp == NULL){ + if (fp == NULL) { _E("appinfo init failed: %s", strerror(errno)); return -1; } diff --git a/am_daemon/amd_launch.c b/am_daemon/amd_launch.c index 313c004e..0e632d19 100644 --- a/am_daemon/amd_launch.c +++ b/am_daemon/amd_launch.c @@ -59,7 +59,7 @@ #define AUL_PR_NAME 16 -// SDK related defines +/* SDK related defines */ #define PATH_APP_ROOT tzplatform_getenv(TZ_USER_APP) #define PATH_GLOBAL_APP_ROOT tzplatform_getenv(TZ_SYS_RW_APP) #define PATH_DATA "/data" @@ -223,7 +223,7 @@ int _term_app(int pid, int clifd) } } - if ( (ret = __app_send_raw_with_delay_reply(pid, APP_TERM_BY_PID, + if ((ret = __app_send_raw_with_delay_reply(pid, APP_TERM_BY_PID, (unsigned char *)&dummy, 0)) < 0) { _D("terminate packet send error - use SIGKILL"); if (_send_to_sigkill(pid) < 0) { @@ -245,7 +245,7 @@ int _term_req_app(int pid, int clifd) int dummy; int ret; - if ( (ret = __app_send_raw_with_delay_reply(pid, APP_TERM_REQ_BY_PID, + if ((ret = __app_send_raw_with_delay_reply(pid, APP_TERM_REQ_BY_PID, (unsigned char *)&dummy, 0)) < 0) { _D("terminate req send error"); __real_send(clifd, ret); @@ -323,9 +323,9 @@ static void __real_send(int clifd, int ret) return; if (send(clifd, &ret, sizeof(int), MSG_NOSIGNAL) < 0) { - if (errno == EPIPE) { + if (errno == EPIPE) _E("send failed due to EPIPE.\n"); - } + _E("send fail to client"); } @@ -396,11 +396,10 @@ static gboolean __reply_handler(gpointer data) } close(fd); - if (res < 0) { + if (res < 0) __real_send(clifd, res); - } else { + else __real_send(clifd, pid); - } _D("listen fd : %d , send fd : %d, pid : %d", fd, clifd, pid); @@ -499,18 +498,17 @@ static int __compare_signature(const struct appinfo *ai, int cmd, { const char *permission; int ret; + const struct appinfo *caller_ai; + const char *preload; + pkgmgrinfo_cert_compare_result_type_e compare_result; permission = appinfo_get_value(ai, AIT_PERM); - if (permission && strncmp(permission, "signature", 9) == 0 ) { + if (permission && strncmp(permission, "signature", 9) == 0) { if (caller_uid != 0 && (cmd == APP_START || cmd == APP_START_RES)) { - const struct appinfo *caller_ai; - const char *preload; - pkgmgrinfo_cert_compare_result_type_e compare_result; - caller_ai = appinfo_find(caller_uid, caller_appid); preload = appinfo_get_value(caller_ai, AIT_PRELOAD); - if (preload && strncmp(preload, "true", 4) != 0 ) { - //is admin is global + if (preload && strncmp(preload, "true", 4) != 0) { + /* is admin is global */ if (caller_uid != GLOBAL_USER) pkgmgrinfo_pkginfo_compare_usr_app_cert_info(caller_appid, appid, caller_uid, &compare_result); @@ -556,7 +554,7 @@ static int __get_pid_for_app_group(const char *appid, int pid, int caller_uid, b *new_process = TRUE; } - if (app_group_can_start_app(appid, kb, can_attach, lpid, launch_mode) != 0 ) { + if (app_group_can_start_app(appid, kb, can_attach, lpid, launch_mode) != 0) { _E("can't make group info"); return -EILLEGALACCESS; } @@ -603,7 +601,7 @@ static int __tep_mount(char *mnt_path[]) } msg = dbus_message_new_method_call(TEP_BUS_NAME, TEP_OBJECT_PATH, - TEP_INTERFACE_NAME, TEP_MOUNT_METHOD); + TEP_INTERFACE_NAME, TEP_MOUNT_METHOD); if (!msg) { _E("dbus_message_new_method_call(%s:%s-%s)", TEP_OBJECT_PATH, TEP_INTERFACE_NAME, TEP_MOUNT_METHOD); @@ -611,9 +609,9 @@ static int __tep_mount(char *mnt_path[]) } if (!dbus_message_append_args(msg, - DBUS_TYPE_STRING, &mnt_path[0], - DBUS_TYPE_STRING, &mnt_path[1], - DBUS_TYPE_INVALID)) { + DBUS_TYPE_STRING, &mnt_path[0], + DBUS_TYPE_STRING, &mnt_path[1], + DBUS_TYPE_INVALID)) { _E("Ran out of memory while constructing args\n"); func_ret = -1; goto func_out; @@ -624,13 +622,15 @@ static int __tep_mount(char *mnt_path[]) func_ret = -1; goto func_out; } -func_out : + +func_out: dbus_message_unref(msg); + return func_ret; } static void __send_mount_request(const struct appinfo *ai, const char *tep_name, - bundle *kb) + bundle *kb) { SECURE_LOGD("tep name is: %s", tep_name); char *mnt_path[2] = {NULL, }; @@ -650,17 +650,18 @@ static void __send_mount_request(const struct appinfo *ai, const char *tep_name, if (installed_storage != NULL) { SECURE_LOGD("storage: %s", installed_storage); if (strncmp(installed_storage, "internal", 8) == 0) { - snprintf(tep_path, PATH_MAX, "%s/%s/res/%s", path_app_root, pkgid, - tep_name); + snprintf(tep_path, PATH_MAX, "%s/%s/res/%s", + path_app_root, pkgid, tep_name); mnt_path[1] = strdup(tep_path); - snprintf(tep_path, PATH_MAX, "%s/%s/res/tep", path_app_root, pkgid); + snprintf(tep_path, PATH_MAX, "%s/%s/res/tep", + path_app_root, pkgid); mnt_path[0] = strdup(tep_path); } else if (strncmp(installed_storage, "external", 8) == 0) { - snprintf(tep_path, PATH_MAX, "%step/%s", PREFIX_EXTERNAL_STORAGE_PATH, - tep_name); + snprintf(tep_path, PATH_MAX, "%step/%s", + PREFIX_EXTERNAL_STORAGE_PATH, tep_name); mnt_path[1] = strdup(tep_path); snprintf(tep_path, PATH_MAX, "%step/tep-access", - PREFIX_EXTERNAL_STORAGE_PATH); /* TODO : keeping tep/tep-access for now for external storage */ + PREFIX_EXTERNAL_STORAGE_PATH); /* TODO : keeping tep/tep-access for now for external storage */ mnt_path[0] = strdup(tep_path); } diff --git a/am_daemon/amd_request.c b/am_daemon/amd_request.c index 121801c6..cfb68614 100644 --- a/am_daemon/amd_request.c +++ b/am_daemon/amd_request.c @@ -346,7 +346,7 @@ static gboolean __add_history_handler(gpointer user_data) rec.pkg_name = pkt->appid; rec.app_path = app_path; - if(pkt->len > 0) + if (pkt->len > 0) rec.arg = pkt->data; SECURE_LOGD("add rua history %s %s", rec.pkg_name, rec.app_path); diff --git a/am_daemon/amd_status.c b/am_daemon/amd_status.c index 989fac2d..88a0f82b 100644 --- a/am_daemon/amd_status.c +++ b/am_daemon/amd_status.c @@ -40,7 +40,7 @@ #include "menu_db_util.h" #include "amd_app_group.h" -typedef struct _app_status_info_t{ +typedef struct _app_status_info_t { char appid[MAX_PACKAGE_STR_SIZE]; char app_path[MAX_PACKAGE_APP_PATH_SIZE]; int status; @@ -61,8 +61,8 @@ int _status_add_app_info_list(const char *appid, const char *app_path, int pid, GSLIST_FOREACH_SAFE(app_status_info_list, iter, iter_next) { info_t = (app_status_info_t *)iter->data; - if(pid == info_t->pid) { - if(uid == info_t->uid) + if (pid == info_t->pid) { + if (uid == info_t->uid) return 0; else { /* PID is unique so if it is exist but user value is not correct remove it. */ @@ -140,7 +140,7 @@ int _status_remove_app_info_list(int pid, uid_t uid) GSLIST_FOREACH_SAFE(app_status_info_list, iter, iter_next) { info_t = (app_status_info_t *)iter->data; - if((pid == info_t->pid) && ((info_t->uid == uid) || (info_t->uid == 0))) { + if ((pid == info_t->pid) && ((info_t->uid == uid) || (info_t->uid == 0))) { app_status_info_list = g_slist_remove(app_status_info_list, info_t); free(info_t); break; diff --git a/src/aul_rsc_mgr.c b/src/aul_rsc_mgr.c index add52598..ce0b4677 100755 --- a/src/aul_rsc_mgr.c +++ b/src/aul_rsc_mgr.c @@ -118,26 +118,28 @@ static gint __resource_manager_comp(gconstpointer a, gconstpointer b) static gint __compare_path(gconstpointer a, gconstpointer b) { char tmp_path[MAX_PATH] = {0, }; - resource_node_list_t *tmp_node_info= (resource_node_list_t *)a; + resource_node_list_t *tmp_node_info = (resource_node_list_t *)a; snprintf(tmp_path, MAX_PATH - 1, "%s%s", res_path, tmp_node_info->folder); return strncmp(tmp_path, (char *)b, strlen(tmp_path)); } - static int __get_dpi(void) { int dpi = 0; char *tmp = NULL; + if (is_slice) { bundle_get_str(given_attr_list, RSC_NODE_ATTR_SCREEN_DPI, &tmp); if (tmp == NULL) { LOGE("Failed to retrieve DPI"); dpi = 0; - } else + } else { dpi = atoi(tmp); - } else + } + } else { system_info_get_platform_int("http://tizen.org/feature/screen.dpi", &dpi); + } return dpi; } @@ -243,65 +245,59 @@ static void __bundle_iterator_get_valid_nodes(const char *key, const int type, } switch (node_attr) { - case NODE_ATTR_SCREEN_DPI: - if (screen_dpi == -1) - screen_dpi =__get_dpi(); - if (screen_dpi != atoi(val)) - *invalid = true; - break; - - case NODE_ATTR_SCREEN_DPI_RANGE: - sscanf(val, "%s %d %s %d", from, &min, to, &max); - if (screen_dpi == -1) - screen_dpi =__get_dpi(); - if (!(min <= screen_dpi && screen_dpi <= max)) - *invalid = true; - break; - - case NODE_ATTR_SCREEN_WIDTH_RANGE: - sscanf(val, "%s %d %s %d", from, &min, to, &max); - if (screen_width == -1) - screen_width = __get_screen_width(); - if (!(min <= screen_width && screen_width <= max)) - *invalid = true; - break; - - case NODE_ATTR_SCREEN_LARGE: - if (!(strcmp(val, "true"))) - t_val = true; + case NODE_ATTR_SCREEN_DPI: + if (screen_dpi == -1) + screen_dpi = __get_dpi(); + if (screen_dpi != atoi(val)) + *invalid = true; + break; + case NODE_ATTR_SCREEN_DPI_RANGE: + sscanf(val, "%s %d %s %d", from, &min, to, &max); + if (screen_dpi == -1) + screen_dpi = __get_dpi(); + if (!(min <= screen_dpi && screen_dpi <= max)) + *invalid = true; + break; + case NODE_ATTR_SCREEN_WIDTH_RANGE: + sscanf(val, "%s %d %s %d", from, &min, to, &max); + if (screen_width == -1) + screen_width = __get_screen_width(); + if (!(min <= screen_width && screen_width <= max)) + *invalid = true; + break; + case NODE_ATTR_SCREEN_LARGE: + if (!(strcmp(val, "true"))) + t_val = true; + else + t_val = false; + if (screen_size_large == -1) { + ret_bool = __get_screen_large(); + if (ret_bool) + screen_size_large = 1; else - t_val = false; - if (screen_size_large == -1) { - ret_bool = __get_screen_large(); - if (ret_bool) - screen_size_large = 1; - else - screen_size_large = 0; - } - if (((bool)screen_size_large) != t_val) - *invalid = true; - break; - - case NODE_ATTR_SCREEN_BPP: - if (screen_bpp == -1) - screen_bpp = __get_screen_bpp(); - if (screen_bpp != atoi(val)) - *invalid = true; - break; - - case NODE_ATTR_PLATFORM_VER: - if (version == NULL) - version = __get_platform_version(); - if (strcmp(version, val)) - *invalid = true; - break; - - case NODE_ATTR_LANGUAGE: - if (cur_language == NULL) - cur_language = vconf_get_str(VCONFKEY_LANGSET); - - if (strncmp(cur_language, val, strlen(val))) - *invalid = true; + screen_size_large = 0; + } + if (((bool)screen_size_large) != t_val) + *invalid = true; + break; + case NODE_ATTR_SCREEN_BPP: + if (screen_bpp == -1) + screen_bpp = __get_screen_bpp(); + if (screen_bpp != atoi(val)) + *invalid = true; + break; + case NODE_ATTR_PLATFORM_VER: + if (version == NULL) + version = __get_platform_version(); + if (strcmp(version, val)) + *invalid = true; + break; + case NODE_ATTR_LANGUAGE: + if (cur_language == NULL) + cur_language = vconf_get_str(VCONFKEY_LANGSET); + + if (strncmp(cur_language, val, strlen(val))) + *invalid = true; break; } } @@ -320,33 +316,27 @@ static void __bundle_iterator_get_best_node(const char *key, const char *val, } switch (node_attr) { - case NODE_ATTR_SCREEN_DPI: - *weight += WEIGHT_SCREEN_DPI; - break; - - case NODE_ATTR_SCREEN_DPI_RANGE: - *weight += WEIGHT_SCREEN_DPI_RANGE; - break; - - case NODE_ATTR_SCREEN_WIDTH_RANGE: - *weight += WEIGHT_SCREEN_WIDTH_RANGE; - break; - - case NODE_ATTR_SCREEN_LARGE: - *weight += WEIGHT_SCREEN_LARGE; - break; - - case NODE_ATTR_SCREEN_BPP: - *weight += WEIGHT_SCREEN_BPP; - break; - - case NODE_ATTR_PLATFORM_VER: - *weight += WEIGHT_PLATFORM_VERSION; - break; - - case NODE_ATTR_LANGUAGE: - *weight += WEIGHT_LANGUAGE; - break; + case NODE_ATTR_SCREEN_DPI: + *weight += WEIGHT_SCREEN_DPI; + break; + case NODE_ATTR_SCREEN_DPI_RANGE: + *weight += WEIGHT_SCREEN_DPI_RANGE; + break; + case NODE_ATTR_SCREEN_WIDTH_RANGE: + *weight += WEIGHT_SCREEN_WIDTH_RANGE; + break; + case NODE_ATTR_SCREEN_LARGE: + *weight += WEIGHT_SCREEN_LARGE; + break; + case NODE_ATTR_SCREEN_BPP: + *weight += WEIGHT_SCREEN_BPP; + break; + case NODE_ATTR_PLATFORM_VER: + *weight += WEIGHT_PLATFORM_VERSION; + break; + case NODE_ATTR_LANGUAGE: + *weight += WEIGHT_LANGUAGE; + break; } } @@ -373,21 +363,18 @@ static const char *__get_cache(aul_resource_e type, return NULL; } else { switch (type) { - case AUL_RESOURCE_TYPE_IMAGE: - rsc_type = RSC_GROUP_TYPE_IMAGE; - break; - - case AUL_RESOURCE_TYPE_LAYOUT: - rsc_type = RSC_GROUP_TYPE_LAYOUT; - break; - - case AUL_RESOURCE_TYPE_SOUND: - rsc_type = RSC_GROUP_TYPE_SOUND; - break; - - case AUL_RESOURCE_TYPE_BIN: - rsc_type = RSC_GROUP_TYPE_BIN; - break; + case AUL_RESOURCE_TYPE_IMAGE: + rsc_type = RSC_GROUP_TYPE_IMAGE; + break; + case AUL_RESOURCE_TYPE_LAYOUT: + rsc_type = RSC_GROUP_TYPE_LAYOUT; + break; + case AUL_RESOURCE_TYPE_SOUND: + rsc_type = RSC_GROUP_TYPE_SOUND; + break; + case AUL_RESOURCE_TYPE_BIN: + rsc_type = RSC_GROUP_TYPE_BIN; + break; } } @@ -397,8 +384,7 @@ static const char *__get_cache(aul_resource_e type, return NULL; } else { total_len = strlen(rsc_type) + strlen(id) + 2; - - key = (char *) calloc(1, total_len); + key = (char *)calloc(1, total_len); if (key == NULL) { LOGE("failed to create a resource_cache(0x%08x)", AUL_RESOURCE_ERROR_OUT_OF_MEMORY); @@ -498,28 +484,25 @@ static void __put_cache(aul_resource_e type, const char *id, return; } else { switch (type) { - case AUL_RESOURCE_TYPE_IMAGE: - rsc_type = RSC_GROUP_TYPE_IMAGE; - break; - - case AUL_RESOURCE_TYPE_LAYOUT: - rsc_type = RSC_GROUP_TYPE_LAYOUT; - break; - - case AUL_RESOURCE_TYPE_SOUND: - rsc_type = RSC_GROUP_TYPE_SOUND; - break; - - case AUL_RESOURCE_TYPE_BIN: - rsc_type = RSC_GROUP_TYPE_BIN; - break; + case AUL_RESOURCE_TYPE_IMAGE: + rsc_type = RSC_GROUP_TYPE_IMAGE; + break; + case AUL_RESOURCE_TYPE_LAYOUT: + rsc_type = RSC_GROUP_TYPE_LAYOUT; + break; + case AUL_RESOURCE_TYPE_SOUND: + rsc_type = RSC_GROUP_TYPE_SOUND; + break; + case AUL_RESOURCE_TYPE_BIN: + rsc_type = RSC_GROUP_TYPE_BIN; + break; } } if (g_hash_table_size(resource_handle->cache) > THRESHOLD_TO_CLEAN) __trim_cache(); - resource_cache = (resource_cache_context_t *) calloc(1, + resource_cache = (resource_cache_context_t *)calloc(1, sizeof(resource_cache_context_t)); if (resource_cache == NULL) { LOGE("failed to create a resource_group(0x%08x)", @@ -528,8 +511,7 @@ static void __put_cache(aul_resource_e type, const char *id, } total_len = strlen(rsc_type) + strlen(id) + 2; - - key = (char *) calloc(1, total_len); + key = (char *)calloc(1, total_len); if (key == NULL) { LOGE("failed to create a resource_cache(0x%08x)", AUL_RESOURCE_ERROR_OUT_OF_MEMORY); @@ -565,21 +547,18 @@ static resource_group_t *__find_group(resource_data_t *data, return NULL; } else { switch (type) { - case AUL_RESOURCE_TYPE_IMAGE: - rsc_type = RSC_GROUP_TYPE_IMAGE; - break; - - case AUL_RESOURCE_TYPE_LAYOUT: - rsc_type = RSC_GROUP_TYPE_LAYOUT; - break; - - case AUL_RESOURCE_TYPE_SOUND: - rsc_type = RSC_GROUP_TYPE_SOUND; - break; - - case AUL_RESOURCE_TYPE_BIN: - rsc_type = RSC_GROUP_TYPE_BIN; - break; + case AUL_RESOURCE_TYPE_IMAGE: + rsc_type = RSC_GROUP_TYPE_IMAGE; + break; + case AUL_RESOURCE_TYPE_LAYOUT: + rsc_type = RSC_GROUP_TYPE_LAYOUT; + break; + case AUL_RESOURCE_TYPE_SOUND: + rsc_type = RSC_GROUP_TYPE_SOUND; + break; + case AUL_RESOURCE_TYPE_BIN: + rsc_type = RSC_GROUP_TYPE_BIN; + break; } } @@ -724,13 +703,11 @@ static int __close(resource_manager_t *handle) } __invalidate_cache(); - if (handle->cache != NULL) { + if (handle->cache != NULL) g_hash_table_destroy(handle->cache); - } - if (handle->data != NULL) { + if (handle->data != NULL) pkgmgrinfo_resource_close(handle->data); - } free(handle); @@ -822,11 +799,11 @@ static aul_resource_e __get_resource_type(char *type) if (strcmp(type, RSC_GROUP_TYPE_IMAGE) == 0) return AUL_RESOURCE_TYPE_IMAGE; - else if(strcmp(type, RSC_GROUP_TYPE_LAYOUT) == 0) + else if (strcmp(type, RSC_GROUP_TYPE_LAYOUT) == 0) return AUL_RESOURCE_TYPE_LAYOUT; - else if(strcmp(type, RSC_GROUP_TYPE_SOUND) == 0) + else if (strcmp(type, RSC_GROUP_TYPE_SOUND) == 0) return AUL_RESOURCE_TYPE_SOUND; - else if(strcmp(type, RSC_GROUP_TYPE_BIN) == 0) + else if (strcmp(type, RSC_GROUP_TYPE_BIN) == 0) return AUL_RESOURCE_TYPE_BIN; else return -1; @@ -906,9 +883,9 @@ static int __make_list(void) group_type = tmp_group->type; node_list = tmp_group->node_list; memset(folder, '\0', MAX_PATH); - snprintf(folder, MAX_PATH - 1, "%s/",tmp_group->folder); + snprintf(folder, MAX_PATH - 1, "%s/", tmp_group->folder); - /*make struct and put it into all node list*/ + /* make struct and put it into all node list */ tmp_node_struct = (resource_node_list_t *)calloc(1, sizeof(resource_node_list_t)); if (tmp_node_struct == NULL) { LOGE("calloc failed"); @@ -924,7 +901,7 @@ static int __make_list(void) if (tmp_node == NULL) return AUL_RESOURCE_ERROR_IO_ERROR; - /*retrieve language value from each node*/ + /* retrieve language value from each node */ b = tmp_node->attr; if (b == NULL) return AUL_RESOURCE_ERROR_IO_ERROR; @@ -933,9 +910,9 @@ static int __make_list(void) g_hash_table_add(supported_lang_list, strdup(node_lang)); memset(folder, '\0', MAX_PATH); - snprintf(folder, MAX_PATH - 1, "%s/",tmp_node->folder); + snprintf(folder, MAX_PATH - 1, "%s/", tmp_node->folder); - /*make struct and put it into all node list*/ + /* make struct and put it into all node list */ tmp_node_struct = (resource_node_list_t *)calloc(1, sizeof(resource_node_list_t)); if (tmp_node_struct == NULL) { LOGE("calloc failed"); diff --git a/src/launch.c b/src/launch.c index 2a57e035..d80cfec1 100644 --- a/src/launch.c +++ b/src/launch.c @@ -83,15 +83,13 @@ int app_start(bundle *kb) _app_start_res_prepare(kb); __call_aul_handler(AUL_START, kb); - // Handle the DataControl callback + /* Handle the DataControl callback */ str = bundle_get_val(kb, AUL_K_DATA_CONTROL_TYPE); - if (str != NULL && strcmp(str, "CORE") == 0) - { + if (str != NULL && strcmp(str, "CORE") == 0) { if (__dc_handler != NULL) - { - __dc_handler(kb, 0, NULL); // bundle, request_id, data - } + __dc_handler(kb, 0, NULL); /* bundle, request_id, data */ } + return 0; } @@ -165,44 +163,45 @@ static int __app_send_cmd_with_fd(int pid, int uid, int cmd, bundle *kb, int *re int res = AUL_R_OK; res = bundle_encode(kb, &kb_data, &datalen); - if (res != BUNDLE_ERROR_NONE) { + if (res != BUNDLE_ERROR_NONE) return AUL_R_EINVAL; - } + if ((res = __app_send_raw_with_fd_reply(pid, uid, cmd, kb_data, datalen, ret_fd)) < 0) { switch (res) { - case -EINVAL: - res = AUL_R_EINVAL; - break; - case -ECOMM: - res = AUL_R_ECOMM; - break; - case -EAGAIN: - res = AUL_R_ETIMEOUT; - break; - case -ELOCALLAUNCH_ID: - res = AUL_R_LOCAL; - break; - case -EILLEGALACCESS: - res = AUL_R_EILLACC; - break; - case -ETERMINATING: - res = AUL_R_ETERMINATING; - break; - case -ENOLAUNCHPAD: - res = AUL_R_ENOLAUNCHPAD; - break; + case -EINVAL: + res = AUL_R_EINVAL; + break; + case -ECOMM: + res = AUL_R_ECOMM; + break; + case -EAGAIN: + res = AUL_R_ETIMEOUT; + break; + case -ELOCALLAUNCH_ID: + res = AUL_R_LOCAL; + break; + case -EILLEGALACCESS: + res = AUL_R_EILLACC; + break; + case -ETERMINATING: + res = AUL_R_ETERMINATING; + break; + case -ENOLAUNCHPAD: + res = AUL_R_ENOLAUNCHPAD; + break; #ifdef _APPFW_FEATURE_APP_CONTROL_LITE - case -EUGLOCAL_LAUNCH: - res = AUL_R_UG_LOCAL; - break; + case -EUGLOCAL_LAUNCH: + res = AUL_R_UG_LOCAL; + break; #endif - case -EREJECTED: - res = AUL_R_EREJECTED; - break; - default: - res = AUL_R_ERROR; + case -EREJECTED: + res = AUL_R_EREJECTED; + break; + default: + res = AUL_R_ERROR; } } + free(kb_data); return res; @@ -317,9 +316,9 @@ static int __app_launch_local(bundle *b) if (!aul_is_initialized()) return AUL_R_ENOINIT; - if (b == NULL) { + if (b == NULL) _E("bundle for APP_START is NULL"); - } + if (g_idle_add(__app_start_internal, b) > 0) return AUL_R_OK; else @@ -340,39 +339,40 @@ int app_request_to_launchpad_with_fd(int cmd, const char *appid, bundle *kb, int { int must_free = 0; int ret = 0; + bundle *b; SECURE_LOGD("launch request : %s", appid); if (kb == NULL) { kb = bundle_create(); must_free = 1; - } else + } else { __clear_internal_key(kb); + } ret = __app_send_cmd_with_fd(AUL_UTIL_PID, uid, cmd, kb, fd); _D("launch request result : %d", ret); if (ret == AUL_R_LOCAL) { _E("app_request_to_launchpad : Same Process Send Local"); - bundle *b; switch (cmd) { - case APP_START: - case APP_START_RES: - b = bundle_dup(kb); - ret = __app_launch_local(b); - break; - case APP_OPEN: - case APP_RESUME: - case APP_RESUME_BY_PID: - ret = __app_resume_local(); - break; - default: - _E("no support packet"); + case APP_START: + case APP_START_RES: + b = bundle_dup(kb); + ret = __app_launch_local(b); + break; + case APP_OPEN: + case APP_RESUME: + case APP_RESUME_BY_PID: + ret = __app_resume_local(); + break; + default: + _E("no support packet"); } } - /* cleanup */ + /* cleanup */ if (must_free) bundle_free(kb); @@ -393,13 +393,15 @@ int app_request_to_launchpad_for_uid(int cmd, const char *appid, bundle *kb, uid { int must_free = 0; int ret = 0; + bundle *b; SECURE_LOGD("launch request : %s", appid); if (kb == NULL) { kb = bundle_create(); must_free = 1; - } else + } else { __clear_internal_key(kb); + } bundle_add(kb, AUL_K_APPID, appid); __set_stime(kb); @@ -408,21 +410,20 @@ int app_request_to_launchpad_for_uid(int cmd, const char *appid, bundle *kb, uid _D("launch request result : %d", ret); if (ret == AUL_R_LOCAL) { _E("app_request_to_launchpad : Same Process Send Local"); - bundle *b; switch (cmd) { - case APP_START: - case APP_START_RES: - b = bundle_dup(kb); - ret = __app_launch_local(b); - break; - case APP_OPEN: - case APP_RESUME: - case APP_RESUME_BY_PID: - ret = __app_resume_local(); - break; - default: - _E("no support packet"); + case APP_START: + case APP_START_RES: + b = bundle_dup(kb); + ret = __app_launch_local(b); + break; + case APP_OPEN: + case APP_RESUME: + case APP_RESUME_BY_PID: + ret = __app_resume_local(); + break; + default: + _E("no support packet"); } } @@ -599,10 +600,8 @@ int aul_register_init_callback( int aul_initialize() { - if (aul_initialized) { - //_E("aul already initialized"); + if (aul_initialized) return AUL_R_ECANCELED; - } aul_fd = __create_server_sock(getpid()); if (aul_fd < 0) { @@ -616,12 +615,10 @@ int aul_initialize() SLPAPI void aul_finalize() { - aul_launch_fini(); - if (aul_initialized) { + if (aul_initialized) close(aul_fd); - } return; } @@ -705,15 +702,15 @@ SLPAPI int aul_terminate_pid(int pid) SLPAPI int aul_terminate_bgapp_pid(int pid) { - char pkgname[MAX_PID_STR_BUFSZ]; - int ret; + char pkgname[MAX_PID_STR_BUFSZ]; + int ret; - if (pid <= 0) - return AUL_R_EINVAL; + if (pid <= 0) + return AUL_R_EINVAL; - snprintf(pkgname, MAX_PID_STR_BUFSZ, "%d", pid); - ret = app_request_to_launchpad(APP_TERM_BGAPP_BY_PID, pkgname, NULL); - return ret; + snprintf(pkgname, MAX_PID_STR_BUFSZ, "%d", pid); + ret = app_request_to_launchpad(APP_TERM_BGAPP_BY_PID, pkgname, NULL); + return ret; } SLPAPI int aul_terminate_pid_without_restart(int pid) @@ -769,22 +766,22 @@ SLPAPI int aul_unset_data_control_provider_cb(void) SLPAPI void aul_set_preinit_window(void *evas_object) { - __window_object = evas_object; + __window_object = evas_object; } SLPAPI void* aul_get_preinit_window(const char *win_name) { - return __window_object; + return __window_object; } SLPAPI void aul_set_preinit_background(void *evas_object) { - __bg_object = evas_object; + __bg_object = evas_object; } SLPAPI void* aul_get_preinit_background(void) { - return __bg_object; + return __bg_object; } SLPAPI void aul_set_preinit_conformant(void *evas_object) diff --git a/src/launch_glib.c b/src/launch_glib.c index 5b8fdfc8..907b9bc2 100644 --- a/src/launch_glib.c +++ b/src/launch_glib.c @@ -154,9 +154,9 @@ SLPAPI int aul_launch_argv_handler(int argc, char **argv) return AUL_R_ENOINIT; b = bundle_import_from_argv(argc, argv); - if (b == NULL) { + if (b == NULL) _E("bundle for APP_START is NULL"); - } + if (g_idle_add(__app_start_internal, b) > 0) return AUL_R_OK; else @@ -168,9 +168,9 @@ SLPAPI int aul_launch_local(bundle *b) if (!aul_is_initialized()) return AUL_R_ENOINIT; - if (b == NULL) { + if (b == NULL) _E("bundle for APP_START is NULL"); - } + if (g_idle_add(__app_start_internal, b) > 0) return AUL_R_OK; else diff --git a/src/launch_with_result.c b/src/launch_with_result.c index 73c52dfc..8f852954 100644 --- a/src/launch_with_result.c +++ b/src/launch_with_result.c @@ -162,9 +162,8 @@ static int __call_app_result_callback(bundle *kb, int is_cancel, newinfo.caller_cb = NULL; newinfo.caller_data = NULL; - if (info->caller_cb) { + if (info->caller_cb) info->caller_cb(newinfo.launched_pid, info->caller_data); - } __remove_resultcb(info); __add_resultcb(newinfo.launched_pid, newinfo.cb_func, newinfo.priv_data); @@ -239,7 +238,7 @@ int _app_start_res_prepare(bundle *kb) return 0; str = bundle_get_val(kb, AUL_K_NO_CANCEL); - if ( str && strncmp("1", str, 1) == 0) { + if (str && strncmp("1", str, 1) == 0) { _D("no cancel"); return 0; } @@ -299,7 +298,7 @@ SLPAPI int aul_launch_app_with_result(const char *pkgname, bundle *kb, void __iterate(const char *key, const char *val, void *data) { - static int i=0; + static int i = 0; _D("%d %s %s", i++, key, val); } @@ -338,9 +337,9 @@ SLPAPI int aul_forward_app(const char* pkgname, bundle *kb) goto end; } -// bundle_iterate(dupb, __iterate, NULL); + /* bundle_iterate(dupb, __iterate, NULL); */ - snprintf(tmp_pid, MAX_PID_STR_BUFSZ,"%d",ret); + snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", ret); ret = aul_create_result_bundle(dupb, &outb); if (ret < 0) @@ -349,7 +348,7 @@ SLPAPI int aul_forward_app(const char* pkgname, bundle *kb) bundle_del(outb, AUL_K_FWD_CALLEE_PID); bundle_add(outb, AUL_K_FWD_CALLEE_PID, tmp_pid); -// bundle_iterate(outb, __iterate, NULL); + /* bundle_iterate(outb, __iterate, NULL); */ ret = aul_send_result(outb, 1); @@ -367,7 +366,7 @@ SLPAPI int aul_create_result_bundle(bundle *inb, bundle **outb) *outb = NULL; - if (inb == NULL){ + if (inb == NULL) { _E("return msg create fail"); return AUL_R_EINVAL; } @@ -419,8 +418,7 @@ int aul_send_result(bundle *kb, int is_cancel) _D("caller pid : %d", pid); - if (bundle_get_val(kb, AUL_K_SEND_RESULT) == NULL) - { + if (bundle_get_val(kb, AUL_K_SEND_RESULT) == NULL) { _D("original msg is not msg with result"); return AUL_R_OK; } @@ -431,14 +429,13 @@ int aul_send_result(bundle *kb, int is_cancel) bundle_add(kb, AUL_K_CALLEE_PID, tmp_pid); ret = aul_app_get_appid_bypid(callee_pid, callee_appid, sizeof(callee_appid)); - if (ret == 0) { + if (ret == 0) bundle_add(kb, AUL_K_CALLEE_APPID, callee_appid); - } else { + else _W("fail(%d) to get callee appid by pid", ret); - } - - ret = app_send_cmd_with_noreply(AUL_UTIL_PID, (is_cancel==1)? APP_CANCEL : APP_RESULT, kb); + ret = app_send_cmd_with_noreply(AUL_UTIL_PID, + (is_cancel == 1) ? APP_CANCEL : APP_RESULT, kb); _D("app_send_cmd_with_noreply : %d", ret); if (latest_caller_pid == pid) @@ -449,11 +446,10 @@ int aul_send_result(bundle *kb, int is_cancel) int app_subapp_terminate_request() { - if (is_subapp) { + if (is_subapp) subapp_cb(subapp_data); - } else { + else __call_aul_handler(AUL_TERMINATE, NULL); - } return 0; } @@ -535,7 +531,6 @@ static gboolean __invoke_caller_cb(gpointer data) launched_pid = GPOINTER_TO_INT(data); info = __find_resultcb(launched_pid); - if (info && info->caller_cb) info->caller_cb(info->launched_pid, info->caller_data); @@ -98,8 +98,7 @@ SLPAPI int aul_get_mime_description(const char *mimetype, char *desc, int len) if (founded != NULL) snprintf(desc, len, "%s", founded); else { - /* TODO : should to try to extract from - share mime info's comment */ + /* TODO : should to try to extract from share mime info's comment */ return AUL_R_ERROR; } @@ -176,9 +175,8 @@ SLPAPI int aul_get_mime_from_file(const char *filename, char *mimetype, int len) return AUL_R_EINVAL; mime = xdg_mime_get_mime_type_for_file(filename, 0); - if (strcmp(mime, "application/octet-stream") == 0) { + if (strcmp(mime, "application/octet-stream") == 0) mime = xdg_mime_get_mime_type_from_file_name(filename); - } snprintf(mimetype, len, "%s", mime); return AUL_R_OK; diff --git a/src/pkginfo.c b/src/pkginfo.c index 8ef59cc7..fc6ea6aa 100644 --- a/src/pkginfo.c +++ b/src/pkginfo.c @@ -82,11 +82,10 @@ SLPAPI int aul_app_get_running_app_info(aul_app_info_iter_fn enum_fn, return AUL_R_EINVAL; pkt = __app_send_cmd_with_result(AUL_UTIL_PID, APP_RUNNING_INFO, NULL, 0); - if (pkt == NULL) return AUL_R_ERROR; - for ( pkt_data = (char *)pkt->data; ; pkt_data = NULL) { + for (pkt_data = (char *)pkt->data; ; pkt_data = NULL) { token = strtok_r(pkt_data, ";", &saveptr1); if (token == NULL) break; diff --git a/src/service.c b/src/service.c index 198d9519..c7b9cc19 100755 --- a/src/service.c +++ b/src/service.c @@ -1346,7 +1346,7 @@ SLPAPI int aul_svc_set_loader_id(bundle *b, int loader_id) return AUL_SVC_RET_EINVAL; } - snprintf(tmp, sizeof(tmp),"%d", loader_id); + snprintf(tmp, sizeof(tmp), "%d", loader_id); return __set_bundle(b, AUL_K_LOADER_ID, tmp); } diff --git a/src/status.c b/src/status.c index 30560f8f..2e9e1723 100644 --- a/src/status.c +++ b/src/status.c @@ -68,9 +68,8 @@ SLPAPI int aul_app_get_status_bypid(int pid) { int ret; - if (pid == getpid()) { + if (pid == getpid()) return app_status; - } ret = __app_send_raw(AUL_UTIL_PID, APP_GET_STATUS, (unsigned char *)&pid, sizeof(pid)); @@ -84,10 +83,10 @@ SLPAPI int aul_add_status_local_cb(int (*func)(int status, void *data), void *da if (func == NULL) return -1; - // check known callback + /* check known callback */ while (cb) { if (cb && cb->handler == func && cb->data == data) { - // already in list + /* already in list */ return 0; } cb = cb->next; diff --git a/test/open_app.c b/test/open_app.c index 948d07f8..6be37528 100644 --- a/test/open_app.c +++ b/test/open_app.c @@ -54,11 +54,11 @@ int launch(int debug_option) { int pid; - if(!debug_option) + if (!debug_option) pid = aul_open_app(gargv[1]); else { kb = create_internal_bundle(); - if (NULL == kb) { + if (kb == NULL) { printf("bundle creation fail\n"); return -1; } @@ -77,7 +77,7 @@ static int __launch_app_dead_handler(int pid, void *data) { int listen_pid = (intptr_t)data; - if(listen_pid == pid) + if (listen_pid == pid) g_main_loop_quit(mainloop); return 0; @@ -96,7 +96,7 @@ static gboolean run_func(void *data) if (kb) { str = bundle_get_val(kb, "__LAUNCH_APP_MODE__"); - if (str && strcmp(str, "SYNC") == 0 ) + if (str && strcmp(str, "SYNC") == 0) aul_listen_app_dead_signal(__launch_app_dead_handler, (void *)(intptr_t)pid); else g_main_loop_quit(mainloop); @@ -114,7 +114,7 @@ static gboolean run_func(void *data) int main(int argc, char **argv) { - if ((argc < 2)||(argc > 3)) { + if ((argc < 2) || (argc > 3)) { print_usage(argv[0]); exit(EXIT_FAILURE); } @@ -122,8 +122,8 @@ int main(int argc, char **argv) gargc = argc; gargv = argv; - if(argc == 3) { - if( (strcmp(argv[2],"-d") != 0 ) && (strcmp(argv[1],"-d") != 0 ) ) { + if (argc == 3) { + if ((strcmp(argv[2], "-d") != 0) && (strcmp(argv[1], "-d") != 0)) { printf("additionnal argument should be -d to enable debugging\n"); print_usage(argv[0]); exit(EXIT_FAILURE); diff --git a/tool/app_group_info.c b/tool/app_group_info.c index 833816c1..7138466d 100644 --- a/tool/app_group_info.c +++ b/tool/app_group_info.c @@ -20,9 +20,9 @@ static void print_idle_info(void) printf(" pid : %d\n", pids[i]); ret = aul_app_get_appid_bypid(pids[i], appid_buf, sizeof(appid_buf) - 1); - if (ret != AUL_R_OK) { + if (ret != AUL_R_OK) appid_buf[0] = '\0'; - } + printf(" appid : %s\n", appid_buf); } @@ -49,29 +49,26 @@ static int print_info(void) printf("App group count : %d\n", group_cnt); printf("\n"); - if(group_cnt == 0){ + if (group_cnt == 0) { printf("No app groups\n"); goto FINISH; } - for(group_num = 0; group_num < group_cnt; group_num++){ + for (group_num = 0; group_num < group_cnt; group_num++) { aul_app_group_get_group_pids(leader_pids[group_num], &member_cnt, &member_pids); printf("< Group : %d >\n", group_num + 1); printf("member cnt : %d\n", member_cnt); printf("\n"); - for(member_num = 0; member_num < member_cnt; member_num++){ + for (member_num = 0; member_num < member_cnt; member_num++) { ret = aul_app_get_appid_bypid(member_pids[member_num], appid_buf, sizeof(appid_buf) - 1); - - if(ret != AUL_R_OK){ + if (ret != AUL_R_OK) appid_buf[0] = '\0'; - } ret = aul_app_get_pkgid_bypid(member_pids[member_num], pkgid_buf, sizeof(pkgid_buf) - 1); - if(ret != AUL_R_OK){ + if (ret != AUL_R_OK) pkgid_buf[0] = '\0'; - } win_id = aul_app_group_get_window(member_pids[member_num]); fg = aul_app_group_get_fg_flag(member_pids[member_num]); @@ -95,11 +92,9 @@ static int print_info(void) } FINISH: - - if(leader_pids != NULL) + if (leader_pids != NULL) free(leader_pids); - - if(leader_pids != NULL) + if (leader_pids != NULL) free(member_pids); return 0; |