Fix use pkgmgr_appinfo_get_usr_list 82/26482/2 submit/tizen/20140826.082542 submit/tizen_ivi/20140827.000000 submit/tizen_ivi/20140828.000000 submit/tizen_ivi/20140829.000000
authorSabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
Mon, 25 Aug 2014 06:31:16 +0000 (08:31 +0200)
committerSabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
Mon, 25 Aug 2014 15:58:03 +0000 (17:58 +0200)
Change-Id: Iea8111f3cb57f70412caf4539eb64697a50625c0
Signed-off-by: Sabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
client/include/package-manager.h
client/src/pkgmgr.c
tool/pkg_cmd.c
tool/pkg_info.c

index 78de658..27adf63 100755 (executable)
@@ -701,7 +701,7 @@ int pkgmgr_info_free(pkgmgr_info * pkg_info);
  * @return     0 if success, error code(<0) if fail\n
 */
 int pkgmgr_pkginfo_get_list(pkgmgr_info_pkg_list_cb pkg_list_cb, void *user_data);
-
+int pkgmgr_pkginfo_get_usr_list(pkgmgr_info_pkg_list_cb pkg_list_cb, void *user_data, uid_t uid);
 /**
  * @brief      This API  get package info entry from db
  *
@@ -939,7 +939,8 @@ int pkgmgr_pkginfo_get_installed_time(pkgmgr_pkginfo_h handle, int *installed_ti
 */
 int pkgmgr_appinfo_get_list(pkgmgr_pkginfo_h handle, pkgmgr_app_component component,
                                                        pkgmgr_info_app_list_cb app_func, void *user_data);
-
+int pkgmgr_appinfo_get_usr_list(pkgmgr_pkginfo_h handle, pkgmgr_app_component component,
+                                                       pkgmgr_info_app_list_cb app_func, void *user_data, uid_t uid);
 /**
  * @brief      This API gets list of category for ui-application/service application.
  *
index 553ed04..87c0bfd 100755 (executable)
@@ -526,7 +526,6 @@ static char *__get_app_info_from_db_by_apppath(const char *apppath, uid_t uid)
        }
        if(uid != GLOBAL_USER)
                ail_filter_list_usr_appinfo_foreach(filter, __appinfo_cb, &caller_appid,uid);
-
        else
                ail_filter_list_appinfo_foreach(filter, __appinfo_cb, &caller_appid);   
 
@@ -1693,15 +1692,24 @@ API int pkgmgr_client_usr_uninstall(pkgmgr_client *pc, const char *pkg_type,
        tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_pkginfo fail");
        tryvm_if(handle == NULL, ret = PKGMGR_R_EINVAL, "Pkgid(%s) can not find in installed pkg DB! \n", pkgid);
 
-       /*check running app , terminate app if it is running*/
-       ret = pkgmgr_appinfo_get_list(handle, PM_UI_APP, __app_list_cb, NULL);
-       tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_UI_APP fail");
+  if (uid != GLOBAL_USER) {
+         /*check running app , terminate app if it is running*/
+         ret = pkgmgr_appinfo_get_usr_list(handle, PM_UI_APP, __app_list_cb, NULL, uid);
+         tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_UI_APP fail");
 
-       /*check running app , terminate app if it is running*/
-       ret = pkgmgr_appinfo_get_list(handle, PM_SVC_APP, __app_list_cb, NULL);
-       tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_SVC_APP fail");
+         /*check running app , terminate app if it is running*/
+         ret = pkgmgr_appinfo_get_usr_list(handle, PM_SVC_APP, __app_list_cb, NULL, uid);
+         tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_SVC_APP fail");
+  } else {
+         /*check running app , terminate app if it is running*/
+         ret = pkgmgr_appinfo_get_list(handle, PM_UI_APP, __app_list_cb, NULL);
+         tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_UI_APP fail");
 
-       /*check type    */
+         /*check running app , terminate app if it is running*/
+         ret = pkgmgr_appinfo_get_list(handle, PM_SVC_APP, __app_list_cb, NULL);
+         tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_SVC_APP fail"); 
+       }
+  /*check type */
        ret = pkgmgr_pkginfo_get_type(handle, &pkgtype);
        tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_type fail");
        tryvm_if(pkgtype == NULL, ret = PKGMGR_R_ERROR, "pkgtype is NULL");
@@ -2197,20 +2205,32 @@ API int pkgmgr_client_move_usr_pkg(pkgmgr_client *pc, const char *pkg_type,
        retv_if(pkgid == NULL, PKGMGR_R_EINVAL);
 
        pkgmgr_pkginfo_h handle;
-       ret = pkgmgr_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
+  if (uid != GLOBAL_USER)
+         ret = pkgmgr_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
+  else
+         ret = pkgmgr_pkginfo_get_pkginfo(pkgid, &handle);
 
        /*check package id      */
        tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_pkginfo fail");
        tryvm_if(handle == NULL, ret = PKGMGR_R_EINVAL, "Pkgid(%s) can not find in installed pkg DB! \n", pkgid);
 
-       /*check running app , terminate app if it is running*/
-       ret = pkgmgr_appinfo_get_list(handle, PM_UI_APP, __app_list_cb, NULL);
-       tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_UI_APP fail");
-
-       /*check running app , terminate app if it is running*/
-       ret = pkgmgr_appinfo_get_list(handle, PM_SVC_APP, __app_list_cb, NULL);
-       tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_SVC_APP fail");
-
+  if (uid != GLOBAL_USER) {
+         /*check running app , terminate app if it is running*/
+         ret = pkgmgr_appinfo_get_usr_list(handle, PM_UI_APP, __app_list_cb, NULL, uid);
+         tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_UI_APP fail");
+
+    /*check running app , terminate app if it is running*/
+         ret = pkgmgr_appinfo_get_usr_list(handle, PM_SVC_APP, __app_list_cb, NULL, uid);
+         tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_SVC_APP fail");
+
+  } else {
+    /*check running app , terminate app if it is running*/
+         ret = pkgmgr_appinfo_get_list(handle, PM_UI_APP, __app_list_cb, NULL);
+         tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_UI_APP fail");
+    /*check running app , terminate app if it is running*/
+         ret = pkgmgr_appinfo_get_list(handle, PM_SVC_APP, __app_list_cb, NULL);
+         tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_SVC_APP fail");
+  }
        /*check type    */
        ret = pkgmgr_pkginfo_get_type(handle, &pkgtype);
        tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_type fail");
@@ -3375,12 +3395,9 @@ API int pkgmgr_get_pkg_list(pkgmgr_iter_fn iter_fn, void *data, uid_t uid)
        }
        
        if(uid != GLOBAL_USER)
-       {
                ret = ail_filter_count_usr_appinfo(filter, &cnt, uid);
-       }else
-       {
+       else
                ret = ail_filter_count_appinfo(filter, &cnt);
-       }
        if (ret != AIL_ERROR_OK) {
                ail_filter_destroy(filter);
                return PKGMGR_R_ERROR;
@@ -3397,12 +3414,9 @@ API int pkgmgr_get_pkg_list(pkgmgr_iter_fn iter_fn, void *data, uid_t uid)
        udata->data = data;
        
        if(uid != GLOBAL_USER)
-       {
                ail_filter_list_usr_appinfo_foreach(filter, __appinfo_func, udata, uid);
-       }else
-       {
+       else
                ail_filter_list_appinfo_foreach(filter, __appinfo_func, udata);
-       }
        free(udata);
 
        ret = ail_filter_destroy(filter);
@@ -3600,6 +3614,13 @@ API int pkgmgr_pkginfo_get_list(pkgmgr_info_pkg_list_cb pkg_list_cb, void *user_
        return ret;
 }
 
+API int pkgmgr_pkginfo_get_usr_list(pkgmgr_info_pkg_list_cb pkg_list_cb, void *user_data, uid_t uid)
+{
+       int ret = 0;
+       ret = pkgmgrinfo_pkginfo_get_usr_list(pkg_list_cb, user_data, uid);
+       return ret;
+}
+
 API int pkgmgr_pkginfo_get_pkginfo(const char *pkgid, pkgmgr_pkginfo_h *handle)
 {
        int ret = 0;
@@ -3759,6 +3780,14 @@ API int pkgmgr_appinfo_get_list(pkgmgr_pkginfo_h handle, pkgmgr_app_component co
        return ret;
 }
 
+API int pkgmgr_appinfo_get_usr_list(pkgmgr_pkginfo_h handle, pkgmgr_app_component component,
+                                                       pkgmgr_info_app_list_cb app_func, void *user_data, uid_t uid)
+{
+       int ret = 0;
+       ret = pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, uid);
+       return ret;
+}
+
 API int pkgmgr_appinfo_foreach_category(pkgmgr_appinfo_h handle, pkgmgr_info_app_category_list_cb category_func,
                                                        void *user_data)
 {
index 09c1907..08fbd1e 100755 (executable)
@@ -47,7 +47,7 @@
 #define PKG_TOOL_VERSION       "0.1"
 #define APP_INSTALLATION_PATH_RW       tzplatform_getenv(TZ_USER_APP)
 
-static int __process_request();
+static int __process_request(uid_t uid);
 static void __print_usage();
 static int __is_authorized();
 static int __is_app_installed(char *pkgid, uid_t uid);
@@ -273,12 +273,9 @@ static int __is_app_installed(char *pkgid, uid_t uid)
        ail_error_e ret;
        char *str = NULL;
        if (uid != GLOBAL_USER)
-       {
                ret = ail_package_get_usr_appinfo(pkgid, &handle, uid);
-       }else
-       {
+       else
                ret = ail_package_get_appinfo(pkgid, &handle);
-       }
        if (ret != AIL_ERROR_OK) {
                return -1;
        }
@@ -492,7 +489,7 @@ static int __pkgmgr_list_cb (const pkgmgr_pkginfo_h handle, void *user_data)
        return ret;
 }
 
-static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data)
+static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data, uid_t uid)
 {
        int ret = -1;
        int size = 0;
@@ -502,8 +499,10 @@ static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data)
        if(ret < 0) {
                printf("pkgmgr_pkginfo_get_pkgid() failed\n");
        }
-
-       ret = pkgmgr_client_request_service(PM_REQUEST_GET_SIZE, PM_GET_TOTAL_SIZE, (pkgmgr_client *)user_data, NULL, pkgid, NULL, NULL, NULL);
+  if (uid != GLOBAL_USER)
+         ret = pkgmgr_client_usr_request_service(PM_REQUEST_GET_SIZE, PM_GET_TOTAL_SIZE, (pkgmgr_client *)user_data, NULL, pkgid, uid, NULL, NULL, NULL);
+  else
+         ret = pkgmgr_client_request_service(PM_REQUEST_GET_SIZE, PM_GET_TOTAL_SIZE, (pkgmgr_client *)user_data, NULL, pkgid, NULL, NULL, NULL);
        if (ret < 0){
                printf("pkgmgr_client_request_service Failed\n");
                return -1;
@@ -672,8 +671,8 @@ static int __process_request(uid_t uid)
                }
                if(uid != GLOBAL_USER)
                {
-                       ret = pkgmgr_client_clear_user_data(pc, data.pkg_type,
-                                                   data.pkgid, mode);
+                       ret = pkgmgr_client_usr_clear_user_data(pc, data.pkg_type,
+                                                   data.pkgid, mode, uid);
                }else
                {
                        ret = pkgmgr_client_clear_user_data(pc, data.pkg_type,
@@ -702,12 +701,9 @@ static int __process_request(uid_t uid)
                if ( strcmp(data.pkg_type, "app") == 0 ) {
                        if (strlen(data.label) == 0) {
                                if (uid != GLOBAL_USER)
-                               {
                                        ret = pkgmgr_client_usr_activate_app(pc, data.pkgid, uid);
-                               }else
-                               {
+                               else
                                        ret = pkgmgr_client_activate_app(pc, data.pkgid);
-                               }
                                if (ret < 0)
                                        break;
                        } else {
@@ -716,23 +712,17 @@ static int __process_request(uid_t uid)
                                largv[0] = "-l";
                                largv[1] = data.label;
                                if(uid != GLOBAL_USER)
-                               {
                                        ret = pkgmgr_client_usr_activate_appv(pc, data.pkgid, largv, uid);
-                               }else
-                               {
+                               else
                                        ret = pkgmgr_client_activate_appv(pc, data.pkgid, largv);
-                               }
                                if (ret < 0)
                                        break;
                        }
                } else {
                        if (uid != GLOBAL_USER)
-                       {
                                ret = pkgmgr_client_usr_activate(pc, data.pkg_type, data.pkgid, uid);
-                       }else
-                       {
+                       else
                                ret = pkgmgr_client_activate(pc, data.pkg_type, data.pkgid);
-                       }
                        if (ret < 0)
                                break;
                }
@@ -758,22 +748,16 @@ static int __process_request(uid_t uid)
 
                if ( strcmp(data.pkg_type, "app") == 0 ) {
                        if (uid != GLOBAL_USER)
-                       {
                                ret = pkgmgr_client_usr_deactivate_app(pc, data.pkgid, uid);
-                       }else
-                       {
+                       else
                                ret = pkgmgr_client_deactivate_app(pc, data.pkgid);
-                       }
                        if (ret < 0)
                                break;
                }else {
                        if(uid != GLOBAL_USER)
-                       {
                                ret = pkgmgr_client_usr_deactivate(pc, data.pkg_type, data.pkgid, uid);
-                       }else
-                       {
+                       else
                                ret = pkgmgr_client_deactivate(pc, data.pkg_type, data.pkgid);
-                       }
                        if (ret < 0)
                                break;
                }
@@ -808,15 +792,16 @@ static int __process_request(uid_t uid)
                if (data.quiet == 0)
                {
                        if(uid != GLOBAL_USER)
-                       {
                                ret = pkgmgr_client_usr_move(pc, data.pkg_type, data.pkgid,  data.type, mode, uid);
-                       }else
-                       {
+                       else
                                ret = pkgmgr_client_move(pc, data.pkg_type, data.pkgid,  data.type, mode);
-                       }
                }else
-                       ret = pkgmgr_client_request_service(PM_REQUEST_MOVE, data.type, pc, NULL, data.pkgid, NULL, NULL, NULL);
-
+               {
+                       if (uid != GLOBAL_USER)
+                               ret = pkgmgr_client_usr_request_service(PM_REQUEST_MOVE, data.type, pc, NULL, data.pkgid, uid, NULL, NULL, NULL);
+                       else
+                               ret = pkgmgr_client_request_service(PM_REQUEST_MOVE, data.type, pc, NULL, data.pkgid, NULL, NULL, NULL);
+               }
                printf("pkg[%s] move result = %d\n", data.pkgid, ret);
 
                if (ret < 0)
@@ -875,7 +860,10 @@ static int __process_request(uid_t uid)
                }
 
                if (data.request == KILLAPP_REQ) {
-                       ret = pkgmgr_client_request_service(PM_REQUEST_KILL_APP, NULL, pc, NULL, data.pkgid, NULL, NULL, &pid);
+                       if (uid != GLOBAL_USER)
+                               ret = pkgmgr_client_usr_request_service(PM_REQUEST_KILL_APP, NULL, pc, NULL, data.pkgid, uid, NULL, NULL, &pid);
+                       else
+                               ret = pkgmgr_client_request_service(PM_REQUEST_KILL_APP, NULL, pc, NULL, data.pkgid, NULL, NULL, &pid);
                        if (ret < 0){
                                data.result = PKGCMD_ERR_FATAL_ERROR;
                                break;
@@ -886,7 +874,10 @@ static int __process_request(uid_t uid)
                                printf("Pkgid: %s is already Terminated\n", data.pkgid);
 
                } else if (data.request == CHECKAPP_REQ) {
-                       ret = pkgmgr_client_request_service(PM_REQUEST_CHECK_APP, NULL, pc, NULL, data.pkgid, NULL, NULL, &pid);
+                       if (uid != GLOBAL_USER)
+                               ret = pkgmgr_client_usr_request_service(PM_REQUEST_CHECK_APP, NULL, pc, NULL, data.pkgid, uid, NULL, NULL, &pid);
+                       else
+                               ret = pkgmgr_client_request_service(PM_REQUEST_CHECK_APP, NULL, pc, NULL, data.pkgid, NULL, NULL, &pid);
                        if (ret < 0){
                                data.result = PKGCMD_ERR_FATAL_ERROR;
                                break;
@@ -902,7 +893,10 @@ static int __process_request(uid_t uid)
 
        case LIST_REQ:
                if (data.pkg_type[0] == '\0') {
-                       ret = pkgmgr_pkginfo_get_list(__pkgmgr_list_cb, NULL);
+                       if (uid != GLOBAL_USER)
+                               ret = pkgmgr_pkginfo_get_usr_list(__pkgmgr_list_cb, NULL, uid);
+                       else
+                               ret = pkgmgr_pkginfo_get_list(__pkgmgr_list_cb, NULL);
                        if (ret == -1) {
                                printf("Failed to get package list\n");
                                break;
@@ -970,7 +964,10 @@ static int __process_request(uid_t uid)
                break;
 
        case CSC_REQ:
-               ret = pkgmgr_client_request_service(PM_REQUEST_CSC, 0, NULL, NULL, NULL, data.des_path, NULL, (void *)data.pkg_path);
+               if (uid != GLOBAL_USER)
+                       ret = pkgmgr_client_usr_request_service(PM_REQUEST_CSC, 0, NULL, NULL, NULL, uid, data.des_path, NULL, (void *)data.pkg_path);
+               else
+                       ret = pkgmgr_client_request_service(PM_REQUEST_CSC, 0, NULL, NULL, NULL, data.des_path, NULL, (void *)data.pkg_path);
                if (ret < 0)
                        data.result = PKGCMD_ERR_FATAL_ERROR;
                break;
@@ -991,11 +988,16 @@ static int __process_request(uid_t uid)
                }
 
                if (data.type == 9) {
-                       ret = pkgmgrinfo_pkginfo_get_list(__pkg_list_cb, (void *)pc);
+                       if (uid != GLOBAL_USER)
+                               ret = pkgmgrinfo_pkginfo_get_usr_list(__pkg_list_cb, (void *)pc, uid);
+                       else
+                               ret = pkgmgrinfo_pkginfo_get_list(__pkg_list_cb, (void *)pc);
                        break;
                }
-
-               ret = pkgmgr_client_request_service(PM_REQUEST_GET_SIZE, data.type, pc, NULL, data.pkgid, NULL, NULL, NULL);
+               if (uid != GLOBAL_USER)
+                       ret = pkgmgr_client_usr_request_service(PM_REQUEST_GET_SIZE, data.type, pc, NULL, data.pkgid, uid, NULL, NULL, NULL);
+               else
+                       ret = pkgmgr_client_request_service(PM_REQUEST_GET_SIZE, data.type, pc, NULL, data.pkgid, NULL, NULL, NULL);
                if (ret < 0){
                        data.result = PKGCMD_ERR_FATAL_ERROR;
                        break;
index d7c4b7e..45ade42 100755 (executable)
@@ -43,10 +43,10 @@ static int __get_app_list(char *pkgid, uid_t uid);
 static int __get_app_category_list(char *appid);
 static int __get_app_metadata_list(char *appid);
 static int __get_app_control_list(char *appid);
-static int __get_pkg_list(void);
+static int __get_pkg_list(uid_t uid);
 static int __get_installed_app_list(uid_t uid);
-static int __add_app_filter(void);
-static int __add_pkg_filter(void);
+static int __add_app_filter(uid_t uid);
+static int __add_pkg_filter(uid_t uid);
 static int __insert_manifest_in_db(char *manifest, uid_t uid);
 static int __remove_manifest_from_db(char *manifest, uid_t uid);
 static int __set_pkginfo_in_db(char *pkgid, uid_t uid);
@@ -55,7 +55,7 @@ static int __get_certinfo_from_db(char *pkgid);
 static int __del_certinfo_from_db(char *pkgid);
 static int __get_integer_input_data(void);
 char *__get_string_input_data(void);
-static int __pkg_list_cb (const pkgmgr_pkginfo_h handle, void *user_data);
+static int __pkg_list_cb (const pkgmgr_pkginfo_h handle, void *user_data, uid_t uid);
 static int __app_category_list_cb(const char *category_name, void *user_data);
 static int __app_control_list_cb(pkgmgrinfo_appcontrol_h handle, void *user_data);
 static int __app_metadata_list_cb(const char *metadata_name, const char *metadata_value, void *user_data);
@@ -380,7 +380,7 @@ err:
        return ret;
 }
 
-static int __add_app_filter()
+static int __add_app_filter(uid_t uid)
 {
        int ret = 0;
        int choice = -1;
@@ -426,7 +426,10 @@ static int __add_app_filter()
                        printf("App count = %d\n", count);
                        break;
                case 1:
-                       ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, app_func, NULL);
+                       if (uid != GLOBAL_USER)
+                               ret = pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_func, NULL, uid);
+                       else
+                               ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, app_func, NULL);
                        if (ret < 0) {
                                printf("pkgmgrinfo_appinfo_filter_foreach_appinfo() failed\n");
                                ret = -1;
@@ -632,7 +635,7 @@ err:
        return ret;
 }
 
-static int __add_pkg_filter()
+static int __add_pkg_filter(uid_t uid)
 {
        int ret = 0;
        int choice = -1;
@@ -667,7 +670,10 @@ static int __add_pkg_filter()
                choice = __get_integer_input_data();
                switch (choice) {
                case 0:
-                       ret = pkgmgrinfo_pkginfo_filter_count(handle, &count);
+                       if (uid != GLOBAL_USER)
+                               ret = pkgmgrinfo_pkginfo_usr_filter_count(handle, &count, uid);
+                       else
+                               ret = pkgmgrinfo_pkginfo_filter_count(handle, &count);
                        if (ret < 0) {
                                printf("pkgmgrinfo_pkginfo_filter_count() failed\n");
                                ret = -1;
@@ -676,9 +682,12 @@ static int __add_pkg_filter()
                        printf("Package count = %d\n", count);
                        break;
                case 1:
-                       ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkg_list_cb, NULL);
+                       if (uid != GLOBAL_USER)
+                               ret = pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(handle, __pkg_list_cb, NULL, uid);
+                       else
+                               ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkg_list_cb, NULL);
                        if (ret < 0) {
-                               printf("pkgmgrinfo_pkginfo_filter_foreach_pkginfo() failed\n");
+                               printf("pkgmgrinfo_pkginfo_(usr)_filter_foreach_pkginfo() failed\n");
                                ret = -1;
                                goto err;
                        }
@@ -856,7 +865,7 @@ err:
        return ret;
 }
 
-static int __add_arg_filter(char *key, char *value)
+static int __add_arg_filter(char *key, char *value, uid_t uid)
 {
        int ret = 0;
        int choice = -1;
@@ -1010,8 +1019,10 @@ static int __add_arg_filter(char *key, char *value)
                __print_arg_filter_usage();
                goto err;
        }
-
-       ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, __get_app_id, NULL);
+       if (uid != GLOBAL_USER)
+               ret = pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, __get_app_id, NULL, uid);
+       else
+               ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, __get_app_id, NULL);
        if (ret < 0) {
                printf("pkgmgrinfo_appinfo_filter_foreach_appinfo() failed\n");
                ret = -1;
@@ -1116,7 +1127,7 @@ static int __get_certinfo_from_db(char *pkgid)
        return -1;
 }
 
-static int __compare_pkg_certinfo_from_db(char *lhs_pkgid, char *rhs_pkgid)
+static int __compare_pkg_certinfo_from_db(char *lhs_pkgid, char *rhs_pkgid, uid_t uid)
 {
        if (lhs_pkgid == NULL || rhs_pkgid == NULL) {
                printf("pkgid is NULL\n");
@@ -1125,7 +1136,10 @@ static int __compare_pkg_certinfo_from_db(char *lhs_pkgid, char *rhs_pkgid)
 
        int ret = 0;
        pkgmgrinfo_cert_compare_result_type_e result;
-       ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lhs_pkgid, rhs_pkgid, &result);
+       if (uid != GLOBAL_USER)
+               ret = pkgmgrinfo_pkginfo_compare_usr_pkg_cert_info(lhs_pkgid, rhs_pkgid, uid, &result);
+       else
+               ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lhs_pkgid, rhs_pkgid, &result);
        if (ret != PMINFO_R_OK) {
                return -1;
        }
@@ -1344,12 +1358,9 @@ static int __set_pkginfo_in_db(char *pkgid, uid_t uid)
        INSTALL_LOCATION storage = 0;
 
        if(uid != GLOBAL_USER)
-       {
                ret = pkgmgrinfo_create_pkgusrdbinfo(pkgid, uid, &handle);
-       }else
-       {
+       else
                ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
-       }
        if (ret < 0) {
                printf("pkgmgrinfo_create_pkgdbinfo failed\n");
                return -1;
@@ -1560,12 +1571,9 @@ static int __insert_manifest_in_db(char *manifest, uid_t uid)
                return -1;
        }
        if (uid != GLOBAL_USER)
-       {
                ret = pkgmgr_parser_parse_usr_manifest_for_installation(manifest, uid, NULL);
-       }else
-       {
+       else
                ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
-       }
        if (ret < 0) {
                printf("insert in db failed\n");
                return -1;
@@ -1583,12 +1591,9 @@ static int __fota_insert_manifest_in_db(char *manifest, uid_t uid)
                return -1;
        }
        if (uid != GLOBAL_USER)
-       {
                ret = pkgmgr_parser_parse_usr_manifest_for_installation(manifest, uid, NULL);
-       }else
-       {
+       else
                ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
-       }
        if (ret < 0) {
                printf("insert in db failed\n");
                return -1;
@@ -1604,12 +1609,9 @@ static int __remove_manifest_from_db(char *manifest, uid_t uid)
                return -1;
        }
        if (uid != GLOBAL_USER)
-       {
                ret = pkgmgr_parser_parse_usr_manifest_for_uninstallation(manifest, uid, NULL);
-       }else
-       {
+       else
                ret = pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);
-       }
        if (ret < 0) {
                printf("remove from db failed\n");
                return -1;
@@ -1747,7 +1749,7 @@ int app_func(const pkgmgr_appinfo_h handle, void *user_data)
 }
 
 
-static int __pkg_list_cb (const pkgmgr_pkginfo_h handle, void *user_data)
+static int __pkg_list_cb (const pkgmgr_pkginfo_h handle, void *user_data, uid_t uid)
 {
        char *test_data = "test data";
        int ret = -1;
@@ -1783,26 +1785,41 @@ static int __pkg_list_cb (const pkgmgr_pkginfo_h handle, void *user_data)
        printf("pkg_type [%s]\tpkgid [%s]\tversion [%s]\tpreload [%d]\tinstalled_time [%d]\n", pkg_type,
               pkgid, pkg_version, preload, installed_time);
 
-       printf("**List of Ui-Apps**\n");
-       ret = pkgmgr_appinfo_get_list(handle, PM_UI_APP, app_func, (void *)test_data);
-       if (ret < 0) {
-               printf("pkgmgr_get_info_app() failed\n");
-       }
-       printf("**List of Svc-Apps**\n");
-       ret = pkgmgr_appinfo_get_list(handle, PM_SVC_APP, app_func, (void *)test_data);
-       if (ret < 0) {
-               printf("pkgmgr_get_info_app() failed\n");
+       if (uid != GLOBAL_USER) {
+               printf("**List of Ui-Apps**\n");
+               ret = pkgmgr_appinfo_get_usr_list(handle, PM_UI_APP, app_func, (void *)test_data, uid);
+               if (ret < 0) {
+                       printf("pkgmgr_get_info_app() failed\n");
+               }
+               printf("**List of Svc-Apps**\n");
+               ret = pkgmgr_appinfo_get_usr_list(handle, PM_SVC_APP, app_func, (void *)test_data, uid);
+               if (ret < 0) {
+                       printf("pkgmgr_get_info_app() failed\n");
+               }
+       } else {
+               printf("**List of Ui-Apps**\n");
+               ret = pkgmgr_appinfo_get_list(handle, PM_UI_APP, app_func, (void *)test_data);
+               if (ret < 0) {
+                       printf("pkgmgr_get_info_app() failed\n");
+               }
+               printf("**List of Svc-Apps**\n");
+               ret = pkgmgr_appinfo_get_list(handle, PM_SVC_APP, app_func, (void *)test_data);
+               if (ret < 0) {
+                       printf("pkgmgr_get_info_app() failed\n");
+               }
        }
-
        printf("---------------------------------------\n");
 
        return 0;
 }
 
-static int __get_pkg_list()
+static int __get_pkg_list(uid_t uid)
 {
        int ret = -1;
-       ret = pkgmgr_pkginfo_get_list(__pkg_list_cb, NULL);
+       if (uid != GLOBAL_USER)
+               ret = pkgmgr_pkginfo_get_usr_list(__pkg_list_cb, NULL, uid);
+       else
+               ret = pkgmgr_pkginfo_get_list(__pkg_list_cb, NULL);
        if (ret < 0) {
                printf("pkgmgr_pkginfo_get_list() failed\n");
                return -1;
@@ -1836,7 +1853,7 @@ static int __app_metadata_list_cb(const char *metadata_name, const char *metadat
 {
        if (metadata_name && metadata_value) {
                printf("Name: %s\n", metadata_name);
-               printf("Value: %s\n",  metadata_value);
+               printf("Value: %s\n",   metadata_value);
                printf("\n");
        }
        return 0;
@@ -1980,15 +1997,28 @@ static int __get_app_list(char *pkgid, uid_t uid)
                printf("Failed to get handle\n");
                return -1;
        }
-       printf("List of Ui-Apps\n\n");
-       ret = pkgmgr_appinfo_get_list(handle, PM_UI_APP, app_func, (void *)test_data);
-       if (ret < 0) {
-               printf("pkgmgr_appinfo_get_list() failed\n");
-       }
-       printf("List of Svc-Apps\n\n");
-       ret = pkgmgr_appinfo_get_list(handle, PM_SVC_APP, app_func, (void *)test_data);
-       if (ret < 0) {
-               printf("pkgmgr_appinfo_get_list() failed\n");
+       if (uid != GLOBAL_USER) {
+               printf("List of Ui-Apps\n\n");
+               ret = pkgmgr_appinfo_get_usr_list(handle, PM_UI_APP, app_func, (void *)test_data, uid);
+               if (ret < 0) {
+                       printf("pkgmgr_appinfo_get_list() failed\n");
+               }
+               printf("List of Svc-Apps\n\n");
+               ret = pkgmgr_appinfo_get_usr_list(handle, PM_SVC_APP, app_func, (void *)test_data, uid);
+               if (ret < 0) {
+                       printf("pkgmgr_appinfo_get_list() failed\n");
+               }
+       } else {
+               printf("List of Ui-Apps\n\n");
+               ret = pkgmgr_appinfo_get_list(handle, PM_UI_APP, app_func, (void *)test_data);
+               if (ret < 0) {
+                       printf("pkgmgr_appinfo_get_list() failed\n");
+               }
+               printf("List of Svc-Apps\n\n");
+               ret = pkgmgr_appinfo_get_list(handle, PM_SVC_APP, app_func, (void *)test_data);
+               if (ret < 0) {
+                       printf("pkgmgr_appinfo_get_list() failed\n");
+               }
        }
        pkgmgr_pkginfo_destroy_pkginfo(handle);
        return 0;
@@ -2197,7 +2227,7 @@ int main(int argc, char *argv[])
        locale = NULL;
        if (argc == 2) {
                if (strcmp(argv[1], "--listpkg") == 0) {
-                       ret = __get_pkg_list();
+                       ret = __get_pkg_list(getuid());
                        if (ret == -1) {
                                printf("get pkg list failed\n");
                                goto end;
@@ -2205,7 +2235,7 @@ int main(int argc, char *argv[])
                                goto end;
                        }
                } else if (strcmp(argv[1], "--app-flt") == 0) {
-                       ret = __add_app_filter();
+                       ret = __add_app_filter(getuid());
                        if (ret == -1) {
                                printf("Adding app filter failed\n");
                                goto end;
@@ -2213,7 +2243,7 @@ int main(int argc, char *argv[])
                                goto end;
                        }
                } else if (strcmp(argv[1], "--pkg-flt") == 0) {
-                       ret = __add_pkg_filter();
+                       ret = __add_pkg_filter(getuid());
                        if (ret == -1) {
                                printf("Adding pkg filter failed\n");
                                goto end;
@@ -2257,7 +2287,7 @@ int main(int argc, char *argv[])
                        }
                        goto end;
                } else if (strcmp(argv[1], "--cmp-pkgcert") == 0) {
-                       ret = __compare_pkg_certinfo_from_db(argv[2], argv[3]);
+                       ret = __compare_pkg_certinfo_from_db(argv[2], argv[3], getuid());
                        if (ret == -1) {
                                printf("compare certinfo from db failed\n");
                                goto end;
@@ -2271,7 +2301,7 @@ int main(int argc, char *argv[])
                        }
                        goto end;
                } else if (strcmp(argv[1], "--arg-flt") == 0) {
-                       ret = __add_arg_filter(argv[2], argv[3]);
+                       ret = __add_arg_filter(argv[2], argv[3], getuid());
                        if (ret == -1) {
                                printf("compare certinfo from db failed\n");
                                goto end;