Don't update running list and running history for invalid app
authorChengwei Yang <chengwei.yang@intel.com>
Tue, 15 Jan 2013 05:00:11 +0000 (13:00 +0800)
committerChengwei Yang <chengwei.yang@intel.com>
Wed, 16 Jan 2013 02:50:17 +0000 (10:50 +0800)
Currently, the app-checker check app launch privilege after the real
launch, and then if it has no privilege to launch, it will be killed by
app-checker immediately. However, seems this isn't a good design because
use may notice a UI blink.

This patch doesn't try to resolve the above issue but another thing, it
don't add the invalid app into running list and running history list.

Change-Id: Ie91f3f41849ef9d1d4551e7bb24810c9dd7fa4c0
Signed-off-by: Chengwei Yang <chengwei.yang@intel.com>
am_daemon/amd_launch.c
am_daemon/amd_request.c
packaging/aul.spec

index b867603..7f90dc6 100755 (executable)
@@ -564,7 +564,8 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, int fd)
 
        if(pid > 0) {
                //_status_add_app_info_list(appid, app_path, pid);
-               ac_server_check_launch_privilege(appid, appinfo_get_value(ai, AIT_TYPE), pid);
+               ret = ac_server_check_launch_privilege(appid, appinfo_get_value(ai, AIT_TYPE), pid);
+               return ret != AC_R_ERROR ? pid : -1;
        }
 
        return pid;
index 7a7b119..8224599 100755 (executable)
@@ -287,6 +287,7 @@ static gboolean __request_handler(gpointer data)
        struct ucred cr;
        int *status;
        int ret = -1;
+       int free_pkt = 1;
        char *appid;
        char *app_path;
        char *tmp_pid;
@@ -308,19 +309,17 @@ static gboolean __request_handler(gpointer data)
                        appid = (char *)bundle_get_val(kb, AUL_K_PKG_NAME);
                        ret = _start_app(appid, kb, pkt->cmd, cr.pid, clifd);
 
-                       item = calloc(1, sizeof(item_pkt_t));
-                       item->pid = ret;
-                       strncpy(item->appid, appid, 511);
-
                        if (kb != NULL)
                                bundle_free(kb), kb = NULL;
 
                        if(ret > 0) {
+                               item = calloc(1, sizeof(item_pkt_t));
+                               item->pid = ret;
+                               strncpy(item->appid, appid, 511);
+                               free_pkt = 0;
+
                                g_timeout_add(1000, __add_history_handler, pkt);
                                g_timeout_add(1200, __add_item_running_list, item);
-                       } else {
-                               free(pkt);
-                               free(item);
                        }
                        break;
                case APP_RESULT:
@@ -328,7 +327,6 @@ static gboolean __request_handler(gpointer data)
                        kb = bundle_decode(pkt->data, pkt->len);
                        ret = __foward_cmd(pkt->cmd, kb, cr.pid);
                        __real_send(clifd, ret);
-                       free(pkt);
                        break;
                case APP_TERM_BY_PID:
                case APP_RESUME_BY_PID:
@@ -337,11 +335,9 @@ static gboolean __request_handler(gpointer data)
                        appid = (char *)bundle_get_val(kb, AUL_K_PKG_NAME);
                        ret = __app_process_by_pid(pkt->cmd, appid, &cr);
                        __real_send(clifd, ret);
-                       free(pkt);
                        break;
                case APP_RUNNING_INFO:
                        _status_send_running_appinfo_v2(clifd);
-                       free(pkt);
                        break;
                case APP_IS_RUNNING:
                        appid = malloc(MAX_PACKAGE_STR_SIZE);
@@ -349,31 +345,26 @@ static gboolean __request_handler(gpointer data)
                        ret = _status_app_is_running_v2(appid);
                        _D("APP_IS_RUNNING : %s : %d",appid, ret);
                        __send_result_to_client(clifd, ret);
-                       free(pkt);
                        free(appid);
                        break;
                case APP_KEY_RESERVE:
                        ret = _register_key_event(cr.pid);
                        __send_result_to_client(clifd, ret);
-                       free(pkt);
                        break;
                case APP_KEY_RELEASE:
                        ret = _unregister_key_event(cr.pid);
                        __send_result_to_client(clifd, ret);
-                       free(pkt);
                        break;
                case APP_STATUS_UPDATE:
                        status = (int *)pkt->data;
                        ret = _status_update_app_info_list(cr.pid, *status);
                        __send_result_to_client(clifd, ret);
-                       free(pkt);
                        break;
                case APP_RELEASED:
                        appid = malloc(MAX_PACKAGE_STR_SIZE);
                        strncpy(appid, (const char*)pkt->data, MAX_PACKAGE_STR_SIZE-1);
                        ret = __release_srv(appid);
                        __send_result_to_client(clifd, ret);
-                       free(pkt);
                        free(appid);
                        break;
                case APP_RUNNING_LIST_UPDATE:
@@ -385,11 +376,14 @@ static gboolean __request_handler(gpointer data)
                          ret = _status_add_app_info_list(appid, app_path, pid);*/
                        ret = 0;
                        __send_result_to_client(clifd, ret);
-                       free(pkt);
                        break;
                default:
                        _E("no support packet");
        }
+
+       if (free_pkt)
+               free(pkt);
+
        if (kb != NULL)
                bundle_free(kb), kb = NULL;
 
index 40faa89..6c95aa3 100644 (file)
@@ -1,6 +1,6 @@
 Name:       aul
 Summary:    App utility library
-Version:    0.0.234
+Version:    0.0.235
 Release:    1
 Group:      System/Libraries
 License:    Apache License, Version 2.0