Refactoring code (use the call of _usr_ function) 27/26927/1
authorSabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
Mon, 1 Sep 2014 14:13:23 +0000 (16:13 +0200)
committerSabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
Mon, 1 Sep 2014 14:14:13 +0000 (16:14 +0200)
Change-Id: I5a827de69caf5e95504a545e9d64229cac2bcb0a
Signed-off-by: Sabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
src/pkgmgr-info.c

index c64c0c0..23c20bc 100755 (executable)
@@ -2921,156 +2921,10 @@ err:
 
 API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
 {
-       retvm_if(pkg_list_cb == NULL, PMINFO_R_EINVAL, "callback function is NULL\n");
-       char *error_message = NULL;
-       int ret = PMINFO_R_OK;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       char *syslocale = NULL;
-       char *locale = NULL;
-       pkgmgr_pkginfo_x *pkginfo = NULL;
-       label_x *tmp1 = NULL;
-       icon_x *tmp2 = NULL;
-       description_x *tmp3 = NULL;
-       author_x *tmp4 = NULL;
-       privilege_x *tmp5 = NULL;
-
-       syslocale = vconf_get_str(VCONFKEY_LANGSET);
-       if (syslocale == NULL) {
-               _LOGE("current locale is NULL\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-       locale = __convert_system_locale_to_manifest_locale(syslocale);
-       if (locale == NULL) {
-               _LOGE("manifest locale is NULL\n");
-               ret = PMINFO_R_EINVAL;
-               goto err;
-       }
-
-       ret = __open_manifest_db(GLOBAL_USER);
-       if (ret == -1) {
-               _LOGE("Fail to open manifest DB\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-       pkgmgr_pkginfo_x *tmphead = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       pkgmgr_pkginfo_x *node = NULL;
-       pkgmgr_pkginfo_x *temp_node = NULL;
-
-       snprintf(query, MAX_QUERY_LEN, "select * from package_info");
-       if (SQLITE_OK !=
-           sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)tmphead, &error_message)) {
-               _LOGE("Don't execute query = %s error message = %s\n", query,
-                      error_message);
-               sqlite3_free(error_message);
-               sqlite3_close(manifest_db);
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-
-       LISTHEAD(tmphead, node);
-
-       for(node = node->next; node ; node = node->next) {
-               pkginfo = node;
-               pkginfo->locale = strdup(locale);
-               pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
-               if (pkginfo->manifest_info->privileges == NULL) {
-                       _LOGE("Failed to allocate memory for privileges info\n");
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-               /*populate manifest_info from DB*/
-               snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
-               ret = __exec_pkginfo_query(query, (void *)pkginfo);
-               if (ret == -1) {
-                       _LOGE("Package Info DB Information retrieval failed\n");
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               /*populate privilege_info from DB*/
-               snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkginfo->manifest_info->package);
-               ret = __exec_pkginfo_query(query, (void *)pkginfo);
-               if (ret == -1) {
-                       _LOGE("Package Privilege Info DB Information retrieval failed\n");
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
-                       " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
-               ret = __exec_pkginfo_query(query, (void *)pkginfo);
-               if (ret == -1) {
-                       _LOGE("Package Info DB Information retrieval failed\n");
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-               /*Also store the values corresponding to default locales*/
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
-                       " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
-               ret = __exec_pkginfo_query(query, (void *)pkginfo);
-               if (ret == -1) {
-                       _LOGE("Package Info DB Information retrieval failed\n");
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-               if (pkginfo->manifest_info->label) {
-                       LISTHEAD(pkginfo->manifest_info->label, tmp1);
-                       pkginfo->manifest_info->label = tmp1;
-               }
-               if (pkginfo->manifest_info->icon) {
-                       LISTHEAD(pkginfo->manifest_info->icon, tmp2);
-                       pkginfo->manifest_info->icon = tmp2;
-               }
-               if (pkginfo->manifest_info->description) {
-                       LISTHEAD(pkginfo->manifest_info->description, tmp3);
-                       pkginfo->manifest_info->description = tmp3;
-               }
-               if (pkginfo->manifest_info->author) {
-                       LISTHEAD(pkginfo->manifest_info->author, tmp4);
-                       pkginfo->manifest_info->author = tmp4;
-               }
-               if (pkginfo->manifest_info->privileges->privilege) {
-                       LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
-                       pkginfo->manifest_info->privileges->privilege = tmp5;
-               }
-       }
-
-       LISTHEAD(tmphead, node);
-
-       for(node = node->next; node ; node = node->next) {
-               pkginfo = node;
-               ret = pkg_list_cb( (void *)pkginfo, user_data);
-               if(ret < 0)
-                       break;
-       }
-
-       ret = PMINFO_R_OK;
-
-err:
-       sqlite3_close(manifest_db);
-       if (syslocale) {
-               free(syslocale);
-               syslocale = NULL;
-       }
-       if (locale) {
-               free(locale);
-               locale = NULL;
-       }
-       LISTHEAD(tmphead, node);
-       temp_node = node->next;
-       node = temp_node;
-       while (node) {
-               temp_node = node->next;
-               __cleanup_pkginfo(node);
-               node = temp_node;
-       }
-       __cleanup_pkginfo(tmphead);
-       return ret;
+       return pkgmgrinfo_pkginfo_get_usr_list(pkg_list_cb, user_data, GLOBAL_USER);
 }
 
-API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle)
+API int pkgmgrinfo_pkginfo_get_usr_pkginfo(const char *pkgid, uid_t uid, pkgmgrinfo_pkginfo_h *handle)
 {
        retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n");
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
@@ -3088,8 +2942,8 @@ API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *
        sqlite3 *pkginfo_db = NULL;
 
        /*validate pkgid*/
-       ret = db_util_open_with_options(getUserPkgParserDBPath(), &pkginfo_db, SQLITE_OPEN_READONLY, NULL);
-       retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPath());
+       ret = db_util_open_with_options(getUserPkgParserDBPathUID(uid), &pkginfo_db, SQLITE_OPEN_READONLY, NULL);
+       retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPathUID(uid));
 
        /*check pkgid exist on db*/
        snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_info where package='%s')", pkgid);
@@ -3182,183 +3036,75 @@ catch:
        return ret;
 }
 
-API int pkgmgrinfo_pkginfo_get_usr_pkginfo(const char *pkgid, uid_t uid, pkgmgrinfo_pkginfo_h *handle)
+API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle)
 {
-       retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n");
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-       pkgmgr_pkginfo_x *pkginfo = NULL;
-       int ret = PMINFO_R_OK;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       char *syslocale = NULL;
-       char *locale = NULL;
-       int exist = 0;
-       label_x *tmp1 = NULL;
-       icon_x *tmp2 = NULL;
-       description_x *tmp3 = NULL;
-       author_x *tmp4 = NULL;
-       privilege_x *tmp5 = NULL;
-       sqlite3 *pkginfo_db = NULL;
-
-       /*validate pkgid*/
-       ret = db_util_open_with_options(getUserPkgParserDBPathUID(uid), &pkginfo_db, SQLITE_OPEN_READONLY, NULL);
-       retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPathUID(uid));
-
-       /*check pkgid exist on db*/
-       snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_info where package='%s')", pkgid);
-       ret = __exec_db_query(pkginfo_db, query, __validate_cb, (void *)&exist);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec[%s] fail", pkgid);
-       tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "pkgid[%s] not found in DB", pkgid);
+       return pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, GLOBAL_USER, handle);
+}
 
-       /*get system locale*/
-       syslocale = vconf_get_str(VCONFKEY_LANGSET);
-       tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
+API int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_name)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+       retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+       if (info->manifest_info->package)
+               *pkg_name = (char *)info->manifest_info->package;
+       else
+               return PMINFO_R_ERROR;
 
-       /*get locale on db*/
-       locale = __convert_system_locale_to_manifest_locale(syslocale);
-       tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
+       return PMINFO_R_OK;
+}
 
-       pkginfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       tryvm_if(pkginfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for pkginfo");
+API int pkgmgrinfo_pkginfo_get_pkgid(pkgmgrinfo_pkginfo_h handle, char **pkgid)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+       retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+       if (info->manifest_info->package)
+               *pkgid = (char *)info->manifest_info->package;
+       else
+               return PMINFO_R_ERROR;
 
-       pkginfo->locale = strdup(locale);
+       return PMINFO_R_OK;
+}
 
-       pkginfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
-       tryvm_if(pkginfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for manifest info");
+API int pkgmgrinfo_pkginfo_get_type(pkgmgrinfo_pkginfo_h handle, char **type)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+       retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+       if (info->manifest_info->type)
+               *type = (char *)info->manifest_info->type;
+       else
+               *type = pkgtype;
+       return PMINFO_R_OK;
+}
 
-       pkginfo->manifest_info->package = strdup(pkgid);
-       pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
-       tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info");
+API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **version)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+       retvm_if(version == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+       *version = (char *)info->manifest_info->version;
+       return PMINFO_R_OK;
+}
 
-       /*populate manifest_info from DB*/
-       snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkgid);
-       ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
-
-       memset(query, '\0', MAX_QUERY_LEN);
-       /*populate privilege_info from DB*/
-       snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkgid);
-       ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Privilege Info DB Information retrieval failed");
-
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
-               " package='%s' and package_locale='%s'", pkgid, locale);
-       ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
-
-       /*Also store the values corresponding to default locales*/
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
-               " package='%s' and package_locale='%s'", pkgid, DEFAULT_LOCALE);
-       ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
-
-       if (pkginfo->manifest_info->label) {
-               LISTHEAD(pkginfo->manifest_info->label, tmp1);
-               pkginfo->manifest_info->label = tmp1;
-       }
-       if (pkginfo->manifest_info->icon) {
-               LISTHEAD(pkginfo->manifest_info->icon, tmp2);
-               pkginfo->manifest_info->icon = tmp2;
-       }
-       if (pkginfo->manifest_info->description) {
-               LISTHEAD(pkginfo->manifest_info->description, tmp3);
-               pkginfo->manifest_info->description = tmp3;
-       }
-       if (pkginfo->manifest_info->author) {
-               LISTHEAD(pkginfo->manifest_info->author, tmp4);
-               pkginfo->manifest_info->author = tmp4;
-       }
-       if (pkginfo->manifest_info->privileges->privilege) {
-               LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
-               pkginfo->manifest_info->privileges->privilege = tmp5;
-       }
-
-catch:
-       if (ret == PMINFO_R_OK)
-               *handle = (void*)pkginfo;
-       else {
-               *handle = NULL;
-               __cleanup_pkginfo(pkginfo);
-       }
-       sqlite3_close(pkginfo_db);
-
-       if (syslocale) {
-               free(syslocale);
-               syslocale = NULL;
-       }
-       if (locale) {
-               free(locale);
-               locale = NULL;
-       }
-       return ret;
-}
-
-
-API int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_name)
-{
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
-       retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-       if (info->manifest_info->package)
-               *pkg_name = (char *)info->manifest_info->package;
-       else
-               return PMINFO_R_ERROR;
-
-       return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_pkgid(pkgmgrinfo_pkginfo_h handle, char **pkgid)
-{
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
-       retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-       if (info->manifest_info->package)
-               *pkgid = (char *)info->manifest_info->package;
-       else
-               return PMINFO_R_ERROR;
-
-       return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_type(pkgmgrinfo_pkginfo_h handle, char **type)
-{
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
-       retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-       if (info->manifest_info->type)
-               *type = (char *)info->manifest_info->type;
-       else
-               *type = pkgtype;
-       return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **version)
-{
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
-       retvm_if(version == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-       *version = (char *)info->manifest_info->version;
-       return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location)
-{
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
-       retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-       char *val = NULL;
-       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-       val = (char *)info->manifest_info->installlocation;
-       if (val) {
-               if (strcmp(val, "internal-only") == 0)
-                       *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
-               else if (strcmp(val, "prefer-external") == 0)
-                       *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
-               else
-                       *location = PMINFO_INSTALL_LOCATION_AUTO;
-       }
-       return PMINFO_R_OK;
-}
+API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+       retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+       char *val = NULL;
+       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+       val = (char *)info->manifest_info->installlocation;
+       if (val) {
+               if (strcmp(val, "internal-only") == 0)
+                       *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
+               else if (strcmp(val, "prefer-external") == 0)
+                       *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
+               else
+                       *location = PMINFO_INSTALL_LOCATION_AUTO;
+       }
+       return PMINFO_R_OK;
+}
 
 API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *size)
 {
@@ -3877,106 +3623,6 @@ API int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path
        return PMINFO_R_OK;
 }
 
-API int pkgmgrinfo_pkginfo_compare_pkg_cert_info(const char *lhs_package_id, const char *rhs_package_id, pkgmgrinfo_cert_compare_result_type_e *compare_result)
-{
-       retvm_if(lhs_package_id == NULL, PMINFO_R_EINVAL, "lhs package ID is NULL");
-       retvm_if(rhs_package_id == NULL, PMINFO_R_EINVAL, "rhs package ID is NULL");
-       retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
-
-       int ret = PMINFO_R_OK;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       char *error_message = NULL;
-       pkgmgr_cert_x *info= NULL;
-       int lcert = 0;
-       int rcert = 0;
-       int exist = -1;
-       *compare_result = PMINFO_CERT_COMPARE_ERROR;
-       info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
-       retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
-
-       ret = db_util_open_with_options(getUserPkgCertDBPath(), &cert_db,
-                                       SQLITE_OPEN_READWRITE, NULL);
-       if (ret != SQLITE_OK) {
-               _LOGE("connect db [%s] failed!\n", getUserPkgCertDBPath());
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-       _check_create_Cert_db(cert_db);
-       snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", lhs_package_id);
-       if (SQLITE_OK !=
-           sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
-               _LOGE("Don't execute query = %s error message = %s\n", query,
-                      error_message);
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-
-       if (exist == 0) {
-               lcert = 0;
-       } else {
-               snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", lhs_package_id);
-               if (SQLITE_OK !=
-                       sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
-                       _LOGE("Don't execute query = %s error message = %s\n", query,
-                                  error_message);
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-               lcert = info->cert_id;
-       }
-
-       snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", rhs_package_id);
-       if (SQLITE_OK !=
-               sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
-               _LOGE("Don't execute query = %s error message = %s\n", query,
-                          error_message);
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-
-       if (exist == 0) {
-               rcert = 0;
-       } else {
-               snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", rhs_package_id);
-               if (SQLITE_OK !=
-                       sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
-                       _LOGE("Don't execute query = %s error message = %s\n", query,
-                                  error_message);
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-               rcert = info->cert_id;
-       }
-
-       if ((lcert == 0) || (rcert == 0))
-       {
-               if ((lcert == 0) && (rcert == 0))
-                       *compare_result = PMINFO_CERT_COMPARE_BOTH_NO_CERT;
-               else if (lcert == 0)
-                       *compare_result = PMINFO_CERT_COMPARE_LHS_NO_CERT;
-               else if (rcert == 0)
-                       *compare_result = PMINFO_CERT_COMPARE_RHS_NO_CERT;
-       } else {
-               if (lcert == rcert)
-                       *compare_result = PMINFO_CERT_COMPARE_MATCH;
-               else
-                       *compare_result = PMINFO_CERT_COMPARE_MISMATCH;
-       }
-
-err:
-       sqlite3_free(error_message);
-       sqlite3_close(cert_db);
-       if (info) {
-               if (info->pkgid) {
-                       free(info->pkgid);
-                       info->pkgid = NULL;
-               }
-               free(info);
-               info = NULL;
-       }
-       return ret;
-}
-
 API int pkgmgrinfo_pkginfo_compare_usr_pkg_cert_info(const char *lhs_package_id, const char *rhs_package_id, uid_t uid, pkgmgrinfo_cert_compare_result_type_e *compare_result)
 {
        retvm_if(lhs_package_id == NULL, PMINFO_R_EINVAL, "lhs package ID is NULL");
@@ -4078,6 +3724,11 @@ err:
        return ret;
 }
 
+API int pkgmgrinfo_pkginfo_compare_pkg_cert_info(const char *lhs_package_id, const char *rhs_package_id, pkgmgrinfo_cert_compare_result_type_e *compare_result)
+{
+       return pkgmgrinfo_pkginfo_compare_usr_pkg_cert_info(lhs_package_id, rhs_package_id, GLOBAL_USER, compare_result);
+}
+
 API int pkgmgrinfo_pkginfo_compare_app_cert_info(const char *lhs_app_id, const char *rhs_app_id, pkgmgrinfo_cert_compare_result_type_e *compare_result)
 {
        retvm_if(lhs_app_id == NULL, PMINFO_R_EINVAL, "lhs app ID is NULL");
@@ -4639,7 +4290,7 @@ API int pkgmgrinfo_pkginfo_filter_add_string(pkgmgrinfo_pkginfo_filter_h handle,
 
 }
 
-API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count)
+API int pkgmgrinfo_pkginfo_usr_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count, uid_t uid)
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
        retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
@@ -4666,7 +4317,7 @@ API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int
                return PMINFO_R_ERROR;
        }
 
-       ret = __open_manifest_db(GLOBAL_USER);
+       ret = __open_manifest_db(uid);
        if (ret == -1) {
                _LOGE("Fail to open manifest DB\n");
                ret = PMINFO_R_ERROR;
@@ -4721,10 +4372,17 @@ err:
        sqlite3_close(manifest_db);
        return ret;
 }
-API int pkgmgrinfo_pkginfo_usr_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count, uid_t uid)
+
+API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count)
+{
+       return pkgmgrinfo_pkginfo_usr_filter_count(handle, count, GLOBAL_USER);
+}
+
+API int pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
+                               pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data, uid_t uid)
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-       retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       retvm_if(pkg_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
        char *syslocale = NULL;
        char *locale = NULL;
        char *condition = NULL;
@@ -4733,6 +4391,14 @@ API int pkgmgrinfo_pkginfo_usr_filter_count(pkgmgrinfo_pkginfo_filter_h handle,
        char where[MAX_QUERY_LEN] = {'\0'};
        GSList *list;
        int ret = 0;
+       label_x *tmp1 = NULL;
+       icon_x *tmp2 = NULL;
+       description_x *tmp3 = NULL;
+       author_x *tmp4 = NULL;
+       privilege_x *tmp5 = NULL;
+       pkgmgr_pkginfo_x *node = NULL;
+       pkgmgr_pkginfo_x *tmphead = NULL;
+       pkgmgr_pkginfo_x *pkginfo = NULL;
 
        pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
        /*Get current locale*/
@@ -4754,100 +4420,8 @@ API int pkgmgrinfo_pkginfo_usr_filter_count(pkgmgrinfo_pkginfo_filter_h handle,
                ret = PMINFO_R_ERROR;
                goto err;
        }
-
        /*Start constructing query*/
-       snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_COUNT_PACKAGE, locale);
-
-       /*Get where clause*/
-       for (list = filter->list; list; list = g_slist_next(list)) {
-               __get_filter_condition(list->data, &condition);
-               if (condition) {
-                       strncat(where, condition, sizeof(where) - strlen(where) -1);
-                       where[sizeof(where) - 1] = '\0';
-                       free(condition);
-                       condition = NULL;
-               }
-               if (g_slist_next(list)) {
-                       strncat(where, " and ", sizeof(where) - strlen(where) - 1);
-                       where[sizeof(where) - 1] = '\0';
-               }
-       }
-       _LOGE("where = %s\n", where);
-       if (strlen(where) > 0) {
-               strncat(query, where, sizeof(query) - strlen(query) - 1);
-               query[sizeof(query) - 1] = '\0';
-       }
-       _LOGE("query = %s\n", query);
-
-       /*Execute Query*/
-       if (SQLITE_OK !=
-           sqlite3_exec(manifest_db, query, __count_cb, (void *)count, &error_message)) {
-               _LOGE("Don't execute query = %s error message = %s\n", query,
-                      error_message);
-               sqlite3_free(error_message);
-               sqlite3_close(manifest_db);
-               ret = PMINFO_R_ERROR;
-               *count = 0;
-               goto err;
-       }
-       ret = PMINFO_R_OK;
-err:
-       if (locale) {
-               free(locale);
-               locale = NULL;
-       }
-       if (syslocale) {
-               free(syslocale);
-               syslocale = NULL;
-       }
-       sqlite3_close(manifest_db);
-       return ret;
-}
-
-API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
-                               pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data)
-{
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-       retvm_if(pkg_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-       char *syslocale = NULL;
-       char *locale = NULL;
-       char *condition = NULL;
-       char *error_message = NULL;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       char where[MAX_QUERY_LEN] = {'\0'};
-       GSList *list;
-       int ret = 0;
-       label_x *tmp1 = NULL;
-       icon_x *tmp2 = NULL;
-       description_x *tmp3 = NULL;
-       author_x *tmp4 = NULL;
-       privilege_x *tmp5 = NULL;
-       pkgmgr_pkginfo_x *node = NULL;
-       pkgmgr_pkginfo_x *tmphead = NULL;
-       pkgmgr_pkginfo_x *pkginfo = NULL;
-
-       pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
-       /*Get current locale*/
-       syslocale = vconf_get_str(VCONFKEY_LANGSET);
-       if (syslocale == NULL) {
-               _LOGE("current locale is NULL\n");
-               return PMINFO_R_ERROR;
-       }
-       locale = __convert_system_locale_to_manifest_locale(syslocale);
-       if (locale == NULL) {
-               _LOGE("manifest locale is NULL\n");
-               free(syslocale);
-               return PMINFO_R_ERROR;
-       }
-
-       ret = __open_manifest_db(GLOBAL_USER);
-       if (ret == -1) {
-               _LOGE("Fail to open manifest DB\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-       /*Start constructing query*/
-       snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_PACKAGE, locale);
+       snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_PACKAGE, locale);
 
        /*Get where clause*/
        for (list = filter->list; list; list = g_slist_next(list)) {
@@ -4969,170 +4543,11 @@ err:
        __cleanup_pkginfo(tmphead);
        return ret;
 }
-API int pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
-                               pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data, uid_t uid)
-{
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-       retvm_if(pkg_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-       char *syslocale = NULL;
-       char *locale = NULL;
-       char *condition = NULL;
-       char *error_message = NULL;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       char where[MAX_QUERY_LEN] = {'\0'};
-       GSList *list;
-       int ret = 0;
-       label_x *tmp1 = NULL;
-       icon_x *tmp2 = NULL;
-       description_x *tmp3 = NULL;
-       author_x *tmp4 = NULL;
-       privilege_x *tmp5 = NULL;
-       pkgmgr_pkginfo_x *node = NULL;
-       pkgmgr_pkginfo_x *tmphead = NULL;
-       pkgmgr_pkginfo_x *pkginfo = NULL;
-
-       pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
-       /*Get current locale*/
-       syslocale = vconf_get_str(VCONFKEY_LANGSET);
-       if (syslocale == NULL) {
-               _LOGE("current locale is NULL\n");
-               return PMINFO_R_ERROR;
-       }
-       locale = __convert_system_locale_to_manifest_locale(syslocale);
-       if (locale == NULL) {
-               _LOGE("manifest locale is NULL\n");
-               free(syslocale);
-               return PMINFO_R_ERROR;
-       }
-
-       ret = __open_manifest_db(uid);
-       if (ret == -1) {
-               _LOGE("Fail to open manifest DB\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-       /*Start constructing query*/
-       snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_PACKAGE, locale);
-
-       /*Get where clause*/
-       for (list = filter->list; list; list = g_slist_next(list)) {
-               __get_filter_condition(list->data, &condition);
-               if (condition) {
-                       strncat(where, condition, sizeof(where) - strlen(where) -1);
-                       where[sizeof(where) - 1] = '\0';
-                       free(condition);
-                       condition = NULL;
-               }
-               if (g_slist_next(list)) {
-                       strncat(where, " and ", sizeof(where) - strlen(where) - 1);
-                       where[sizeof(where) - 1] = '\0';
-               }
-       }
-       _LOGE("where = %s\n", where);
-       if (strlen(where) > 0) {
-               strncat(query, where, sizeof(query) - strlen(query) - 1);
-               query[sizeof(query) - 1] = '\0';
-       }
-       _LOGE("query = %s\n", query);
-       tmphead = calloc(1, sizeof(pkgmgr_pkginfo_x));
-       if (tmphead == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-
-       if (SQLITE_OK !=
-           sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)tmphead, &error_message)) {
-               _LOGE("Don't execute query = %s error message = %s\n", query,
-                      error_message);
-               sqlite3_free(error_message);
-               sqlite3_close(manifest_db);
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-
-       LISTHEAD(tmphead, node);
-       for(node = node->next ; node ; node = node->next) {
-               pkginfo = node;
-               pkginfo->locale = strdup(locale);
-               pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
-               if (pkginfo->manifest_info->privileges == NULL) {
-                       _LOGE("Failed to allocate memory for privileges info\n");
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-
-               /*populate manifest_info from DB*/
-               snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
-               ret = __exec_pkginfo_query(query, (void *)pkginfo);
-               if (ret == -1) {
-                       _LOGE("Package Info DB Information retrieval failed\n");
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
-                       " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
-               ret = __exec_pkginfo_query(query, (void *)pkginfo);
-               if (ret == -1) {
-                       _LOGE("Package Info DB Information retrieval failed\n");
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-               /*Also store the values corresponding to default locales*/
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
-                       " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
-               ret = __exec_pkginfo_query(query, (void *)pkginfo);
-               if (ret == -1) {
-                       _LOGE("Package Info DB Information retrieval failed\n");
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-               if (pkginfo->manifest_info->label) {
-                       LISTHEAD(pkginfo->manifest_info->label, tmp1);
-                       pkginfo->manifest_info->label = tmp1;
-               }
-               if (pkginfo->manifest_info->icon) {
-                       LISTHEAD(pkginfo->manifest_info->icon, tmp2);
-                       pkginfo->manifest_info->icon = tmp2;
-               }
-               if (pkginfo->manifest_info->description) {
-                       LISTHEAD(pkginfo->manifest_info->description, tmp3);
-                       pkginfo->manifest_info->description = tmp3;
-               }
-               if (pkginfo->manifest_info->author) {
-                       LISTHEAD(pkginfo->manifest_info->author, tmp4);
-                       pkginfo->manifest_info->author = tmp4;
-               }
-               if (pkginfo->manifest_info->privileges->privilege) {
-                       LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
-                       pkginfo->manifest_info->privileges->privilege = tmp5;
-               }
-       }
-
-       LISTHEAD(tmphead, node);
-
-       for(node = node->next ; node ; node = node->next) {
-               pkginfo = node;
-               ret = pkg_cb( (void *)pkginfo, user_data);
-               if(ret < 0)
-                       break;
-       }
-       ret = PMINFO_R_OK;
 
-err:
-       if (locale) {
-               free(locale);
-               locale = NULL;
-       }
-       if (syslocale) {
-               free(syslocale);
-               syslocale = NULL;
-       }
-       sqlite3_close(manifest_db);
-       __cleanup_pkginfo(tmphead);
-       return ret;
+API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
+                               pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data)
+{
+       return pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(handle, pkg_cb, user_data, GLOBAL_USER);
 }
 
 API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
@@ -5154,8 +4569,8 @@ API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
        return PMINFO_R_OK;
 }
 
-API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
-                                               pkgmgrinfo_app_list_cb app_func, void *user_data)
+API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
+                                               pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
        retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback pointer is NULL");
@@ -5205,9 +4620,9 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_
                appinfo->app_component = PMINFO_ALL_APP;
 
        /*open db */
-       ret = db_util_open_with_options(getUserPkgParserDBPath(), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
-       tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPath());
-
+       ret = db_util_open_with_options(getUserPkgParserDBPathUID(uid), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
+       tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPathUID(uid));
+
        appinfo->package = strdup(info->manifest_info->package);
        snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
                        "from package_app_info where " \
@@ -5493,810 +4908,190 @@ catch:
        return ret;
 }
 
-API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
-                                               pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
+API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
+                                               pkgmgrinfo_app_list_cb app_func, void *user_data)
 {
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
-       retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback pointer is NULL");
-       retvm_if((component != PMINFO_UI_APP) && (component != PMINFO_SVC_APP) && (component != PMINFO_ALL_APP), PMINFO_R_EINVAL, "Invalid App Component Type");
+       return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, GLOBAL_USER);
+}
+
+API int pkgmgrinfo_appinfo_get_usr_install_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
+{
+       retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
+
+       int ret = PMINFO_R_OK;
+       char query[MAX_QUERY_LEN] = {'\0'};
+       pkgmgr_appinfo_x *appinfo = NULL;
+       uiapplication_x *ptr1 = NULL;
+       serviceapplication_x *ptr2 = NULL;
+       sqlite3 *appinfo_db = NULL;
+
+       /*open db*/
+       ret = db_util_open_with_options(getUserPkgParserDBPathUID(uid), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
+       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPathUID(uid));
+
+       /*calloc pkginfo*/
+       pkgmgr_pkginfo_x *info = NULL;
+       info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
+       tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
+
+       /*calloc manifest_info*/
+       info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
+       tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
+
+       /*calloc appinfo*/
+       appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
+       tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
+
+       snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
+       ret = __exec_db_query(appinfo_db, query, __mini_appinfo_cb, (void *)info);
+       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
+
+       if (info->manifest_info->uiapplication) {
+               LISTHEAD(info->manifest_info->uiapplication, ptr1);
+               info->manifest_info->uiapplication = ptr1;
+       }
+       if (info->manifest_info->serviceapplication) {
+               LISTHEAD(info->manifest_info->serviceapplication, ptr2);
+               info->manifest_info->serviceapplication = ptr2;
+       }
+
+       /*UI Apps*/
+       for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
+       {
+               appinfo->app_component = PMINFO_UI_APP;
+               appinfo->package = strdup(ptr1->package);
+               appinfo->uiapp_info = ptr1;
+
+               ret = app_func((void *)appinfo, user_data);
+               if (ret < 0)
+                       break;
+               free((void *)appinfo->package);
+               appinfo->package = NULL;
+       }
+       /*Service Apps*/
+       for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
+       {
+               appinfo->app_component = PMINFO_SVC_APP;
+               appinfo->package = strdup(ptr2->package);
+               appinfo->svcapp_info = ptr2;
+
+               ret = app_func((void *)appinfo, user_data);
+               if (ret < 0)
+                       break;
+               free((void *)appinfo->package);
+               appinfo->package = NULL;
+       }
+       ret = PMINFO_R_OK;
+
+catch:
+       sqlite3_close(appinfo_db);
+
+       if (appinfo) {
+               free(appinfo);
+               appinfo = NULL;
+       }
+       __cleanup_pkginfo(info);
+       return ret;
+}
+
+API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
+{
+       return pkgmgrinfo_appinfo_get_usr_install_list(app_func, GLOBAL_USER, user_data);
+}
+
+API int pkgmgrinfo_appinfo_get_usr_installed_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
+{
+       retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
 
+       int ret = PMINFO_R_OK;
+       char query[MAX_QUERY_LEN] = {'\0'};
        char *syslocale = NULL;
        char *locale = NULL;
-       int ret = -1;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-       pkgmgr_pkginfo_x *allinfo = NULL;
        pkgmgr_appinfo_x *appinfo = NULL;
-       icon_x *ptr1 = NULL;
-       label_x *ptr2 = NULL;
-       category_x *ptr3 = NULL;
-       metadata_x *ptr4 = NULL;
-       permission_x *ptr5 = NULL;
-       image_x *ptr6 = NULL;
+       uiapplication_x *ptr1 = NULL;
+       serviceapplication_x *ptr2 = NULL;
+       label_x *tmp1 = NULL;
+       icon_x *tmp2 = NULL;
+       category_x *tmp3 = NULL;
+       metadata_x *tmp4 = NULL;
+       permission_x *tmp5 = NULL;
+       image_x *tmp6 = NULL;
        sqlite3 *appinfo_db = NULL;
 
        /*get system locale*/
        syslocale = vconf_get_str(VCONFKEY_LANGSET);
-       retvm_if(syslocale == NULL, PMINFO_R_EINVAL, "current locale is NULL");
+       tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
 
        /*get locale on db*/
        locale = __convert_system_locale_to_manifest_locale(syslocale);
-       tryvm_if(locale == NULL, ret = PMINFO_R_EINVAL, "manifest locale is NULL");
+       tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
 
-       /*calloc allinfo*/
-       allinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       tryvm_if(allinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
+       /*open db*/
+       ret = db_util_open_with_options(getUserPkgParserDBPathUID(uid), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
+       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPathUID(uid));
+
+       /*calloc pkginfo*/
+       pkgmgr_pkginfo_x *info = NULL;
+       info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
+       tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
 
        /*calloc manifest_info*/
-       allinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
-       tryvm_if(allinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
+       info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
+       tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
 
        /*calloc appinfo*/
        appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
-       tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
-
-       /*set component type*/
-       if (component == PMINFO_UI_APP)
-               appinfo->app_component = PMINFO_UI_APP;
-       if (component == PMINFO_SVC_APP)
-               appinfo->app_component = PMINFO_SVC_APP;
-       if (component == PMINFO_ALL_APP)
-               appinfo->app_component = PMINFO_ALL_APP;
+       tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
 
-       /*open db */
-       ret = db_util_open_with_options(getUserPkgParserDBPathUID(uid), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
-       tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPathUID(uid));
+       snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
+       ret = __exec_db_query(appinfo_db, query, __app_list_cb, (void *)info);
+       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
 
-       appinfo->package = strdup(info->manifest_info->package);
-       snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
-                       "from package_app_info where " \
-                       "package='%s' and app_component='%s'",
-                       info->manifest_info->package,
-                       (appinfo->app_component==PMINFO_UI_APP ? "uiapp" : "svcapp"));
+       if (info->manifest_info->uiapplication) {
+               LISTHEAD(info->manifest_info->uiapplication, ptr1);
+               info->manifest_info->uiapplication = ptr1;
+       }
+       if (info->manifest_info->serviceapplication) {
+               LISTHEAD(info->manifest_info->serviceapplication, ptr2);
+               info->manifest_info->serviceapplication = ptr2;
+       }
 
-       switch(component) {
-       case PMINFO_UI_APP:
-               /*Populate ui app info */
-               ret = __exec_db_query(appinfo_db, query, __uiapp_list_cb, (void *)info);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
+       /*UI Apps*/
+       for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
+       {
+               appinfo->locale = strdup(locale);
+               appinfo->app_component = PMINFO_UI_APP;
+               appinfo->package = strdup(ptr1->package);
+               appinfo->uiapp_info = ptr1;
+               snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
+                               "from package_app_info where " \
+                               "app_id='%s'", ptr1->appid);
+               ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
 
-               uiapplication_x *tmp = NULL;
-               if (info->manifest_info->uiapplication) {
-                       LISTHEAD(info->manifest_info->uiapplication, tmp);
-                       info->manifest_info->uiapplication = tmp;
-               }
-               /*Populate localized info for default locales and call callback*/
-               /*If the callback func return < 0 we break and no more call back is called*/
-               while(tmp != NULL)
-               {
-                       appinfo->locale = strdup(locale);
-                       appinfo->uiapp_info = tmp;
-                       if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
-                               if (locale) {
-                                       free(locale);
-                               }
-                               locale = __get_app_locale_by_fallback(appinfo_db, appinfo->uiapp_info->appid, syslocale);
+               if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
+                       if (locale) {
+                               free(locale);
                        }
+                       locale = __get_app_locale_by_fallback(appinfo_db, ptr1->appid, syslocale);
+               }
 
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
-                       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+               memset(query, '\0', MAX_QUERY_LEN);
+               snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
+                               "from package_app_localized_info where " \
+                               "app_id='%s' and app_locale='%s'",
+                               ptr1->appid, locale);
+               ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
 
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, DEFAULT_LOCALE);
-                       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+               memset(query, '\0', MAX_QUERY_LEN);
+               snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
+                               "from package_app_localized_info where " \
+                               "app_id='%s' and app_locale='%s'",
+                               ptr1->appid, DEFAULT_LOCALE);
 
-                       /*store setting notification icon section*/
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
-                       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
-                       
-                       /*store app preview image info*/
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
-                       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
-
-                       if (appinfo->uiapp_info->label) {
-                               LISTHEAD(appinfo->uiapp_info->label, ptr2);
-                               appinfo->uiapp_info->label = ptr2;
-                       }
-                       if (appinfo->uiapp_info->icon) {
-                               LISTHEAD(appinfo->uiapp_info->icon, ptr1);
-                               appinfo->uiapp_info->icon = ptr1;
-                       }
-                       if (appinfo->uiapp_info->category) {
-                               LISTHEAD(appinfo->uiapp_info->category, ptr3);
-                               appinfo->uiapp_info->category = ptr3;
-                       }
-                       if (appinfo->uiapp_info->metadata) {
-                               LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
-                               appinfo->uiapp_info->metadata = ptr4;
-                       }
-                       if (appinfo->uiapp_info->permission) {
-                               LISTHEAD(appinfo->uiapp_info->permission, ptr5);
-                               appinfo->uiapp_info->permission = ptr5;
-                       }
-                       if (appinfo->uiapp_info->image) {
-                               LISTHEAD(appinfo->uiapp_info->image, ptr6);
-                               appinfo->uiapp_info->image = ptr6;
-                       }
-                       ret = app_func((void *)appinfo, user_data);
-                       if (ret < 0)
-                               break;
-                       tmp = tmp->next;
-               }
-               break;
-       case PMINFO_SVC_APP:
-               /*Populate svc app info */
-               ret = __exec_db_query(appinfo_db, query, __svcapp_list_cb, (void *)info);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
-
-               serviceapplication_x *tmp1 = NULL;
-               if (info->manifest_info->serviceapplication) {
-                       LISTHEAD(info->manifest_info->serviceapplication, tmp1);
-                       info->manifest_info->serviceapplication = tmp1;
-               }
-               /*Populate localized info for default locales and call callback*/
-               /*If the callback func return < 0 we break and no more call back is called*/
-               while(tmp1 != NULL)
-               {
-                       appinfo->locale = strdup(locale);
-                       appinfo->svcapp_info = tmp1;
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
-                       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
-
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, DEFAULT_LOCALE);
-                       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
-
-                       if (appinfo->svcapp_info->label) {
-                               LISTHEAD(appinfo->svcapp_info->label, ptr2);
-                               appinfo->svcapp_info->label = ptr2;
-                       }
-                       if (appinfo->svcapp_info->icon) {
-                               LISTHEAD(appinfo->svcapp_info->icon, ptr1);
-                               appinfo->svcapp_info->icon = ptr1;
-                       }
-                       if (appinfo->svcapp_info->category) {
-                               LISTHEAD(appinfo->svcapp_info->category, ptr3);
-                               appinfo->svcapp_info->category = ptr3;
-                       }
-                       if (appinfo->svcapp_info->metadata) {
-                               LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
-                               appinfo->svcapp_info->metadata = ptr4;
-                       }
-                       if (appinfo->svcapp_info->permission) {
-                               LISTHEAD(appinfo->svcapp_info->permission, ptr5);
-                               appinfo->svcapp_info->permission = ptr5;
-                       }
-                       ret = app_func((void *)appinfo, user_data);
-                       if (ret < 0)
-                               break;
-                       tmp1 = tmp1->next;
-               }
-               break;
-       case PMINFO_ALL_APP:
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where package='%s'", info->manifest_info->package);
-
-               /*Populate all app info */
-               ret = __exec_db_query(appinfo_db, query, __allapp_list_cb, (void *)allinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
-
-               /*UI Apps*/
-               appinfo->app_component = PMINFO_UI_APP;
-               uiapplication_x *tmp2 = NULL;
-               if (allinfo->manifest_info->uiapplication) {
-                       LISTHEAD(allinfo->manifest_info->uiapplication, tmp2);
-                       allinfo->manifest_info->uiapplication = tmp2;
-               }
-               /*Populate localized info for default locales and call callback*/
-               /*If the callback func return < 0 we break and no more call back is called*/
-               while(tmp2 != NULL)
-               {
-                       appinfo->locale = strdup(locale);
-                       appinfo->uiapp_info = tmp2;
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
-                       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
-
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, DEFAULT_LOCALE);
-                       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
-
-                       /*store setting notification icon section*/
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
-                       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
-                       
-                       /*store app preview image info*/
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
-                       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
-
-                       if (appinfo->uiapp_info->label) {
-                               LISTHEAD(appinfo->uiapp_info->label, ptr2);
-                               appinfo->uiapp_info->label = ptr2;
-                       }
-                       if (appinfo->uiapp_info->icon) {
-                               LISTHEAD(appinfo->uiapp_info->icon, ptr1);
-                               appinfo->uiapp_info->icon = ptr1;
-                       }
-                       if (appinfo->uiapp_info->category) {
-                               LISTHEAD(appinfo->uiapp_info->category, ptr3);
-                               appinfo->uiapp_info->category = ptr3;
-                       }
-                       if (appinfo->uiapp_info->metadata) {
-                               LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
-                               appinfo->uiapp_info->metadata = ptr4;
-                       }
-                       if (appinfo->uiapp_info->permission) {
-                               LISTHEAD(appinfo->uiapp_info->permission, ptr5);
-                               appinfo->uiapp_info->permission = ptr5;
-                       }
-                       if (appinfo->uiapp_info->image) {
-                               LISTHEAD(appinfo->uiapp_info->image, ptr6);
-                               appinfo->uiapp_info->image = ptr6;
-                       }
-                       ret = app_func((void *)appinfo, user_data);
-                       if (ret < 0)
-                               break;
-                       tmp2 = tmp2->next;
-               }
-
-               /*SVC Apps*/
-               appinfo->app_component = PMINFO_SVC_APP;
-               serviceapplication_x *tmp3 = NULL;
-               if (allinfo->manifest_info->serviceapplication) {
-                       LISTHEAD(allinfo->manifest_info->serviceapplication, tmp3);
-                       allinfo->manifest_info->serviceapplication = tmp3;
-               }
-               /*Populate localized info for default locales and call callback*/
-               /*If the callback func return < 0 we break and no more call back is called*/
-               while(tmp3 != NULL)
-               {
-                       appinfo->locale = strdup(locale);
-                       appinfo->svcapp_info = tmp3;
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
-                       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
-
-                       memset(query, '\0', MAX_QUERY_LEN);
-                       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, DEFAULT_LOCALE);
-                       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
-
-                       if (appinfo->svcapp_info->label) {
-                               LISTHEAD(appinfo->svcapp_info->label, ptr2);
-                               appinfo->svcapp_info->label = ptr2;
-                       }
-                       if (appinfo->svcapp_info->icon) {
-                               LISTHEAD(appinfo->svcapp_info->icon, ptr1);
-                               appinfo->svcapp_info->icon = ptr1;
-                       }
-                       if (appinfo->svcapp_info->category) {
-                               LISTHEAD(appinfo->svcapp_info->category, ptr3);
-                               appinfo->svcapp_info->category = ptr3;
-                       }
-                       if (appinfo->svcapp_info->metadata) {
-                               LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
-                               appinfo->svcapp_info->metadata = ptr4;
-                       }
-                       if (appinfo->svcapp_info->permission) {
-                               LISTHEAD(appinfo->svcapp_info->permission, ptr5);
-                               appinfo->svcapp_info->permission = ptr5;
-                       }
-                       ret = app_func((void *)appinfo, user_data);
-                       if (ret < 0)
-                               break;
-                       tmp3 = tmp3->next;
-               }
-               appinfo->app_component = PMINFO_ALL_APP;
-               break;
-
-       }
-
-       ret = PMINFO_R_OK;
-catch:
-       if (locale) {
-               free(locale);
-               locale = NULL;
-       }
-       if (syslocale) {
-               free(syslocale);
-               syslocale = NULL;
-       }
-       if (appinfo) {
-               if (appinfo->package) {
-                       free((void *)appinfo->package);
-                       appinfo->package = NULL;
-               }
-               free(appinfo);
-               appinfo = NULL;
-       }
-       __cleanup_pkginfo(allinfo);
-
-       sqlite3_close(appinfo_db);
-       return ret;
-}
-
-API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
-{
-       retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
-
-       int ret = PMINFO_R_OK;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       pkgmgr_appinfo_x *appinfo = NULL;
-       uiapplication_x *ptr1 = NULL;
-       serviceapplication_x *ptr2 = NULL;
-       sqlite3 *appinfo_db = NULL;
-
-       /*open db*/
-       ret = db_util_open_with_options(getUserPkgParserDBPath(), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
-       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPath());
-
-       /*calloc pkginfo*/
-       pkgmgr_pkginfo_x *info = NULL;
-       info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
-
-       /*calloc manifest_info*/
-       info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
-       tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
-
-       /*calloc appinfo*/
-       appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
-       tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
-
-       snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
-       ret = __exec_db_query(appinfo_db, query, __mini_appinfo_cb, (void *)info);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
-
-       if (info->manifest_info->uiapplication) {
-               LISTHEAD(info->manifest_info->uiapplication, ptr1);
-               info->manifest_info->uiapplication = ptr1;
-       }
-       if (info->manifest_info->serviceapplication) {
-               LISTHEAD(info->manifest_info->serviceapplication, ptr2);
-               info->manifest_info->serviceapplication = ptr2;
-       }
-
-       /*UI Apps*/
-       for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
-       {
-               appinfo->app_component = PMINFO_UI_APP;
-               appinfo->package = strdup(ptr1->package);
-               appinfo->uiapp_info = ptr1;
-
-               ret = app_func((void *)appinfo, user_data);
-               if (ret < 0)
-                       break;
-               free((void *)appinfo->package);
-               appinfo->package = NULL;
-       }
-       /*Service Apps*/
-       for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
-       {
-               appinfo->app_component = PMINFO_SVC_APP;
-               appinfo->package = strdup(ptr2->package);
-               appinfo->svcapp_info = ptr2;
-
-               ret = app_func((void *)appinfo, user_data);
-               if (ret < 0)
-                       break;
-               free((void *)appinfo->package);
-               appinfo->package = NULL;
-       }
-       ret = PMINFO_R_OK;
-
-catch:
-       sqlite3_close(appinfo_db);
-
-       if (appinfo) {
-               free(appinfo);
-               appinfo = NULL;
-       }
-       __cleanup_pkginfo(info);
-       return ret;
-}
-
-API int pkgmgrinfo_appinfo_get_usr_install_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
-{
-       retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
-
-       int ret = PMINFO_R_OK;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       pkgmgr_appinfo_x *appinfo = NULL;
-       uiapplication_x *ptr1 = NULL;
-       serviceapplication_x *ptr2 = NULL;
-       sqlite3 *appinfo_db = NULL;
-
-       /*open db*/
-       ret = db_util_open_with_options(getUserPkgParserDBPathUID(uid), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
-       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPathUID(uid));
-
-       /*calloc pkginfo*/
-       pkgmgr_pkginfo_x *info = NULL;
-       info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
-
-       /*calloc manifest_info*/
-       info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
-       tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
-
-       /*calloc appinfo*/
-       appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
-       tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
-
-       snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
-       ret = __exec_db_query(appinfo_db, query, __mini_appinfo_cb, (void *)info);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
-
-       if (info->manifest_info->uiapplication) {
-               LISTHEAD(info->manifest_info->uiapplication, ptr1);
-               info->manifest_info->uiapplication = ptr1;
-       }
-       if (info->manifest_info->serviceapplication) {
-               LISTHEAD(info->manifest_info->serviceapplication, ptr2);
-               info->manifest_info->serviceapplication = ptr2;
-       }
-
-       /*UI Apps*/
-       for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
-       {
-               appinfo->app_component = PMINFO_UI_APP;
-               appinfo->package = strdup(ptr1->package);
-               appinfo->uiapp_info = ptr1;
-
-               ret = app_func((void *)appinfo, user_data);
-               if (ret < 0)
-                       break;
-               free((void *)appinfo->package);
-               appinfo->package = NULL;
-       }
-       /*Service Apps*/
-       for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
-       {
-               appinfo->app_component = PMINFO_SVC_APP;
-               appinfo->package = strdup(ptr2->package);
-               appinfo->svcapp_info = ptr2;
-
-               ret = app_func((void *)appinfo, user_data);
-               if (ret < 0)
-                       break;
-               free((void *)appinfo->package);
-               appinfo->package = NULL;
-       }
-       ret = PMINFO_R_OK;
-
-catch:
-       sqlite3_close(appinfo_db);
-
-       if (appinfo) {
-               free(appinfo);
-               appinfo = NULL;
-       }
-       __cleanup_pkginfo(info);
-       return ret;
-}
-
-API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
-{
-       retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
-
-       int ret = PMINFO_R_OK;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       char *syslocale = NULL;
-       char *locale = NULL;
-       pkgmgr_appinfo_x *appinfo = NULL;
-       uiapplication_x *ptr1 = NULL;
-       serviceapplication_x *ptr2 = NULL;
-       label_x *tmp1 = NULL;
-       icon_x *tmp2 = NULL;
-       category_x *tmp3 = NULL;
-       metadata_x *tmp4 = NULL;
-       permission_x *tmp5 = NULL;
-       image_x *tmp6 = NULL;
-       sqlite3 *appinfo_db = NULL;
-
-       /*get system locale*/
-       syslocale = vconf_get_str(VCONFKEY_LANGSET);
-       tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
-
-       /*get locale on db*/
-       locale = __convert_system_locale_to_manifest_locale(syslocale);
-       tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
-
-       /*open db*/
-       ret = db_util_open_with_options(getUserPkgParserDBPath(), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
-       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPath());
-
-       /*calloc pkginfo*/
-       pkgmgr_pkginfo_x *info = NULL;
-       info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
-
-       /*calloc manifest_info*/
-       info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
-       tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
-
-       /*calloc appinfo*/
-       appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
-       tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
-
-       snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
-       ret = __exec_db_query(appinfo_db, query, __app_list_cb, (void *)info);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
-
-       if (info->manifest_info->uiapplication) {
-               LISTHEAD(info->manifest_info->uiapplication, ptr1);
-               info->manifest_info->uiapplication = ptr1;
-       }
-       if (info->manifest_info->serviceapplication) {
-               LISTHEAD(info->manifest_info->serviceapplication, ptr2);
-               info->manifest_info->serviceapplication = ptr2;
-       }
-
-       /*UI Apps*/
-       for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
-       {
-               appinfo->locale = strdup(locale);
-               appinfo->app_component = PMINFO_UI_APP;
-               appinfo->package = strdup(ptr1->package);
-               appinfo->uiapp_info = ptr1;
-               snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
-                               "from package_app_info where " \
-                               "app_id='%s'", ptr1->appid);
-               ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
-
-               if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
-                       if (locale) {
-                               free(locale);
-                       }
-                       locale = __get_app_locale_by_fallback(appinfo_db, ptr1->appid, syslocale);
-               }
-
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
-                               "from package_app_localized_info where " \
-                               "app_id='%s' and app_locale='%s'",
-                               ptr1->appid, locale);
-               ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
-
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
-                               "from package_app_localized_info where " \
-                               "app_id='%s' and app_locale='%s'",
-                               ptr1->appid, DEFAULT_LOCALE);
-
-               ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
-
-               /*store setting notification icon section*/
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", ptr1->appid);
-               ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
-               
-               /*store app preview image info*/
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", ptr1->appid);
-               ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
-
-               if (appinfo->uiapp_info->label) {
-                       LISTHEAD(appinfo->uiapp_info->label, tmp1);
-                       appinfo->uiapp_info->label = tmp1;
-               }
-               if (appinfo->uiapp_info->icon) {
-                       LISTHEAD(appinfo->uiapp_info->icon, tmp2);
-                       appinfo->uiapp_info->icon= tmp2;
-               }
-               if (appinfo->uiapp_info->category) {
-                       LISTHEAD(appinfo->uiapp_info->category, tmp3);
-                       appinfo->uiapp_info->category = tmp3;
-               }
-               if (appinfo->uiapp_info->metadata) {
-                       LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
-                       appinfo->uiapp_info->metadata = tmp4;
-               }
-               if (appinfo->uiapp_info->permission) {
-                       LISTHEAD(appinfo->uiapp_info->permission, tmp5);
-                       appinfo->uiapp_info->permission = tmp5;
-               }
-               if (appinfo->uiapp_info->image) {
-                       LISTHEAD(appinfo->uiapp_info->image, tmp6);
-                       appinfo->uiapp_info->image = tmp6;
-               }
-               ret = app_func((void *)appinfo, user_data);
-               if (ret < 0)
-                       break;
-               free((void *)appinfo->package);
-               appinfo->package = NULL;
-       }
-       /*Service Apps*/
-       for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
-       {
-               appinfo->locale = strdup(locale);
-               appinfo->app_component = PMINFO_SVC_APP;
-               appinfo->package = strdup(ptr2->package);
-               appinfo->svcapp_info = ptr2;
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
-                               "from package_app_info where " \
-                               "app_id='%s'", ptr2->appid);
-               ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
-
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
-                               "from package_app_localized_info where " \
-                               "app_id='%s' and app_locale='%s'",
-                               ptr2->appid, locale);
-               ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
-
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
-                               "from package_app_localized_info where " \
-                               "app_id='%s' and app_locale='%s'",
-                               ptr2->appid, DEFAULT_LOCALE);
-               ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
-
-               if (appinfo->svcapp_info->label) {
-                       LISTHEAD(appinfo->svcapp_info->label, tmp1);
-                       appinfo->svcapp_info->label = tmp1;
-               }
-               if (appinfo->svcapp_info->icon) {
-                       LISTHEAD(appinfo->svcapp_info->icon, tmp2);
-                       appinfo->svcapp_info->icon= tmp2;
-               }
-               if (appinfo->svcapp_info->category) {
-                       LISTHEAD(appinfo->svcapp_info->category, tmp3);
-                       appinfo->svcapp_info->category = tmp3;
-               }
-               if (appinfo->svcapp_info->metadata) {
-                       LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
-                       appinfo->svcapp_info->metadata = tmp4;
-               }
-               if (appinfo->svcapp_info->permission) {
-                       LISTHEAD(appinfo->svcapp_info->permission, tmp5);
-                       appinfo->svcapp_info->permission = tmp5;
-               }
-               ret = app_func((void *)appinfo, user_data);
-               if (ret < 0)
-                       break;
-               free((void *)appinfo->package);
-               appinfo->package = NULL;
-       }
-       ret = PMINFO_R_OK;
-
-catch:
-       if (locale) {
-               free(locale);
-               locale = NULL;
-       }
-       if (syslocale) {
-               free(syslocale);
-               syslocale = NULL;
-       }
-       sqlite3_close(appinfo_db);
-       if (appinfo) {
-               free(appinfo);
-               appinfo = NULL;
-       }
-       __cleanup_pkginfo(info);
-       return ret;
-}
-
-API int pkgmgrinfo_appinfo_get_usr_installed_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
-{
-       retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
-
-       int ret = PMINFO_R_OK;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       char *syslocale = NULL;
-       char *locale = NULL;
-       pkgmgr_appinfo_x *appinfo = NULL;
-       uiapplication_x *ptr1 = NULL;
-       serviceapplication_x *ptr2 = NULL;
-       label_x *tmp1 = NULL;
-       icon_x *tmp2 = NULL;
-       category_x *tmp3 = NULL;
-       metadata_x *tmp4 = NULL;
-       permission_x *tmp5 = NULL;
-       image_x *tmp6 = NULL;
-       sqlite3 *appinfo_db = NULL;
-
-       /*get system locale*/
-       syslocale = vconf_get_str(VCONFKEY_LANGSET);
-       tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
-
-       /*get locale on db*/
-       locale = __convert_system_locale_to_manifest_locale(syslocale);
-       tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
-
-       /*open db*/
-       ret = db_util_open_with_options(getUserPkgParserDBPathUID(uid), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
-       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPathUID(uid));
-
-       /*calloc pkginfo*/
-       pkgmgr_pkginfo_x *info = NULL;
-       info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
-
-       /*calloc manifest_info*/
-       info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
-       tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
-
-       /*calloc appinfo*/
-       appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
-       tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
-
-       snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
-       ret = __exec_db_query(appinfo_db, query, __app_list_cb, (void *)info);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
-
-       if (info->manifest_info->uiapplication) {
-               LISTHEAD(info->manifest_info->uiapplication, ptr1);
-               info->manifest_info->uiapplication = ptr1;
-       }
-       if (info->manifest_info->serviceapplication) {
-               LISTHEAD(info->manifest_info->serviceapplication, ptr2);
-               info->manifest_info->serviceapplication = ptr2;
-       }
-
-       /*UI Apps*/
-       for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
-       {
-               appinfo->locale = strdup(locale);
-               appinfo->app_component = PMINFO_UI_APP;
-               appinfo->package = strdup(ptr1->package);
-               appinfo->uiapp_info = ptr1;
-               snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
-                               "from package_app_info where " \
-                               "app_id='%s'", ptr1->appid);
-               ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
-
-               if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
-                       if (locale) {
-                               free(locale);
-                       }
-                       locale = __get_app_locale_by_fallback(appinfo_db, ptr1->appid, syslocale);
-               }
-
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
-                               "from package_app_localized_info where " \
-                               "app_id='%s' and app_locale='%s'",
-                               ptr1->appid, locale);
-               ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
-
-               memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
-                               "from package_app_localized_info where " \
-                               "app_id='%s' and app_locale='%s'",
-                               ptr1->appid, DEFAULT_LOCALE);
-
-               ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+               ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
 
                /*store setting notification icon section*/
                memset(query, '\0', MAX_QUERY_LEN);
@@ -6407,197 +5202,21 @@ catch:
                free(syslocale);
                syslocale = NULL;
        }
-       sqlite3_close(appinfo_db);
-       if (appinfo) {
-               free(appinfo);
-               appinfo = NULL;
-       }
-       __cleanup_pkginfo(info);
-       return ret;
-}
-
-API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid, pkgmgrinfo_appinfo_h *handle)
-{
-       retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL");
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
-
-       pkgmgr_appinfo_x *appinfo = NULL;
-       char *syslocale = NULL;
-       char *locale = NULL;
-       int ret = -1;
-       int exist = 0;
-       label_x *tmp1 = NULL;
-       icon_x *tmp2 = NULL;
-       category_x *tmp3 = NULL;
-       metadata_x *tmp4 = NULL;
-       permission_x *tmp5 = NULL;
-       image_x *tmp6 = NULL;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       sqlite3 *appinfo_db = NULL;
-
-       /*open db*/
-       _LOGD("getUserPkgParserDBPathUID(%d) returns: [%s]", uid, getUserPkgParserDBPathUID(uid));
-       ret = db_util_open_with_options(getUserPkgParserDBPathUID(uid), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
-       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPathUID(uid));
-
-  
-       /*check appid exist on db*/
-       snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", appid);
-       ret = __exec_db_query(appinfo_db, query, __validate_cb, (void *)&exist);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec fail");
-       tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "Appid[%s] not found in DB", appid);
-
-       /*get system locale*/
-       syslocale = vconf_get_str(VCONFKEY_LANGSET);
-       tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
-
-       /*get locale on db*/
-       locale = __convert_system_locale_to_manifest_locale(syslocale);
-       tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
-
-       /*calloc appinfo*/
-       appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
-       tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
-
-       /*check app_component from DB*/
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select app_component, package from package_app_info where app_id='%s' ", appid);
-       ret = __exec_db_query(appinfo_db, query, __appcomponent_cb, (void *)appinfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
-
-       /*calloc app_component*/
-       if (appinfo->app_component == PMINFO_UI_APP) {
-               appinfo->uiapp_info = (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
-               tryvm_if(appinfo->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for uiapp info");
-       } else {
-               appinfo->svcapp_info = (serviceapplication_x *)calloc(1, sizeof(serviceapplication_x));
-               tryvm_if(appinfo->svcapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for svcapp info");
-       }
-       appinfo->locale = strdup(locale);
-
-       /*populate app_info from DB*/
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' ", appid);
-       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
-
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, locale);
-       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
-
-       /*Also store the values corresponding to default locales*/
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, DEFAULT_LOCALE);
-       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
-
-       /*Populate app category*/
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_category where app_id='%s'", appid);
-       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Category Info DB Information retrieval failed");
-
-       /*Populate app metadata*/
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_metadata where app_id='%s'", appid);
-       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Metadata Info DB Information retrieval failed");
-
-       /*Populate app permission*/
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_permission where app_id='%s'", appid);
-       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App permission Info DB Information retrieval failed");
-
-       /*store setting notification icon section*/
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appid);
-       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
-
-       /*store app preview image info*/
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appid);
-       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
-
-       switch (appinfo->app_component) {
-       case PMINFO_UI_APP:
-               if (appinfo->uiapp_info->label) {
-                       LISTHEAD(appinfo->uiapp_info->label, tmp1);
-                       appinfo->uiapp_info->label = tmp1;
-               }
-               if (appinfo->uiapp_info->icon) {
-                       LISTHEAD(appinfo->uiapp_info->icon, tmp2);
-                       appinfo->uiapp_info->icon = tmp2;
-               }
-               if (appinfo->uiapp_info->category) {
-                       LISTHEAD(appinfo->uiapp_info->category, tmp3);
-                       appinfo->uiapp_info->category = tmp3;
-               }
-               if (appinfo->uiapp_info->metadata) {
-                       LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
-                       appinfo->uiapp_info->metadata = tmp4;
-               }
-               if (appinfo->uiapp_info->permission) {
-                       LISTHEAD(appinfo->uiapp_info->permission, tmp5);
-                       appinfo->uiapp_info->permission = tmp5;
-               }
-               if (appinfo->uiapp_info->image) {
-                       LISTHEAD(appinfo->uiapp_info->image, tmp6);
-                       appinfo->uiapp_info->image = tmp6;
-               }
-               break;
-       case PMINFO_SVC_APP:
-               if (appinfo->svcapp_info->label) {
-                       LISTHEAD(appinfo->svcapp_info->label, tmp1);
-                       appinfo->svcapp_info->label = tmp1;
-               }
-               if (appinfo->svcapp_info->icon) {
-                       LISTHEAD(appinfo->svcapp_info->icon, tmp2);
-                       appinfo->svcapp_info->icon = tmp2;
-               }
-               if (appinfo->svcapp_info->category) {
-                       LISTHEAD(appinfo->svcapp_info->category, tmp3);
-                       appinfo->svcapp_info->category = tmp3;
-               }
-               if (appinfo->svcapp_info->metadata) {
-                       LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
-                       appinfo->svcapp_info->metadata = tmp4;
-               }
-               if (appinfo->svcapp_info->permission) {
-                       LISTHEAD(appinfo->svcapp_info->permission, tmp5);
-                       appinfo->svcapp_info->permission = tmp5;
-               }
-               break;
-       default:
-               break;
-       }
-
-       ret = PMINFO_R_OK;
-
-catch:
-       if (ret == PMINFO_R_OK)
-               *handle = (void*)appinfo;
-       else {
-               *handle = NULL;
-               __cleanup_appinfo(appinfo);
-       }
-
-       sqlite3_close(appinfo_db);
-       if (syslocale) {
-               free(syslocale);
-               syslocale = NULL;
-       }
-       if (locale) {
-               free(locale);
-               locale = NULL;
+       sqlite3_close(appinfo_db);
+       if (appinfo) {
+               free(appinfo);
+               appinfo = NULL;
        }
+       __cleanup_pkginfo(info);
        return ret;
 }
 
-API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
+API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
+{
+       return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, GLOBAL_USER, user_data);
+}
+
+API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid, pkgmgrinfo_appinfo_h *handle)
 {
        retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL");
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
@@ -6617,9 +5236,11 @@ API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *
        sqlite3 *appinfo_db = NULL;
 
        /*open db*/
-       ret = db_util_open_with_options(getUserPkgParserDBPath(), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
-       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPath());
+       _LOGD("getUserPkgParserDBPathUID(%d) returns: [%s]", uid, getUserPkgParserDBPathUID(uid));
+       ret = db_util_open_with_options(getUserPkgParserDBPathUID(uid), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
+       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPathUID(uid));
 
+  
        /*check appid exist on db*/
        snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", appid);
        ret = __exec_db_query(appinfo_db, query, __validate_cb, (void *)&exist);
@@ -6776,6 +5397,10 @@ catch:
        return ret;
 }
 
+API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
+{
+       return pkgmgrinfo_appinfo_get_usr_appinfo(appid, GLOBAL_USER, handle);
+}
 
 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h  handle, char **appid)
 {
@@ -7613,746 +6238,391 @@ API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
                uc = 0;
                mc = 0;
                oc = 0;
-               sc = 0;
-       }
-       pkgmgr_parser_free_manifest_xml(mfx);
-       if (ptr) {
-               free(ptr);
-               ptr = NULL;
-       }
-       return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h  handle, bool *nodisplay)
-{
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
-       retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
-       char *val = NULL;
-       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       val = (char *)info->uiapp_info->nodisplay;
-       if (val) {
-               if (strcasecmp(val, "true") == 0)
-                       *nodisplay = 1;
-               else if (strcasecmp(val, "false") == 0)
-                       *nodisplay = 0;
-               else
-                       *nodisplay = 0;
-       }
-       return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h  handle, bool *multiple)
-{
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
-       retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
-       char *val = NULL;
-       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       val = (char *)info->uiapp_info->multiple;
-       if (val) {
-               if (strcasecmp(val, "true") == 0)
-                       *multiple = 1;
-               else if (strcasecmp(val, "false") == 0)
-                       *multiple = 0;
-               else
-                       *multiple = 0;
-       }
-       return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
-{
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
-       retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
-       char *val = NULL;
-       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       val = (char *)info->uiapp_info->indicatordisplay;
-       if (val) {
-               if (strcasecmp(val, "true") == 0){
-                       *indicator_disp = 1;
-               }else if (strcasecmp(val, "false") == 0){
-                       *indicator_disp = 0;
-               }else{
-                       *indicator_disp = 0;
-               }
-       }
-       return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h  handle, bool *taskmanage)
-{
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
-       retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
-       char *val = NULL;
-       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       val = (char *)info->uiapp_info->taskmanage;
-       if (val) {
-               if (strcasecmp(val, "true") == 0)
-                       *taskmanage = 1;
-               else if (strcasecmp(val, "false") == 0)
-                       *taskmanage = 0;
-               else
-                       *taskmanage = 0;
-       }
-       return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h  handle, bool *enabled)
-{
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
-       retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
-       char *val = NULL;
-       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       if (info->app_component == PMINFO_UI_APP)
-               val = (char *)info->uiapp_info->enabled;
-       else if (info->app_component == PMINFO_SVC_APP)
-               val = (char *)info->uiapp_info->enabled;
-       else {
-               _LOGE("invalid component type\n");
-               return PMINFO_R_EINVAL;
-       }
-
-       if (val) {
-               if (strcasecmp(val, "true") == 0)
-                       *enabled = 1;
-               else if (strcasecmp(val, "false") == 0)
-                       *enabled = 0;
-               else
-                       *enabled = 1;
-       }
-       return PMINFO_R_OK;
-
-}
-
-API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h  handle, bool *onboot)
-{
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
-       retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
-       char *val = NULL;
-       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       val = (char *)info->svcapp_info->onboot;
-       if (val) {
-               if (strcasecmp(val, "true") == 0)
-                       *onboot = 1;
-               else if (strcasecmp(val, "false") == 0)
-                       *onboot = 0;
-               else
-                       *onboot = 0;
-       }
-       return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h  handle, bool *autorestart)
-{
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
-       retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
-       char *val = NULL;
-       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       val = (char *)info->svcapp_info->autorestart;
-       if (val) {
-               if (strcasecmp(val, "true") == 0)
-                       *autorestart = 1;
-               else if (strcasecmp(val, "false") == 0)
-                       *autorestart = 0;
-               else
-                       *autorestart = 0;
-       }
-       return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h  handle, bool *mainapp)
-{
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
-       retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
-       char *val = NULL;
-       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       val = (char *)info->uiapp_info->mainapp;
-       if (val) {
-               if (strcasecmp(val, "true") == 0)
-                       *mainapp = 1;
-               else if (strcasecmp(val, "false") == 0)
-                       *mainapp = 0;
-               else
-                       *mainapp = 0;
-       }
-       return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
-{
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
-       retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-       char *val = NULL;
-       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       val = (char *)info->uiapp_info->preload;
-       if (val) {
-               if (strcasecmp(val, "true") == 0)
-                       *preload = 1;
-               else if (strcasecmp(val, "false") == 0)
-                       *preload = 0;
-               else
-                       *preload = 0;
-       }
-       return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
-{
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
-       retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-       char *val = NULL;
-       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       val = (char *)info->uiapp_info->submode;
-       if (val) {
-               if (strcasecmp(val, "true") == 0)
-                       *submode = 1;
-               else if (strcasecmp(val, "false") == 0)
-                       *submode = 0;
-               else
-                       *submode = 0;
-       }
-       return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h  handle)
-{
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
-       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       __cleanup_appinfo(info);
-       return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
-{
-       return (pkgmgrinfo_pkginfo_filter_create(handle));
-}
-
-API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
-{
-       return (pkgmgrinfo_pkginfo_filter_destroy(handle));
-}
-
-API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
-                               const char *property, const int value)
-{
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-       retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-       char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
-       char *val = NULL;
-       GSList *link = NULL;
-       int prop = -1;
-       prop = _pminfo_appinfo_convert_to_prop_int(property);
-       if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
-               prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
-               _LOGE("Invalid Integer Property\n");
-               return PMINFO_R_EINVAL;
-       }
-       pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
-       pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
-       if (node == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               return PMINFO_R_ERROR;
+               sc = 0;
        }
-       snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
-       val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
-       if (val == NULL) {
-               _LOGE("Out of Memory\n");
-               free(node);
-               node = NULL;
-               return PMINFO_R_ERROR;
+       pkgmgr_parser_free_manifest_xml(mfx);
+       if (ptr) {
+               free(ptr);
+               ptr = NULL;
        }
-       node->prop = prop;
-       node->value = val;
-       /*If API is called multiple times for same property, we should override the previous values.
-       Last value set will be used for filtering.*/
-       link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
-       if (link)
-               filter->list = g_slist_delete_link(filter->list, link);
-       filter->list = g_slist_append(filter->list, (gpointer)node);
        return PMINFO_R_OK;
-
 }
 
-API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
-                               const char *property, const bool value)
+API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h  handle, bool *nodisplay)
 {
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-       retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
        char *val = NULL;
-       GSList *link = NULL;
-       int prop = -1;
-       prop = _pminfo_appinfo_convert_to_prop_bool(property);
-       if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
-               prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
-               _LOGE("Invalid Boolean Property\n");
-               return PMINFO_R_EINVAL;
-       }
-       pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
-       pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
-       if (node == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               return PMINFO_R_ERROR;
-       }
-       if (value)
-               val = strndup("('true','True')", 15);
-       else
-               val = strndup("('false','False')", 17);
-       if (val == NULL) {
-               _LOGE("Out of Memory\n");
-               free(node);
-               node = NULL;
-               return PMINFO_R_ERROR;
+       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+       val = (char *)info->uiapp_info->nodisplay;
+       if (val) {
+               if (strcasecmp(val, "true") == 0)
+                       *nodisplay = 1;
+               else if (strcasecmp(val, "false") == 0)
+                       *nodisplay = 0;
+               else
+                       *nodisplay = 0;
        }
-       node->prop = prop;
-       node->value = val;
-       /*If API is called multiple times for same property, we should override the previous values.
-       Last value set will be used for filtering.*/
-       link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
-       if (link)
-               filter->list = g_slist_delete_link(filter->list, link);
-       filter->list = g_slist_append(filter->list, (gpointer)node);
        return PMINFO_R_OK;
-
 }
 
-API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
-                               const char *property, const char *value)
+API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h  handle, bool *multiple)
 {
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-       retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-       retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
        char *val = NULL;
-       pkgmgrinfo_node_x *ptr = NULL;
-       char prev[PKG_STRING_LEN_MAX] = {'\0'};
-       char temp[PKG_STRING_LEN_MAX] = {'\0'};
-       GSList *link = NULL;
-       int prop = -1;
-       prop = _pminfo_appinfo_convert_to_prop_str(property);
-       if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
-               prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
-               _LOGE("Invalid String Property\n");
-               return PMINFO_R_EINVAL;
-       }
-       pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
-       pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
-       if (node == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               return PMINFO_R_ERROR;
-       }
-       node->prop = prop;
-       switch (prop) {
-       case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
-               if (strcmp(value, PMINFO_APPINFO_UI_APP) == 0)
-                       val = strndup("uiapp", PKG_STRING_LEN_MAX - 1);
+       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+       val = (char *)info->uiapp_info->multiple;
+       if (val) {
+               if (strcasecmp(val, "true") == 0)
+                       *multiple = 1;
+               else if (strcasecmp(val, "false") == 0)
+                       *multiple = 0;
                else
-                       val = strndup("svcapp", PKG_STRING_LEN_MAX - 1);
-               node->value = val;
-               link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
-               if (link)
-                       filter->list = g_slist_delete_link(filter->list, link);
-               filter->list = g_slist_append(filter->list, (gpointer)node);
-               break;
-       case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
-       case E_PMINFO_APPINFO_PROP_APP_OPERATION:
-       case E_PMINFO_APPINFO_PROP_APP_URI:
-       case E_PMINFO_APPINFO_PROP_APP_MIME:
-               val = (char *)calloc(1, PKG_STRING_LEN_MAX);
-               if (val == NULL) {
-                       _LOGE("Out of Memory\n");
-                       free(node);
-                       node = NULL;
-                       return PMINFO_R_ERROR;
-               }
-               link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
-               if (link) {
-                       ptr = (pkgmgrinfo_node_x *)link->data;
-                       strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
-                       _LOGE("Previous value is %s\n", prev);
-                       filter->list = g_slist_delete_link(filter->list, link);
-                       snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
-                       strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
-                       _LOGE("New value is %s\n", val);
-                       node->value = val;
-                       filter->list = g_slist_append(filter->list, (gpointer)node);
-                       memset(temp, '\0', PKG_STRING_LEN_MAX);
-               } else {
-                       snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
-                       strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
-                       _LOGE("First value is %s\n", val);
-                       node->value = val;
-                       filter->list = g_slist_append(filter->list, (gpointer)node);
-                       memset(temp, '\0', PKG_STRING_LEN_MAX);
-               }
-               break;
-       default:
-               node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
-               link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
-               if (link)
-                       filter->list = g_slist_delete_link(filter->list, link);
-               filter->list = g_slist_append(filter->list, (gpointer)node);
-               break;
+                       *multiple = 0;
        }
        return PMINFO_R_OK;
 }
 
-API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
+API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
 {
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-       retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-       char *syslocale = NULL;
-       char *locale = NULL;
-       char *condition = NULL;
-       char *error_message = NULL;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       char where[MAX_QUERY_LEN] = {'\0'};
-       GSList *list;
-       int ret = 0;
-
-       pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
-       /*Get current locale*/
-       syslocale = vconf_get_str(VCONFKEY_LANGSET);
-       if (syslocale == NULL) {
-               _LOGE("current locale is NULL\n");
-               return PMINFO_R_ERROR;
-       }
-       locale = __convert_system_locale_to_manifest_locale(syslocale);
-       if (locale == NULL) {
-               _LOGE("manifest locale is NULL\n");
-               free(syslocale);
-               return PMINFO_R_ERROR;
-       }
-
-       ret = __open_manifest_db(uid);
-       if (ret == -1) {
-               _LOGE("Fail to open manifest DB\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-
-       /*Start constructing query*/
-       snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_COUNT_APP, locale);
-
-       /*Get where clause*/
-       for (list = filter->list; list; list = g_slist_next(list)) {
-               __get_filter_condition(list->data, &condition);
-               if (condition) {
-                       strncat(where, condition, sizeof(where) - strlen(where) -1);
-                       where[sizeof(where) - 1] = '\0';
-                       free(condition);
-                       condition = NULL;
-               }
-               if (g_slist_next(list)) {
-                       strncat(where, " and ", sizeof(where) - strlen(where) - 1);
-                       where[sizeof(where) - 1] = '\0';
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+       char *val = NULL;
+       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+       val = (char *)info->uiapp_info->indicatordisplay;
+       if (val) {
+               if (strcasecmp(val, "true") == 0){
+                       *indicator_disp = 1;
+               }else if (strcasecmp(val, "false") == 0){
+                       *indicator_disp = 0;
+               }else{
+                       *indicator_disp = 0;
                }
        }
-       _LOGE("where = %s\n", where);
-       if (strlen(where) > 0) {
-               strncat(query, where, sizeof(query) - strlen(query) - 1);
-               query[sizeof(query) - 1] = '\0';
-       }
-       _LOGE("query = %s\n", query);
+       return PMINFO_R_OK;
+}
 
-       /*Execute Query*/
-       if (SQLITE_OK !=
-           sqlite3_exec(manifest_db, query, __count_cb, (void *)count, &error_message)) {
-               _LOGE("Don't execute query = %s error message = %s\n", query,
-                      error_message);
-               sqlite3_free(error_message);
-               sqlite3_close(manifest_db);
-               ret = PMINFO_R_ERROR;
-               *count = 0;
-               goto err;
-       }
-       ret = PMINFO_R_OK;
-err:
-       if (locale) {
-               free(locale);
-               locale = NULL;
-       }
-       if (syslocale) {
-               free(syslocale);
-               syslocale = NULL;
+API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h  handle, bool *taskmanage)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+       char *val = NULL;
+       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+       val = (char *)info->uiapp_info->taskmanage;
+       if (val) {
+               if (strcasecmp(val, "true") == 0)
+                       *taskmanage = 1;
+               else if (strcasecmp(val, "false") == 0)
+                       *taskmanage = 0;
+               else
+                       *taskmanage = 0;
        }
-       sqlite3_close(manifest_db);
-       return ret;
+       return PMINFO_R_OK;
 }
-API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
-{
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-       retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-       char *syslocale = NULL;
-       char *locale = NULL;
-       char *condition = NULL;
-       char *error_message = NULL;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       char where[MAX_QUERY_LEN] = {'\0'};
-       GSList *list;
-       int ret = 0;
 
-       pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
-       /*Get current locale*/
-       syslocale = vconf_get_str(VCONFKEY_LANGSET);
-       if (syslocale == NULL) {
-               _LOGE("current locale is NULL\n");
-               return PMINFO_R_ERROR;
-       }
-       locale = __convert_system_locale_to_manifest_locale(syslocale);
-       if (locale == NULL) {
-               _LOGE("manifest locale is NULL\n");
-               free(syslocale);
-               return PMINFO_R_ERROR;
+API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h  handle, bool *enabled)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+       char *val = NULL;
+       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+       if (info->app_component == PMINFO_UI_APP)
+               val = (char *)info->uiapp_info->enabled;
+       else if (info->app_component == PMINFO_SVC_APP)
+               val = (char *)info->uiapp_info->enabled;
+       else {
+               _LOGE("invalid component type\n");
+               return PMINFO_R_EINVAL;
        }
 
-       ret = __open_manifest_db(GLOBAL_USER);
-       if (ret == -1) {
-               _LOGE("Fail to open manifest DB\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
+       if (val) {
+               if (strcasecmp(val, "true") == 0)
+                       *enabled = 1;
+               else if (strcasecmp(val, "false") == 0)
+                       *enabled = 0;
+               else
+                       *enabled = 1;
        }
+       return PMINFO_R_OK;
 
-       /*Start constructing query*/
-       snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_COUNT_APP, locale);
+}
 
-       /*Get where clause*/
-       for (list = filter->list; list; list = g_slist_next(list)) {
-               __get_filter_condition(list->data, &condition);
-               if (condition) {
-                       strncat(where, condition, sizeof(where) - strlen(where) -1);
-                       where[sizeof(where) - 1] = '\0';
-                       free(condition);
-                       condition = NULL;
-               }
-               if (g_slist_next(list)) {
-                       strncat(where, " and ", sizeof(where) - strlen(where) - 1);
-                       where[sizeof(where) - 1] = '\0';
-               }
-       }
-       _LOGE("where = %s\n", where);
-       if (strlen(where) > 0) {
-               strncat(query, where, sizeof(query) - strlen(query) - 1);
-               query[sizeof(query) - 1] = '\0';
+API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h  handle, bool *onboot)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+       char *val = NULL;
+       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+       val = (char *)info->svcapp_info->onboot;
+       if (val) {
+               if (strcasecmp(val, "true") == 0)
+                       *onboot = 1;
+               else if (strcasecmp(val, "false") == 0)
+                       *onboot = 0;
+               else
+                       *onboot = 0;
        }
-       _LOGE("query = %s\n", query);
+       return PMINFO_R_OK;
+}
 
-       /*Execute Query*/
-       if (SQLITE_OK !=
-           sqlite3_exec(manifest_db, query, __count_cb, (void *)count, &error_message)) {
-               _LOGE("Don't execute query = %s error message = %s\n", query,
-                      error_message);
-               sqlite3_free(error_message);
-               sqlite3_close(manifest_db);
-               ret = PMINFO_R_ERROR;
-               *count = 0;
-               goto err;
-       }
-       ret = PMINFO_R_OK;
-err:
-       if (locale) {
-               free(locale);
-               locale = NULL;
-       }
-       if (syslocale) {
-               free(syslocale);
-               syslocale = NULL;
+API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h  handle, bool *autorestart)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+       char *val = NULL;
+       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+       val = (char *)info->svcapp_info->autorestart;
+       if (val) {
+               if (strcasecmp(val, "true") == 0)
+                       *autorestart = 1;
+               else if (strcasecmp(val, "false") == 0)
+                       *autorestart = 0;
+               else
+                       *autorestart = 0;
        }
-       sqlite3_close(manifest_db);
-       return ret;
+       return PMINFO_R_OK;
 }
 
-API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
-                               pkgmgrinfo_app_list_cb app_cb, void * user_data)
+API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h  handle, bool *mainapp)
 {
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-       retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-       char *syslocale = NULL;
-       char *locale = NULL;
-       char *condition = NULL;
-       char *error_message = NULL;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       char where[MAX_QUERY_LEN] = {'\0'};
-       GSList *list;
-       int ret = 0;
-       uiapplication_x *ptr1 = NULL;
-       serviceapplication_x *ptr2 = NULL;
-       pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
-       /*Get current locale*/
-       syslocale = vconf_get_str(VCONFKEY_LANGSET);
-       if (syslocale == NULL) {
-               _LOGE("current locale is NULL\n");
-               return PMINFO_R_ERROR;
-       }
-       locale = __convert_system_locale_to_manifest_locale(syslocale);
-       if (locale == NULL) {
-               _LOGE("manifest locale is NULL\n");
-               free(syslocale);
-               return PMINFO_R_ERROR;
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+       char *val = NULL;
+       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+       val = (char *)info->uiapp_info->mainapp;
+       if (val) {
+               if (strcasecmp(val, "true") == 0)
+                       *mainapp = 1;
+               else if (strcasecmp(val, "false") == 0)
+                       *mainapp = 0;
+               else
+                       *mainapp = 0;
        }
+       return PMINFO_R_OK;
+}
 
-       ret = __open_manifest_db(GLOBAL_USER);
-       if (ret == -1) {
-               _LOGE("Fail to open manifest DB\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-       /*Start constructing query*/
-       snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_APP, locale);
-       /*Get where clause*/
-       for (list = filter->list; list; list = g_slist_next(list)) {
-               __get_filter_condition(list->data, &condition);
-               if (condition) {
-                       strncat(where, condition, sizeof(where) - strlen(where) -1);
-                       where[sizeof(where) - 1] = '\0';
-                       free(condition);
-                       condition = NULL;
-               }
-               if (g_slist_next(list)) {
-                       strncat(where, " and ", sizeof(where) - strlen(where) - 1);
-                       where[sizeof(where) - 1] = '\0';
-               }
+API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+       retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+       char *val = NULL;
+       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+       val = (char *)info->uiapp_info->preload;
+       if (val) {
+               if (strcasecmp(val, "true") == 0)
+                       *preload = 1;
+               else if (strcasecmp(val, "false") == 0)
+                       *preload = 0;
+               else
+                       *preload = 0;
        }
-       _LOGE("where = %s\n", where);
-       if (strlen(where) > 0) {
-               strncat(query, where, sizeof(query) - strlen(query) - 1);
-               query[sizeof(query) - 1] = '\0';
+       return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+       retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+       char *val = NULL;
+       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+       val = (char *)info->uiapp_info->submode;
+       if (val) {
+               if (strcasecmp(val, "true") == 0)
+                       *submode = 1;
+               else if (strcasecmp(val, "false") == 0)
+                       *submode = 0;
+               else
+                       *submode = 0;
        }
-       _LOGE("query = %s\n", query);
-       /*To get filtered list*/
-       pkgmgr_pkginfo_x *info = NULL;
-       info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       if (info == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
+       return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h  handle)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+       __cleanup_appinfo(info);
+       return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
+{
+       return (pkgmgrinfo_pkginfo_filter_create(handle));
+}
+
+API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
+{
+       return (pkgmgrinfo_pkginfo_filter_destroy(handle));
+}
+
+API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
+                               const char *property, const int value)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
+       char *val = NULL;
+       GSList *link = NULL;
+       int prop = -1;
+       prop = _pminfo_appinfo_convert_to_prop_int(property);
+       if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
+               prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
+               _LOGE("Invalid Integer Property\n");
+               return PMINFO_R_EINVAL;
        }
-       info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
-       if (info->manifest_info == NULL) {
+       pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
+       pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
+       if (node == NULL) {
                _LOGE("Out of Memory!!!\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
+               return PMINFO_R_ERROR;
        }
-       /*To get detail app info for each member of filtered list*/
-       pkgmgr_pkginfo_x *filtinfo = NULL;
-       filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       if (filtinfo == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
+       snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
+       val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
+       if (val == NULL) {
+               _LOGE("Out of Memory\n");
+               free(node);
+               node = NULL;
+               return PMINFO_R_ERROR;
        }
-       filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
-       if (filtinfo->manifest_info == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
+       node->prop = prop;
+       node->value = val;
+       /*If API is called multiple times for same property, we should override the previous values.
+       Last value set will be used for filtering.*/
+       link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
+       if (link)
+               filter->list = g_slist_delete_link(filter->list, link);
+       filter->list = g_slist_append(filter->list, (gpointer)node);
+       return PMINFO_R_OK;
+
+}
+
+API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
+                               const char *property, const bool value)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       char *val = NULL;
+       GSList *link = NULL;
+       int prop = -1;
+       prop = _pminfo_appinfo_convert_to_prop_bool(property);
+       if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
+               prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
+               _LOGE("Invalid Boolean Property\n");
+               return PMINFO_R_EINVAL;
        }
-       pkgmgr_appinfo_x *appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
-       if (appinfo == NULL) {
+       pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
+       pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
+       if (node == NULL) {
                _LOGE("Out of Memory!!!\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
+               return PMINFO_R_ERROR;
        }
-       if (SQLITE_OK !=
-           sqlite3_exec(manifest_db, query, __app_list_cb, (void *)info, &error_message)) {
-               _LOGE("Don't execute query = %s error message = %s\n", query,
-                      error_message);
-               sqlite3_free(error_message);
-               sqlite3_close(manifest_db);
-               ret = PMINFO_R_ERROR;
-               goto err;
+       if (value)
+               val = strndup("('true','True')", 15);
+       else
+               val = strndup("('false','False')", 17);
+       if (val == NULL) {
+               _LOGE("Out of Memory\n");
+               free(node);
+               node = NULL;
+               return PMINFO_R_ERROR;
        }
-       memset(query, '\0', MAX_QUERY_LEN);
-       if (info->manifest_info->uiapplication) {
-               LISTHEAD(info->manifest_info->uiapplication, ptr1);
-               info->manifest_info->uiapplication = ptr1;
+       node->prop = prop;
+       node->value = val;
+       /*If API is called multiple times for same property, we should override the previous values.
+       Last value set will be used for filtering.*/
+       link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
+       if (link)
+               filter->list = g_slist_delete_link(filter->list, link);
+       filter->list = g_slist_append(filter->list, (gpointer)node);
+       return PMINFO_R_OK;
+
+}
+
+API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
+                               const char *property, const char *value)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       char *val = NULL;
+       pkgmgrinfo_node_x *ptr = NULL;
+       char prev[PKG_STRING_LEN_MAX] = {'\0'};
+       char temp[PKG_STRING_LEN_MAX] = {'\0'};
+       GSList *link = NULL;
+       int prop = -1;
+       prop = _pminfo_appinfo_convert_to_prop_str(property);
+       if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
+               prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
+               _LOGE("Invalid String Property\n");
+               return PMINFO_R_EINVAL;
        }
-       if (info->manifest_info->serviceapplication) {
-               LISTHEAD(info->manifest_info->serviceapplication, ptr2);
-               info->manifest_info->serviceapplication = ptr2;
+       pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
+       pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
+       if (node == NULL) {
+               _LOGE("Out of Memory!!!\n");
+               return PMINFO_R_ERROR;
        }
-       /*Filtered UI Apps*/
-       for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
-       {
-               snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
-                                                       ptr1->appid, "uiapp");
-               if (SQLITE_OK !=
-               sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message)) {
-                       _LOGE("Don't execute query = %s error message = %s\n", query,
-                              error_message);
-                       sqlite3_free(error_message);
-                       sqlite3_close(manifest_db);
-                       ret = PMINFO_R_ERROR;
-                       goto err;
+       node->prop = prop;
+       switch (prop) {
+       case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
+               if (strcmp(value, PMINFO_APPINFO_UI_APP) == 0)
+                       val = strndup("uiapp", PKG_STRING_LEN_MAX - 1);
+               else
+                       val = strndup("svcapp", PKG_STRING_LEN_MAX - 1);
+               node->value = val;
+               link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
+               if (link)
+                       filter->list = g_slist_delete_link(filter->list, link);
+               filter->list = g_slist_append(filter->list, (gpointer)node);
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
+       case E_PMINFO_APPINFO_PROP_APP_OPERATION:
+       case E_PMINFO_APPINFO_PROP_APP_URI:
+       case E_PMINFO_APPINFO_PROP_APP_MIME:
+               val = (char *)calloc(1, PKG_STRING_LEN_MAX);
+               if (val == NULL) {
+                       _LOGE("Out of Memory\n");
+                       free(node);
+                       node = NULL;
+                       return PMINFO_R_ERROR;
                }
-       }
-       for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
-       {
-               snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
-                                                       ptr2->appid, "svcapp");
-               if (SQLITE_OK !=
-               sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message)) {
-                       _LOGE("Don't execute query = %s error message = %s\n", query,
-                              error_message);
-                       sqlite3_free(error_message);
-                       sqlite3_close(manifest_db);
-                       ret = PMINFO_R_ERROR;
-                       goto err;
+               link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
+               if (link) {
+                       ptr = (pkgmgrinfo_node_x *)link->data;
+                       strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
+                       _LOGE("Previous value is %s\n", prev);
+                       filter->list = g_slist_delete_link(filter->list, link);
+                       snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
+                       strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
+                       _LOGE("New value is %s\n", val);
+                       node->value = val;
+                       filter->list = g_slist_append(filter->list, (gpointer)node);
+                       memset(temp, '\0', PKG_STRING_LEN_MAX);
+               } else {
+                       snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
+                       strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
+                       _LOGE("First value is %s\n", val);
+                       node->value = val;
+                       filter->list = g_slist_append(filter->list, (gpointer)node);
+                       memset(temp, '\0', PKG_STRING_LEN_MAX);
                }
+               break;
+       default:
+               node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
+               link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
+               if (link)
+                       filter->list = g_slist_delete_link(filter->list, link);
+               filter->list = g_slist_append(filter->list, (gpointer)node);
+               break;
        }
-       if (filtinfo->manifest_info->uiapplication) {
-               LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
-               filtinfo->manifest_info->uiapplication = ptr1;
-       }
-       /*If the callback func return < 0 we break and no more call back is called*/
-       while(ptr1 != NULL)
-       {
-               appinfo->locale = strdup(locale);
-               appinfo->uiapp_info = ptr1;
-               appinfo->app_component = PMINFO_UI_APP;
-               ret = app_cb((void *)appinfo, user_data);
-               if (ret < 0)
-                       break;
-               ptr1 = ptr1->next;
-       }
-       /*Filtered Service Apps*/
-       if (filtinfo->manifest_info->serviceapplication) {
-               LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
-               filtinfo->manifest_info->serviceapplication = ptr2;
-       }
-       /*If the callback func return < 0 we break and no more call back is called*/
-       while(ptr2 != NULL)
-       {
-               appinfo->locale = strdup(locale);
-               appinfo->svcapp_info = ptr2;
-               appinfo->app_component = PMINFO_SVC_APP;
-               ret = app_cb((void *)appinfo, user_data);
-               if (ret < 0)
-                       break;
-               ptr2 = ptr2->next;
-       }
-       ret = PMINFO_R_OK;
-err:
-       if (locale) {
-               free(locale);
-               locale = NULL;
-       }
-       if (syslocale) {
-               free(syslocale);
-               syslocale = NULL;
-       }
-       sqlite3_close(manifest_db);
-       if (appinfo) {
-               free(appinfo);
-               appinfo = NULL;
-       }
-       __cleanup_pkginfo(info);
-       __cleanup_pkginfo(filtinfo);
-       return ret;
+       return PMINFO_R_OK;
 }
 
-API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
-                               pkgmgrinfo_app_list_cb app_cb, void * user_data, uid_t uid)
+API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-       retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
        char *syslocale = NULL;
        char *locale = NULL;
        char *condition = NULL;
@@ -8361,8 +6631,7 @@ API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_
        char where[MAX_QUERY_LEN] = {'\0'};
        GSList *list;
        int ret = 0;
-       uiapplication_x *ptr1 = NULL;
-       serviceapplication_x *ptr2 = NULL;
+
        pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
        /*Get current locale*/
        syslocale = vconf_get_str(VCONFKEY_LANGSET);
@@ -8383,8 +6652,10 @@ API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_
                ret = PMINFO_R_ERROR;
                goto err;
        }
+
        /*Start constructing query*/
-       snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_APP, locale);
+       snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_COUNT_APP, locale);
+
        /*Get where clause*/
        for (list = filter->list; list; list = g_slist_next(list)) {
                __get_filter_condition(list->data, &condition);
@@ -8405,118 +6676,18 @@ API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_
                query[sizeof(query) - 1] = '\0';
        }
        _LOGE("query = %s\n", query);
-       /*To get filtered list*/
-       pkgmgr_pkginfo_x *info = NULL;
-       info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       if (info == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-       info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
-       if (info->manifest_info == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-       /*To get detail app info for each member of filtered list*/
-       pkgmgr_pkginfo_x *filtinfo = NULL;
-       filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       if (filtinfo == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-       filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
-       if (filtinfo->manifest_info == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
-       pkgmgr_appinfo_x *appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
-       if (appinfo == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
-       }
+
+       /*Execute Query*/
        if (SQLITE_OK !=
-           sqlite3_exec(manifest_db, query, __app_list_cb, (void *)info, &error_message)) {
+           sqlite3_exec(manifest_db, query, __count_cb, (void *)count, &error_message)) {
                _LOGE("Don't execute query = %s error message = %s\n", query,
                       error_message);
                sqlite3_free(error_message);
                sqlite3_close(manifest_db);
                ret = PMINFO_R_ERROR;
+               *count = 0;
                goto err;
        }
-       memset(query, '\0', MAX_QUERY_LEN);
-       if (info->manifest_info->uiapplication) {
-               LISTHEAD(info->manifest_info->uiapplication, ptr1);
-               info->manifest_info->uiapplication = ptr1;
-       }
-       if (info->manifest_info->serviceapplication) {
-               LISTHEAD(info->manifest_info->serviceapplication, ptr2);
-               info->manifest_info->serviceapplication = ptr2;
-       }
-       /*Filtered UI Apps*/
-       for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
-       {
-               snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
-                                                       ptr1->appid, "uiapp");
-               if (SQLITE_OK !=
-               sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message)) {
-                       _LOGE("Don't execute query = %s error message = %s\n", query,
-                              error_message);
-                       sqlite3_free(error_message);
-                       sqlite3_close(manifest_db);
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-       }
-       for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
-       {
-               snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
-                                                       ptr2->appid, "svcapp");
-               if (SQLITE_OK !=
-               sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message)) {
-                       _LOGE("Don't execute query = %s error message = %s\n", query,
-                              error_message);
-                       sqlite3_free(error_message);
-                       sqlite3_close(manifest_db);
-                       ret = PMINFO_R_ERROR;
-                       goto err;
-               }
-       }
-       if (filtinfo->manifest_info->uiapplication) {
-               LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
-               filtinfo->manifest_info->uiapplication = ptr1;
-       }
-       /*If the callback func return < 0 we break and no more call back is called*/
-       while(ptr1 != NULL)
-       {
-               appinfo->locale = strdup(locale);
-               appinfo->uiapp_info = ptr1;
-               appinfo->app_component = PMINFO_UI_APP;
-               ret = app_cb((void *)appinfo, user_data);
-               if (ret < 0)
-                       break;
-               ptr1 = ptr1->next;
-       }
-       /*Filtered Service Apps*/
-       if (filtinfo->manifest_info->serviceapplication) {
-               LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
-               filtinfo->manifest_info->serviceapplication = ptr2;
-       }
-       /*If the callback func return < 0 we break and no more call back is called*/
-       while(ptr2 != NULL)
-       {
-               appinfo->locale = strdup(locale);
-               appinfo->svcapp_info = ptr2;
-               appinfo->app_component = PMINFO_SVC_APP;
-               ret = app_cb((void *)appinfo, user_data);
-               if (ret < 0)
-                       break;
-               ptr2 = ptr2->next;
-       }
        ret = PMINFO_R_OK;
 err:
        if (locale) {
@@ -8528,70 +6699,19 @@ err:
                syslocale = NULL;
        }
        sqlite3_close(manifest_db);
-       if (appinfo) {
-               free(appinfo);
-               appinfo = NULL;
-       }
-       __cleanup_pkginfo(info);
-       __cleanup_pkginfo(filtinfo);
        return ret;
 }
 
-API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
-{
-       return (pkgmgrinfo_pkginfo_filter_create(handle));
-}
-
-API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
-{
-       return (pkgmgrinfo_pkginfo_filter_destroy(handle));
-}
-
-API int pkgmgrinfo_appinfo_metadata_filter_add(pkgmgrinfo_appinfo_metadata_filter_h handle,
-               const char *key, const char *value)
+API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
 {
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
-       retvm_if(key == NULL, PMINFO_R_EINVAL, "metadata key supplied is NULL\n");
-       /*value can be NULL. In that case all apps with specified key should be displayed*/
-       int ret = 0;
-       char *k = NULL;
-       char *v = NULL;
-       pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
-       pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
-       retvm_if(node == NULL, PMINFO_R_ERROR, "Out of Memory!!!\n");
-       k = strdup(key);
-       tryvm_if(k == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
-       node->key = k;
-       if (value) {
-               v = strdup(value);
-               tryvm_if(v == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
-       }
-       node->value = v;
-       /*If API is called multiple times, we should OR all conditions.*/
-       filter->list = g_slist_append(filter->list, (gpointer)node);
-       /*All memory will be freed in destroy API*/
-       return PMINFO_R_OK;
-catch:
-       if (node) {
-               if (node->key) {
-                       free(node->key);
-                       node->key = NULL;
-               }
-               if (node->value) {
-                       free(node->value);
-                       node->value = NULL;
-               }
-               free(node);
-               node = NULL;
-       }
-       return ret;
+       return pkgmgrinfo_appinfo_usr_filter_count(handle, count, GLOBAL_USER);
 }
 
-API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filter_h handle,
-               pkgmgrinfo_app_list_cb app_cb, void *user_data)
+API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
+                               pkgmgrinfo_app_list_cb app_cb, void * user_data, uid_t uid)
 {
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
-       retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Callback function supplied is NULL\n");
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+       retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
        char *syslocale = NULL;
        char *locale = NULL;
        char *condition = NULL;
@@ -8600,64 +6720,94 @@ API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_f
        char where[MAX_QUERY_LEN] = {'\0'};
        GSList *list;
        int ret = 0;
-       pkgmgr_pkginfo_x *info = NULL;
-       pkgmgr_pkginfo_x *filtinfo = NULL;
-       pkgmgr_appinfo_x *appinfo = NULL;
        uiapplication_x *ptr1 = NULL;
        serviceapplication_x *ptr2 = NULL;
        pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
-
        /*Get current locale*/
        syslocale = vconf_get_str(VCONFKEY_LANGSET);
-       retvm_if(syslocale == NULL, PMINFO_R_ERROR, "current locale is NULL\n");
+       if (syslocale == NULL) {
+               _LOGE("current locale is NULL\n");
+               return PMINFO_R_ERROR;
+       }
        locale = __convert_system_locale_to_manifest_locale(syslocale);
-       tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL\n");
-
-       ret = __open_manifest_db(GLOBAL_USER);
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Fail to open manifest DB\n");
+       if (locale == NULL) {
+               _LOGE("manifest locale is NULL\n");
+               free(syslocale);
+               return PMINFO_R_ERROR;
+       }
 
+       ret = __open_manifest_db(uid);
+       if (ret == -1) {
+               _LOGE("Fail to open manifest DB\n");
+               ret = PMINFO_R_ERROR;
+               goto err;
+       }
        /*Start constructing query*/
-       memset(where, '\0', MAX_QUERY_LEN);
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN - 1, METADATA_FILTER_QUERY_SELECT_CLAUSE);
+       snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_APP, locale);
        /*Get where clause*/
        for (list = filter->list; list; list = g_slist_next(list)) {
-               __get_metadata_filter_condition(list->data, &condition);
+               __get_filter_condition(list->data, &condition);
                if (condition) {
                        strncat(where, condition, sizeof(where) - strlen(where) -1);
+                       where[sizeof(where) - 1] = '\0';
                        free(condition);
                        condition = NULL;
                }
                if (g_slist_next(list)) {
-                       strncat(where, METADATA_FILTER_QUERY_UNION_CLAUSE, sizeof(where) - strlen(where) - 1);
+                       strncat(where, " and ", sizeof(where) - strlen(where) - 1);
+                       where[sizeof(where) - 1] = '\0';
                }
        }
-       _LOGE("where = %s (%d)\n", where, strlen(where));
+       _LOGE("where = %s\n", where);
        if (strlen(where) > 0) {
                strncat(query, where, sizeof(query) - strlen(query) - 1);
+               query[sizeof(query) - 1] = '\0';
        }
-       _LOGE("query = %s (%d)\n", query, strlen(query));
+       _LOGE("query = %s\n", query);
        /*To get filtered list*/
+       pkgmgr_pkginfo_x *info = NULL;
        info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
-
+       if (info == NULL) {
+               _LOGE("Out of Memory!!!\n");
+               ret = PMINFO_R_ERROR;
+               goto err;
+       }
        info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
-       tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
-
+       if (info->manifest_info == NULL) {
+               _LOGE("Out of Memory!!!\n");
+               ret = PMINFO_R_ERROR;
+               goto err;
+       }
        /*To get detail app info for each member of filtered list*/
+       pkgmgr_pkginfo_x *filtinfo = NULL;
        filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
-       tryvm_if(filtinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
-
+       if (filtinfo == NULL) {
+               _LOGE("Out of Memory!!!\n");
+               ret = PMINFO_R_ERROR;
+               goto err;
+       }
        filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
-       tryvm_if(filtinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
-
-       appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
-       tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
-
-       ret = sqlite3_exec(manifest_db, query, __app_list_cb, (void *)info, &error_message);
-       tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
+       if (filtinfo->manifest_info == NULL) {
+               _LOGE("Out of Memory!!!\n");
+               ret = PMINFO_R_ERROR;
+               goto err;
+       }
+       pkgmgr_appinfo_x *appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
+       if (appinfo == NULL) {
+               _LOGE("Out of Memory!!!\n");
+               ret = PMINFO_R_ERROR;
+               goto err;
+       }
+       if (SQLITE_OK !=
+           sqlite3_exec(manifest_db, query, __app_list_cb, (void *)info, &error_message)) {
+               _LOGE("Don't execute query = %s error message = %s\n", query,
+                      error_message);
+               sqlite3_free(error_message);
+               sqlite3_close(manifest_db);
+               ret = PMINFO_R_ERROR;
+               goto err;
+       }
        memset(query, '\0', MAX_QUERY_LEN);
-
        if (info->manifest_info->uiapplication) {
                LISTHEAD(info->manifest_info->uiapplication, ptr1);
                info->manifest_info->uiapplication = ptr1;
@@ -8666,26 +6816,35 @@ API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_f
                LISTHEAD(info->manifest_info->serviceapplication, ptr2);
                info->manifest_info->serviceapplication = ptr2;
        }
-
-       /*UI Apps*/
+       /*Filtered UI Apps*/
        for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
        {
                snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
                                                        ptr1->appid, "uiapp");
-               ret = sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message);
-               tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
-               memset(query, '\0', MAX_QUERY_LEN);
+               if (SQLITE_OK !=
+               sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message)) {
+                       _LOGE("Don't execute query = %s error message = %s\n", query,
+                              error_message);
+                       sqlite3_free(error_message);
+                       sqlite3_close(manifest_db);
+                       ret = PMINFO_R_ERROR;
+                       goto err;
+               }
        }
-       /*Service Apps*/
        for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
        {
                snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
                                                        ptr2->appid, "svcapp");
-               ret = sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message);
-               tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
-               memset(query, '\0', MAX_QUERY_LEN);
+               if (SQLITE_OK !=
+               sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message)) {
+                       _LOGE("Don't execute query = %s error message = %s\n", query,
+                              error_message);
+                       sqlite3_free(error_message);
+                       sqlite3_close(manifest_db);
+                       ret = PMINFO_R_ERROR;
+                       goto err;
+               }
        }
-       /*Filtered UI Apps*/
        if (filtinfo->manifest_info->uiapplication) {
                LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
                filtinfo->manifest_info->uiapplication = ptr1;
@@ -8718,7 +6877,7 @@ API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_f
                ptr2 = ptr2->next;
        }
        ret = PMINFO_R_OK;
-catch:
+err:
        if (locale) {
                free(locale);
                locale = NULL;
@@ -8727,7 +6886,6 @@ catch:
                free(syslocale);
                syslocale = NULL;
        }
-       sqlite3_free(error_message);
        sqlite3_close(manifest_db);
        if (appinfo) {
                free(appinfo);
@@ -8737,6 +6895,63 @@ catch:
        __cleanup_pkginfo(filtinfo);
        return ret;
 }
+
+API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
+                               pkgmgrinfo_app_list_cb app_cb, void * user_data)
+{
+       return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, GLOBAL_USER);
+}
+
+API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
+{
+       return (pkgmgrinfo_pkginfo_filter_create(handle));
+}
+
+API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
+{
+       return (pkgmgrinfo_pkginfo_filter_destroy(handle));
+}
+
+API int pkgmgrinfo_appinfo_metadata_filter_add(pkgmgrinfo_appinfo_metadata_filter_h handle,
+               const char *key, const char *value)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
+       retvm_if(key == NULL, PMINFO_R_EINVAL, "metadata key supplied is NULL\n");
+       /*value can be NULL. In that case all apps with specified key should be displayed*/
+       int ret = 0;
+       char *k = NULL;
+       char *v = NULL;
+       pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
+       pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
+       retvm_if(node == NULL, PMINFO_R_ERROR, "Out of Memory!!!\n");
+       k = strdup(key);
+       tryvm_if(k == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
+       node->key = k;
+       if (value) {
+               v = strdup(value);
+               tryvm_if(v == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
+       }
+       node->value = v;
+       /*If API is called multiple times, we should OR all conditions.*/
+       filter->list = g_slist_append(filter->list, (gpointer)node);
+       /*All memory will be freed in destroy API*/
+       return PMINFO_R_OK;
+catch:
+       if (node) {
+               if (node->key) {
+                       free(node->key);
+                       node->key = NULL;
+               }
+               if (node->value) {
+                       free(node->value);
+                       node->value = NULL;
+               }
+               free(node);
+               node = NULL;
+       }
+       return ret;
+}
+
 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filter_h handle,
                pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
 {
@@ -8763,7 +6978,7 @@ API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(pkgmgrinfo_appinfo_metada
        locale = __convert_system_locale_to_manifest_locale(syslocale);
        tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL\n");
 
-       ret = __open_manifest_db(GLOBAL_USER);
+       ret = __open_manifest_db(uid);
        tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Fail to open manifest DB\n");
 
        /*Start constructing query*/
@@ -8888,6 +7103,12 @@ catch:
        return ret;
 }
 
+API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filter_h handle,
+               pkgmgrinfo_app_list_cb app_cb, void *user_data)
+{
+       return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb, user_data, GLOBAL_USER);
+}
+
 API int pkgmgrinfo_pkginfo_create_certinfo(pkgmgrinfo_certinfo_h *handle)
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
@@ -9568,59 +7789,6 @@ API int pkgmgrinfo_pkginfo_set_state_enabled(const char *pkgid, bool enabled)
        return 0;
 }
 
-API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled)
-{
-       retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
-       int ret = -1;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       ret = __open_manifest_db(GLOBAL_USER);
-
-       if (access(getUserPkgParserDBPath(), F_OK) == 0) {
-               ret = db_util_open(MANIFEST_DB, &manifest_db,
-                        DB_UTIL_REGISTER_HOOK_METHOD);
-               if (ret != SQLITE_OK) {
-                       _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", getUserPkgParserDBPath());
-                       return PMINFO_R_ERROR;
-               }
-       }
-
-       /*Begin transaction*/
-       ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
-       if (ret != SQLITE_OK) {
-               _LOGE("Failed to begin transaction\n");
-               sqlite3_close(manifest_db);
-               return PMINFO_R_ERROR;
-       }
-       _LOGD("Transaction Begin\n");
-
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN,
-               "update package_app_info set app_enabled='%s' where app_id='%s'", enabled?"true":"false", appid);
-
-       char *error_message = NULL;
-       if (SQLITE_OK !=
-           sqlite3_exec(manifest_db, query, NULL, NULL, &error_message)) {
-               _LOGE("Don't execute query = %s error message = %s\n", query,
-                      error_message);
-               sqlite3_free(error_message);
-               return PMINFO_R_ERROR;
-       }
-       sqlite3_free(error_message);
-
-       /*Commit transaction*/
-       ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL);
-       if (ret != SQLITE_OK) {
-               _LOGE("Failed to commit transaction. Rollback now\n");
-               sqlite3_exec(manifest_db, "ROLLBACK", NULL, NULL, NULL);
-               sqlite3_close(manifest_db);
-               return PMINFO_R_ERROR;
-       }
-       _LOGD("Transaction Commit and End\n");
-       sqlite3_close(manifest_db);
-
-       return PMINFO_R_OK;
-}
-
 API int pkgmgrinfo_appinfo_set_usr_state_enabled(const char *appid, bool enabled, uid_t uid)
 {
        retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
@@ -9674,6 +7842,11 @@ API int pkgmgrinfo_appinfo_set_usr_state_enabled(const char *appid, bool enabled
        return PMINFO_R_OK;
 }
 
+API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled)
+{
+       return pkgmgrinfo_appinfo_set_usr_state_enabled(appid, enabled, GLOBAL_USER);
+}
+
 API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access)
 {
        retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
@@ -9773,54 +7946,7 @@ API int pkgmgrinfo_appinfo_set_usr_default_label(const char *appid, const char *
 
 API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *label)
 {
-       retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
-       int ret = -1;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       char *error_message = NULL;
-       ret = __open_manifest_db(GLOBAL_USER);
-
-       if (access(getUserPkgParserDBPath(), F_OK) == 0) {
-               ret = db_util_open(getUserPkgParserDBPath(), &manifest_db,
-                        DB_UTIL_REGISTER_HOOK_METHOD);
-               if (ret != SQLITE_OK) {
-                       _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", getUserPkgParserDBPath());
-                       return PMINFO_R_ERROR;
-               }
-       }
-
-       /*Begin transaction*/
-       ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
-       if (ret != SQLITE_OK) {
-               _LOGE("Failed to begin transaction\n");
-               sqlite3_close(manifest_db);
-               return PMINFO_R_ERROR;
-       }
-       _LOGD("Transaction Begin\n");
-
-       memset(query, '\0', MAX_QUERY_LEN);
-       snprintf(query, MAX_QUERY_LEN,
-               "update package_app_localized_info set app_label='%s' where app_id='%s' and app_locale='No Locale'", label, appid);
-
-       if (SQLITE_OK !=
-           sqlite3_exec(manifest_db, query, NULL, NULL, &error_message)) {
-               _LOGE("Don't execute query = %s error message = %s\n", query,
-                      error_message);
-               sqlite3_free(error_message);
-               return PMINFO_R_ERROR;
-       }
-
-       /*Commit transaction*/
-       ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL);
-       if (ret != SQLITE_OK) {
-               _LOGE("Failed to commit transaction. Rollback now\n");
-               sqlite3_exec(manifest_db, "ROLLBACK", NULL, NULL, NULL);
-               sqlite3_close(manifest_db);
-               return PMINFO_R_ERROR;
-       }
-       _LOGD("Transaction Commit and End\n");
-       sqlite3_close(manifest_db);
-
-       return PMINFO_R_OK;
+       return pkgmgrinfo_appinfo_set_usr_default_label(appid, label, GLOBAL_USER);
 }
 
 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
@@ -9842,7 +7968,7 @@ API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle,
        return PMINFO_R_OK;
 }
 
-API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status)
+API int pkgmgrinfo_appinfo_set_usr_guestmode_visibility(pkgmgrinfo_appinfo_h handle, uid_t uid, bool status)
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
        char *val = NULL;
@@ -9857,7 +7983,7 @@ API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle,
        val = (char *)info->uiapp_info->guestmode_visibility;
        if (val ) {
                 ret =
-                   db_util_open_with_options(getUserPkgParserDBPath(), &pkgmgr_parser_db,
+                   db_util_open_with_options(getUserPkgParserDBPathUID(uid), &pkgmgr_parser_db,
                                 SQLITE_OPEN_READWRITE, NULL);
 
                 if (ret != SQLITE_OK) {
@@ -9892,54 +8018,9 @@ API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle,
        return PMINFO_R_OK;
 }
 
-API int pkgmgrinfo_appinfo_set_usr_guestmode_visibility(pkgmgrinfo_appinfo_h handle, uid_t uid, bool status)
+API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status)
 {
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
-       char *val = NULL;
-       int ret = 0;
-       char *noti_string = NULL;
-       int len = 0;
-       char query[MAX_QUERY_LEN] = {'\0'};
-       char *errmsg = NULL;
-       sqlite3 *pkgmgr_parser_db;
-
-       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-       val = (char *)info->uiapp_info->guestmode_visibility;
-       if (val ) {
-                ret =
-                   db_util_open_with_options(getUserPkgParserDBPathUID(uid), &pkgmgr_parser_db,
-                                SQLITE_OPEN_READWRITE, NULL);
-
-                if (ret != SQLITE_OK) {
-                       _LOGE("DB Open Failed\n");
-                       return PMINFO_R_ERROR;
-                }
-
-               /*TODO: Write to DB here*/
-               if (status == true)
-                       snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'true' where app_id = '%s'", (char *)info->uiapp_info->appid);
-               else
-                       snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'false' where app_id = '%s'", (char *)info->uiapp_info->appid);
-
-               if (SQLITE_OK != sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &errmsg)) {
-                       _LOGE("DB update [%s] failed, error message = %s\n", query, errmsg);
-                       free(errmsg);
-                       sqlite3_close(pkgmgr_parser_db);
-                       return PMINFO_R_ERROR;
-               }else{
-                       sqlite3_close(pkgmgr_parser_db);
-                       len = strlen((char *)info->uiapp_info->appid) + 8;
-                       noti_string = calloc(1, len);
-                       if (noti_string == NULL){
-                               return PMINFO_R_ERROR;
-                       }
-                       snprintf(noti_string, len, "update:%s", (char *)info->uiapp_info->appid);
-               vconf_set_str(VCONFKEY_AIL_INFO_STATE, noti_string);
-                       vconf_set_str(VCONFKEY_MENUSCREEN_DESKTOP, noti_string); // duplicate, will be removed
-                       free(noti_string);
-               }
-       }
-       return PMINFO_R_OK;
+       return pkgmgrinfo_appinfo_set_usr_guestmode_visibility(handle, GLOBAL_USER, status);
 }
 
 /* pkgmgrinfo client start*/