Fix compare and load certinfo by GLOBAL USER.
[platform/core/appfw/pkgmgr-info.git] / src / pkgmgr-info.c
old mode 100755 (executable)
new mode 100644 (file)
index 7460390..3a7c264
@@ -19,7 +19,8 @@
  * limitations under the License.
  *
  */
-
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <glib.h>
 #include <ctype.h>
 #include <assert.h>
+#include <dlfcn.h>
+#include <sys/smack.h>
+#include <linux/limits.h>
+#include <libgen.h>
+#include <grp.h>
 
 #include <libxml/parser.h>
 #include <libxml/xmlreader.h>
 #include <libxml/xmlschemas.h>
 
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+/* For multi-user support */
+#include <tzplatform_config.h>
+
 #include "pkgmgr_parser.h"
 #include "pkgmgr-info-internal.h"
 #include "pkgmgr-info-debug.h"
 #include "pkgmgr-info.h"
 #include "pkgmgr_parser_db.h"
+#include "pkgmgr_parser_internal.h"
 #include <dirent.h>
 #include <sys/stat.h>
 
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "PKGMGR_INFO"
+
 #define ASC_CHAR(s) (const char *)s
 #define XML_CHAR(s) (const xmlChar *)s
 
-#define MANIFEST_DB    "/opt/dbspace/.pkgmgr_parser.db"
+#define MANIFEST_DB    tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db")
 #define MAX_QUERY_LEN  4096
 #define MAX_CERT_TYPE  9
-#define CERT_DB                "/opt/dbspace/.pkgmgr_cert.db"
-#define DATACONTROL_DB "/opt/usr/dbspace/.app-package.db"
+#define CERT_DB                tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert.db")
+#define DATACONTROL_DB tzplatform_mkpath(TZ_USER_DB, ".app-package.db")
 #define PKG_TYPE_STRING_LEN_MAX                128
 #define PKG_VERSION_STRING_LEN_MAX     128
 #define PKG_VALUE_STRING_LEN_MAX               512
 #define PKG_LOCALE_STRING_LEN_MAX              8
-#define PKG_RW_PATH "/opt/usr/apps/"
-#define PKG_RO_PATH "/usr/apps/"
+#define PKG_RW_PATH tzplatform_mkpath(TZ_USER_APP, "")
+#define PKG_RO_PATH tzplatform_mkpath(TZ_SYS_RO_APP, "")
 #define BLOCK_SIZE      4096 /*in bytes*/
+#define BUFSIZE 4096
+#define ROOT_UID 0
 
-#define MMC_PATH "/opt/storage/sdcard"
-#define PKG_SD_PATH MMC_PATH"/app2sd/"
-#define PKG_INSTALLATION_PATH "/opt/usr/apps/"
+#define MMC_PATH tzplatform_mkpath(TZ_SYS_STORAGE, "sdcard")
+#define PKG_SD_PATH tzplatform_mkpath3(TZ_SYS_STORAGE, "sdcard", "app2sd/")
+#define PKG_INSTALLATION_PATH tzplatform_mkpath(TZ_USER_APP, "")
 
 #define FILTER_QUERY_COUNT_PACKAGE     "select count(DISTINCT package_info.package) " \
                                "from package_info LEFT OUTER JOIN package_localized_info " \
 
 #define LANGUAGE_LENGTH 2
 
+#define SERVICE_NAME "org.tizen.system.deviced"
+#define PATH_NAME "/Org/Tizen/System/DeviceD/Mmc"
+#define INTERFACE_NAME "org.tizen.system.deviced.Mmc"
+#define METHOD_NAME "RequestMountApp2ext"
+
+
+
 typedef struct _pkgmgr_instcertinfo_x {
        char *pkgid;
        char *cert_info[MAX_CERT_TYPE]; /*certificate data*/
@@ -113,6 +140,7 @@ typedef struct _pkgmgr_certindexinfo_x {
 } pkgmgr_certindexinfo_x;
 
 typedef struct _pkgmgr_pkginfo_x {
+       uid_t uid;
        manifest_x *manifest_info;
        char *locale;
 
@@ -154,6 +182,7 @@ typedef struct _pkgmgr_appinfo_x {
 } pkgmgr_appinfo_x;
 
 typedef struct _pkgmgr_certinfo_x {
+       int for_all_users;
        char *pkgid;
        char *cert_value;
        char *cert_info[MAX_CERT_TYPE]; /*certificate info*/
@@ -162,6 +191,7 @@ typedef struct _pkgmgr_certinfo_x {
 
 /*For filter APIs*/
 typedef struct _pkgmgrinfo_filter_x {
+       uid_t uid;
        GSList *list;
 } pkgmgrinfo_filter_x;
 
@@ -182,14 +212,80 @@ typedef struct _pkgmgrinfo_appcontrol_x {
        char **subapp;
 } pkgmgrinfo_appcontrol_x;
 
+
+typedef struct _db_handle {
+       sqlite3 *dbHandle;
+       int ref;
+} db_handle;
+
+
 typedef int (*sqlite_query_callback)(void *data, int ncols, char **coltxt, char **colname);
 
+typedef int (*pkgmgr_handler)(int req_id, const char *pkg_type,
+                               const char *pkgid, const char *key,
+                               const char *val, const void *pmsg, void *data);
+
+typedef void pkgmgr_client;
+typedef void pkgmgr_info;
+
+typedef enum {
+       PM_REQUEST_CSC = 0,
+       PM_REQUEST_MOVE = 1,
+       PM_REQUEST_GET_SIZE = 2,
+       PM_REQUEST_KILL_APP = 3,
+       PM_REQUEST_CHECK_APP = 4,
+       PM_REQUEST_MAX
+}pkgmgr_request_service_type;
+
+typedef enum {
+       PM_GET_TOTAL_SIZE= 0,
+       PM_GET_DATA_SIZE = 1,
+       PM_GET_ALL_PKGS = 2,
+       PM_GET_SIZE_INFO = 3,
+       PM_GET_TOTAL_AND_DATA = 4,
+       PM_GET_SIZE_FILE = 5,
+       PM_GET_MAX
+}pkgmgr_getsize_type;
+
+typedef enum {
+       PC_REQUEST = 0,
+       PC_LISTENING,
+       PC_BROADCAST,
+}client_type;
+
+#define PKG_SIZE_INFO_FILE "/tmp/pkgmgr_size_info.txt"
+#define MAX_PKG_BUF_LEN                1024
+#define MAX_PKG_INFO_LEN       10
+
+#define QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO "create table if not exists package_cert_index_info " \
+                                               "(cert_info text not null, " \
+                                               "cert_id integer, " \
+                                               "cert_ref_count integer, " \
+                                               "PRIMARY KEY(cert_id)) "
+
+#define QUERY_CREATE_TABLE_PACKAGE_CERT_INFO "create table if not exists package_cert_info " \
+                                               "(package text not null, " \
+                                               "author_root_cert integer, " \
+                                               "author_im_cert integer, " \
+                                               "author_signer_cert integer, " \
+                                               "dist_root_cert integer, " \
+                                               "dist_im_cert integer, " \
+                                               "dist_signer_cert integer, " \
+                                               "dist2_root_cert integer, " \
+                                               "dist2_im_cert integer, " \
+                                               "dist2_signer_cert integer, " \
+                                               "PRIMARY KEY(package)) "
+
+#define GET_DB(X)  (X).dbHandle
 char *pkgtype = "rpm";
-__thread sqlite3 *manifest_db = NULL;
-__thread sqlite3 *datacontrol_db = NULL;
-__thread sqlite3 *cert_db = NULL;
-
-static int __open_manifest_db();
+__thread db_handle manifest_db;
+__thread db_handle datacontrol_db;
+__thread db_handle cert_db;
+
+static int __open_manifest_db(uid_t uid);
+static int __close_manifest_db(void);
+static int __open_cert_db(uid_t uid, char* mode);
+static int __close_cert_db(void);
 static int __exec_pkginfo_query(char *query, void *data);
 static int __exec_certinfo_query(char *query, void *data);
 static int __exec_certindexinfo_query(char *query, void *data);
@@ -211,7 +307,238 @@ static void __destroy_each_node(gpointer data, gpointer user_data);
 static void __get_filter_condition(gpointer data, char **condition);
 static void __get_metadata_filter_condition(gpointer data, char **condition);
 static gint __compare_func(gconstpointer data1, gconstpointer data2);
-static int __delete_certinfo(const char *pkgid);
+static int __delete_certinfo(const char *pkgid, uid_t uid);
+static int _check_create_Cert_db( sqlite3 *certdb);
+static int __exec_db_query(sqlite3 *db, char *query, sqlite_query_callback callback, void *data);
+
+static int _mkdir_for_user(const char* dir, uid_t uid, gid_t gid)
+{
+       int ret;
+       char *fullpath;
+       char *subpath;
+
+       fullpath = strdup(dir);
+       subpath = dirname(fullpath);
+       if (strlen(subpath) > 1 && strcmp(subpath, fullpath) != 0) {
+               ret = _mkdir_for_user(fullpath, uid, gid);
+               if (ret == -1) {
+                       free(fullpath);
+                       return ret;
+               }
+       }
+
+       ret = mkdir(dir, S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH);
+       if (ret && errno != EEXIST) {
+               free(fullpath);
+               return ret;
+       } else if (ret && errno == EEXIST) {
+               free(fullpath);
+               return 0;
+       }
+
+       if (getuid() == ROOT_UID) {
+               ret = chown(dir, uid, gid);
+               if (ret == -1)
+                       _LOGE("FAIL : chown %s %d.%d, because %s", dir, uid,
+                                       gid, strerror(errno));
+       }
+
+       free(fullpath);
+
+       return 0;
+}
+
+static const char *_get_db_path(uid_t uid) {
+       const char *db_path = NULL;
+       if (uid != GLOBAL_USER && uid != ROOT_UID) {
+               tzplatform_set_user(uid);
+               db_path = tzplatform_getenv(TZ_USER_DB);
+               tzplatform_reset_user();
+       } else {
+               db_path = tzplatform_getenv(TZ_SYS_DB);
+       }
+       return db_path;
+}
+
+static int __attach_and_create_view(sqlite3 *handle, const char *db, const char *tables[], uid_t uid)
+{
+       int i;
+       char *err;
+       char query[MAX_QUERY_LEN];
+
+       if (uid == GLOBAL_USER || uid == ROOT_UID)
+               return SQLITE_OK;
+
+       snprintf(query, sizeof(query), "ATTACH DATABASE '%s' AS Global", db);
+       if (SQLITE_OK != sqlite3_exec(handle, query, NULL, NULL, &err)) {
+               _LOGD("Don't execute query = %s error message = %s\n", query, err);
+               sqlite3_free(err);
+               return SQLITE_ERROR;
+       }
+
+       for (i = 0; tables[i]; i++) {
+               snprintf(query, sizeof(query), "CREATE TEMP VIEW '%s' AS SELECT * \
+                               FROM (SELECT *,0 AS for_all_users FROM  main.'%s' UNION \
+                               SELECT *,1 AS for_all_users FROM Global.'%s')",
+                               tables[i], tables[i], tables[i]);
+               if (SQLITE_OK != sqlite3_exec(handle, query, NULL, NULL, &err)) {
+                       _LOGD("Don't execute query = %s error message = %s\n", query, err);
+                       sqlite3_free(err);
+               }
+       }
+
+       return SQLITE_OK;
+}
+
+static int _check_create_Cert_db( sqlite3 *certdb)
+{
+       int ret = 0;
+       ret = __exec_db_query(certdb, QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO, NULL, NULL);
+       if(ret < 0)
+               return ret;
+       ret = __exec_db_query(certdb, QUERY_CREATE_TABLE_PACKAGE_CERT_INFO, NULL, NULL);
+       return ret;
+}
+
+static gid_t _get_gid(const char *name)
+{
+       char buf[BUFSIZE];
+       struct group entry;
+       struct group *ge;
+       int ret;
+
+       ret = getgrnam_r(name, &entry, buf, sizeof(buf), &ge);
+       if (ret || ge == NULL) {
+               _LOGE("fail to get gid of %s", name);
+               return -1;
+       }
+
+       return entry.gr_gid;
+}
+
+API char *getIconPath(uid_t uid)
+{
+       const char *path = NULL;
+       uid_t uid_caller = getuid();
+       gid_t gid = ROOT_UID;
+
+       if (uid != GLOBAL_USER && uid != ROOT_UID) {
+               tzplatform_set_user(uid);
+               path = tzplatform_mkpath(TZ_USER_ICONS, "/");
+               gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
+               tzplatform_reset_user();
+       } else {
+               path = tzplatform_mkpath(TZ_SYS_RW_ICONS, "/");
+       }
+
+       // just allow certain users to create the icon directory if needed.
+       if (uid_caller == ROOT_UID || uid_caller == uid)
+               _mkdir_for_user(path, uid, gid);
+
+       return path;
+}
+
+API char *getUserPkgParserDBPath(void)
+{
+       return getUserPkgParserDBPathUID(GLOBAL_USER);
+}
+
+API char *getUserPkgParserDBPathUID(uid_t uid)
+{
+       const char *pkgmgr_parser_db = NULL;
+       uid_t uid_caller = getuid();
+       gid_t gid = ROOT_UID;
+
+       if (uid != GLOBAL_USER && uid != ROOT_UID) {
+               tzplatform_set_user(uid);
+               pkgmgr_parser_db = tzplatform_mkpath(TZ_USER_DB, ".pkgmgr_parser.db");
+               gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
+               tzplatform_reset_user();
+       } else {
+               pkgmgr_parser_db = tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db");
+       }
+
+       // just allow certain users to create the dbspace directory if needed.
+       if (uid_caller == ROOT_UID || uid_caller == uid) {
+               const char *db_path = _get_db_path(uid);
+               _mkdir_for_user(db_path, uid, gid);
+       }
+
+       return pkgmgr_parser_db;
+}
+
+API char *getUserPkgCertDBPath(void)
+{
+        return getUserPkgCertDBPathUID(GLOBAL_USER);
+}
+
+API char *getUserPkgCertDBPathUID(uid_t uid)
+{
+       const char *pkgmgr_cert_db = NULL;
+       uid_t uid_caller = getuid();
+       gid_t gid = ROOT_UID;
+
+       if (uid != GLOBAL_USER && uid != ROOT_UID) {
+               tzplatform_set_user(uid);
+               pkgmgr_cert_db = tzplatform_mkpath(TZ_USER_DB, ".pkgmgr_cert.db");
+               gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
+               tzplatform_reset_user();
+       } else {
+               pkgmgr_cert_db = tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert.db");
+       }
+
+       // just allow certain users to create the dbspace directory if needed.
+       if (uid_caller == ROOT_UID || uid_caller == uid) {
+               const char *db_path = _get_db_path(uid);
+               _mkdir_for_user(db_path, uid, gid);
+       }
+
+       return pkgmgr_cert_db;
+}
+
+API const char* getUserDesktopPath(uid_t uid)
+{
+       const char *path = NULL;
+       uid_t uid_caller = getuid();
+       gid_t gid = ROOT_UID;
+
+       if (uid != GLOBAL_USER && uid != ROOT_UID) {
+               tzplatform_set_user(uid);
+               path = tzplatform_mkpath(TZ_USER_DESKTOP, "/");
+               gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
+               tzplatform_reset_user();
+       } else {
+               path = tzplatform_mkpath(TZ_SYS_RW_DESKTOP_APP, "/");
+       }
+
+       // just allow certain users to create the icon directory if needed.
+       if (uid_caller == ROOT_UID || uid_caller == uid)
+               _mkdir_for_user(path, uid, gid);
+
+       return path;
+}
+
+API const char* getUserManifestPath(uid_t uid)
+{
+       const char *path = NULL;
+       uid_t uid_caller = getuid();
+       gid_t gid = ROOT_UID;
+
+       if (uid != GLOBAL_USER && uid != ROOT_UID) {
+               tzplatform_set_user(uid);
+               path = tzplatform_mkpath(TZ_USER_PACKAGES, "/");
+               gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
+               tzplatform_reset_user();
+       } else {
+               path = tzplatform_mkpath(TZ_SYS_RW_PACKAGES, "/");
+       }
+
+       // just allow certain users to create the icon directory if needed.
+       if (uid_caller == ROOT_UID || uid_caller == uid)
+               _mkdir_for_user(path, uid, gid);
+
+       return path;
+}
 
 static gint __compare_func(gconstpointer data1, gconstpointer data2)
 {
@@ -368,6 +695,9 @@ static void __get_filter_condition(gpointer data, char **condition)
        case E_PMINFO_APPINFO_PROP_APP_HWACCELERATION:
                snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_hwacceleration='%s'", node->value);
                break;
+       case E_PMINFO_APPINFO_PROP_APP_SCREENREADER:
+               snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_screenreader='%s'", node->value);
+               break;
        case E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION:
                snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_launchcondition IN %s", node->value);
                break;
@@ -432,28 +762,131 @@ static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
        return;
 }
 
-static int __open_manifest_db()
+static int __close_manifest_db(void)
+{
+       if(manifest_db.ref) {
+               if(--manifest_db.ref == 0)
+                       sqlite3_close(GET_DB(manifest_db));
+               return 0;
+       }
+       return -1;
+}
+
+static const char *parserdb_tables[] = {
+       "package_app_app_category",
+       "package_app_info",
+       "package_app_app_control",
+       "package_app_localized_info",
+       "package_app_app_metadata",
+       "package_app_share_allowed",
+       "package_app_app_permission",
+       "package_app_share_request",
+       "package_app_app_svc",
+       "package_info",
+       "package_app_data_control",
+       "package_localized_info",
+       "package_app_icon_section_info",
+       "package_privilege_info",
+       "package_app_image_info",
+       NULL
+};
+
+static int __open_manifest_db(uid_t uid)
 {
        int ret = -1;
-       if (access(MANIFEST_DB, F_OK) == 0) {
-               ret =
-                   db_util_open_with_options(MANIFEST_DB, &manifest_db,
-                                SQLITE_OPEN_READONLY, NULL);
-               retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", MANIFEST_DB);
+       if(manifest_db.ref) {
+               manifest_db.ref ++;
                return 0;
        }
-       _LOGE("Manifest DB does not exists !!\n");
+       const char* user_pkg_parser = getUserPkgParserDBPathUID(uid);
+       if (access(user_pkg_parser, F_OK) != 0) {
+               _LOGE("Manifest DB does not exists !! try to create\n");
+
+               if (pkgmgr_parser_check_and_create_db(uid)) {
+                       _LOGE("create db failed");
+                       return -1;
+               }
+
+               if (pkgmgr_parser_initialize_db()) {
+                       _LOGE("initialize db failed");
+                       return -1;
+               }
+       }
+
+       ret = db_util_open_with_options(user_pkg_parser, &GET_DB(manifest_db),
+                       SQLITE_OPEN_READONLY, NULL);
+       retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", user_pkg_parser);
+       manifest_db.ref ++;
+       ret = __attach_and_create_view(GET_DB(manifest_db), MANIFEST_DB, parserdb_tables, uid);
+       retvm_if(ret != SQLITE_OK, -1, "attach db [%s] failed!\n", user_pkg_parser);
+
+       return 0;
+}
+
+static int __close_cert_db(void)
+{
+       if(cert_db.ref) {
+               if(--cert_db.ref == 0)
+                       sqlite3_close(GET_DB(cert_db));
+                       return 0;
+       }
+       _LOGE("Certificate DB is already closed !!\n");
+       return -1;
+}
+
+static const char *certdb_tables[] = {
+       "package_cert_index_info",
+       "package_cert_info",
+       NULL
+};
+
+static int __open_cert_db(uid_t uid, char* mode)
+{
+       int ret = -1;
+       if(cert_db.ref) {
+               cert_db.ref ++;
+               return 0;
+       }
+
+       const char* user_cert_parser = getUserPkgCertDBPathUID(uid);
+       if (access(user_cert_parser, F_OK) == 0) {
+               ret = db_util_open_with_options(user_cert_parser, &GET_DB(cert_db),
+                                SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
+               retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", user_cert_parser);
+               cert_db.ref ++;
+               if ((strcmp(mode, "w") != 0)) {
+                       ret = __attach_and_create_view(GET_DB(cert_db), CERT_DB, certdb_tables, uid);
+                       retvm_if(ret != SQLITE_OK, -1, "attach db [%s] failed!\n", user_cert_parser);
+               }
+               return 0;
+       }
+       _LOGE("Cert DB does not exists !!\n");
+       return -1;
+}
+
+static int __close_datacontrol_db(void)
+{
+       if(datacontrol_db.ref) {
+               if(--datacontrol_db.ref == 0)
+                       sqlite3_close(GET_DB(datacontrol_db));
+                       return 0;
+       }
+       _LOGE("Certificate DB is already closed !!\n");
        return -1;
 }
 
 static int __open_datacontrol_db()
 {
        int ret = -1;
+       if(datacontrol_db.ref) {
+               datacontrol_db.ref ++;
+               return 0;
+       }
        if (access(DATACONTROL_DB, F_OK) == 0) {
-               ret =
-                   db_util_open_with_options(DATACONTROL_DB, &datacontrol_db,
+               ret = db_util_open_with_options(DATACONTROL_DB, &GET_DB(datacontrol_db),
                                 SQLITE_OPEN_READONLY, NULL);
                retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", DATACONTROL_DB);
+               datacontrol_db.ref ++;
                return 0;
        }
        _LOGE("Datacontrol DB does not exists !!\n");
@@ -469,6 +902,7 @@ static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname)
        info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
 
        LISTADD(udata, info);
+
        for(i = 0; i < ncols; i++)
        {
                if (strcmp(colname[i], "package") == 0) {
@@ -476,9 +910,19 @@ static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname)
                                info->manifest_info->package = strdup(coltxt[i]);
                        else
                                info->manifest_info->package = NULL;
+               } else if (strcmp(colname[i], "for_all_users") == 0) {
+                       if (coltxt[i])
+                               info->manifest_info->for_all_users = strdup(coltxt[i]);
+                       else
+                               info->manifest_info->for_all_users = NULL;      
                } else
                        continue;
        }
+       
+       //by default if views are not set , the column for_all_users doesn't exist,
+       // in this case we assume we retreive information about app avaible for all users
+       if (!info->manifest_info->for_all_users)
+               info->manifest_info->for_all_users = strdup("1");
 
        return 0;
 }
@@ -595,6 +1039,11 @@ static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
                                info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
                        else
                                info->manifest_info->uiapplication->hwacceleration = NULL;
+               } else if (strcmp(colname[i], "app_screenreader") == 0 ){
+                       if (coltxt[i])
+                               info->manifest_info->uiapplication->screenreader = strdup(coltxt[i]);
+                       else
+                               info->manifest_info->uiapplication->screenreader = NULL;
                } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
                        if (coltxt[i])
                                info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
@@ -679,6 +1128,11 @@ static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
                                info->manifest_info->uiapplication->submode_mainid = strdup(coltxt[i]);
                        else
                                info->manifest_info->uiapplication->submode_mainid = NULL;
+               } else if (strcmp(colname, "app_launch_mode") == 0 ) {
+                       if (coltxt[i])
+                               info->manifest_info->uiapplication->launch_mode = strdup(coltxt[i]);
+                       else
+                               info->manifest_info->uiapplication->launch_mode = NULL;
                } else
                        continue;
        }
@@ -816,6 +1270,11 @@ static int __allapp_list_cb(void *data, int ncols, char **coltxt, char **colname
                                                                info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
                                                        else
                                                                info->manifest_info->uiapplication->hwacceleration = NULL;
+                                               } else if (strcmp(colname[i], "app_screenreader") == 0 ){
+                                                       if (coltxt[i])
+                                                               info->manifest_info->uiapplication->screenreader = strdup(coltxt[i]);
+                                                       else
+                                                               info->manifest_info->uiapplication->screenreader = NULL;
                                                } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
                                                        if (coltxt[i])
                                                                info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
@@ -1062,6 +1521,11 @@ static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname)
                                info->manifest_info->update= strdup(coltxt[i]);
                        else
                                info->manifest_info->update = NULL;
+               } else if (strcmp(colname[i], "package_system") == 0 ){
+                       if (coltxt[i])
+                               info->manifest_info->system= strdup(coltxt[i]);
+                       else
+                               info->manifest_info->system = NULL;
                } else if (strcmp(colname[i], "package_appsetting") == 0 ){
                        if (coltxt[i])
                                info->manifest_info->appsetting = strdup(coltxt[i]);
@@ -1072,11 +1536,21 @@ static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname)
                                info->manifest_info->installed_time = strdup(coltxt[i]);
                        else
                                info->manifest_info->installed_time = NULL;
+               } else if (strcmp(colname[i], "installed_storage") == 0 ){
+                       if (coltxt[i])
+                               info->manifest_info->installed_storage = strdup(coltxt[i]);
+                       else
+                               info->manifest_info->installed_storage = NULL;
                } else if (strcmp(colname[i], "mainapp_id") == 0 ){
                        if (coltxt[i])
                                info->manifest_info->mainapp_id = strdup(coltxt[i]);
                        else
                                info->manifest_info->mainapp_id = NULL;
+               } else if (strcmp(colname[i], "storeclient_id") == 0 ){
+                       if (coltxt[i])
+                               info->manifest_info->storeclient_id = strdup(coltxt[i]);
+                       else
+                               info->manifest_info->storeclient_id = NULL;
                } else if (strcmp(colname[i], "root_path") == 0 ){
                        if (coltxt[i])
                                info->manifest_info->root_path = strdup(coltxt[i]);
@@ -1208,6 +1682,11 @@ static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname)
                                info->cert_value = strdup(coltxt[i]);
                        else
                                info->cert_value = NULL;
+               } else if (strcmp(colname[i], "for_all_users") == 0 ){
+                       if (coltxt[i])
+                               info->for_all_users = atoi(coltxt[i]);
+                       else
+                               info->for_all_users = 0;
                } else
                        continue;
        }
@@ -1216,129 +1695,187 @@ static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname)
 
 static int __mini_appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
 {
-       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
+       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
        int i = 0;
+       int j = 0;
        uiapplication_x *uiapp = NULL;
-       uiapp = calloc(1, sizeof(uiapplication_x));
-       if (uiapp == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               return -1;
-       }
-
-       LISTADD(info->uiapp_info, uiapp);
-
+       serviceapplication_x *svcapp = NULL;
        for(i = 0; i < ncols; i++)
        {
-               if (strcmp(colname[i], "app_id") == 0) {
-                       /*appid being foreign key, is column in every table
-                       Hence appid gets strduped every time leading to memory leak.
-                       If appid is already set, just continue.*/
-                       if (info->uiapp_info->appid)
-                               continue;
-                       if (coltxt[i])
-                               info->uiapp_info->appid = strdup(coltxt[i]);
-                       else
-                               info->uiapp_info->appid = NULL;
-               } else if (strcmp(colname[i], "app_exec") == 0) {
-                       if (coltxt[i])
-                               info->uiapp_info->exec = strdup(coltxt[i]);
-                       else
-                               info->uiapp_info->exec = NULL;
-               } else if (strcmp(colname[i], "app_nodisplay") == 0) {
-                       if (coltxt[i])
-                               info->uiapp_info->nodisplay = strdup(coltxt[i]);
-                       else
-                               info->uiapp_info->nodisplay = NULL;
-               } else if (strcmp(colname[i], "app_type") == 0 ) {
-                       if (coltxt[i])
-                               info->uiapp_info->type = strdup(coltxt[i]);
-                       else
-                               info->uiapp_info->type = NULL;
-               } else if (strcmp(colname[i], "app_multiple") == 0 ) {
-                       if (coltxt[i])
-                               info->uiapp_info->multiple = strdup(coltxt[i]);
-                       else
-                               info->uiapp_info->multiple = NULL;
-               } else if (strcmp(colname[i], "app_taskmanage") == 0 ) {
-                       if (coltxt[i])
-                               info->uiapp_info->taskmanage = strdup(coltxt[i]);
-                       else
-                               info->uiapp_info->taskmanage = NULL;
-               } else if (strcmp(colname[i], "app_hwacceleration") == 0 ) {
-                       if (coltxt[i])
-                               info->uiapp_info->hwacceleration = strdup(coltxt[i]);
-                       else
-                               info->uiapp_info->hwacceleration = NULL;
-               } else if (strcmp(colname[i], "app_enabled") == 0 ) {
-                       if (coltxt[i])
-                               info->uiapp_info->enabled= strdup(coltxt[i]);
-                       else
-                               info->uiapp_info->enabled = NULL;
-               } else if (strcmp(colname[i], "app_indicatordisplay") == 0){
-                       if (coltxt[i])
-                               info->uiapp_info->indicatordisplay = strdup(coltxt[i]);
-                       else
-                               info->uiapp_info->indicatordisplay = NULL;
-               } else if (strcmp(colname[i], "app_portraitimg") == 0){
-                       if (coltxt[i])
-                               info->uiapp_info->portraitimg = strdup(coltxt[i]);
-                       else
-                               info->uiapp_info->portraitimg = NULL;
-               } else if (strcmp(colname[i], "app_landscapeimg") == 0){
-                       if (coltxt[i])
-                               info->uiapp_info->landscapeimg = strdup(coltxt[i]);
-                       else
-                               info->uiapp_info->landscapeimg = NULL;
-               } else if (strcmp(colname[i], "app_guestmodevisibility") == 0){
-                       if (coltxt[i])
-                               info->uiapp_info->guestmode_visibility = strdup(coltxt[i]);
-                       else
-                               info->uiapp_info->guestmode_visibility = NULL;
-               } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
-                       if (coltxt[i])
-                               info->uiapp_info->recentimage = strdup(coltxt[i]);
-                       else
-                               info->uiapp_info->recentimage = NULL;
-               } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
-                       if (coltxt[i])
-                               info->uiapp_info->mainapp = strdup(coltxt[i]);
-                       else
-                               info->uiapp_info->mainapp = NULL;
-               } else if (strcmp(colname[i], "package") == 0 ) {
-                       if (coltxt[i])
-                               info->uiapp_info->package = strdup(coltxt[i]);
-                       else
-                               info->uiapp_info->package = NULL;
-               } else if (strcmp(colname[i], "app_component") == 0) {
-                       if (coltxt[i])
-                               info->uiapp_info->app_component = strdup(coltxt[i]);
-                       else
-                               info->uiapp_info->app_component = NULL;
-               } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
-                       if (coltxt[i])
-                               info->uiapp_info->permission_type = strdup(coltxt[i]);
-                       else
-                               info->uiapp_info->permission_type = NULL;
-               } else if (strcmp(colname[i], "component_type") == 0 ) {
-                       if (coltxt[i])
-                               info->uiapp_info->component_type = strdup(coltxt[i]);
-                       else
-                               info->uiapp_info->component_type = NULL;
-               } else if (strcmp(colname[i], "app_preload") == 0 ) {
-                       if (coltxt[i])
-                               info->uiapp_info->preload = strdup(coltxt[i]);
-                       else
-                               info->uiapp_info->preload = NULL;
-               } else if (strcmp(colname[i], "app_submode") == 0 ) {
-                       if (coltxt[i])
-                               info->uiapp_info->submode = strdup(coltxt[i]);
-                       else
-                               info->uiapp_info->submode = NULL;
-               } else if (strcmp(colname[i], "app_submode_mainid") == 0 ) {
-                       if (coltxt[i])
-                               info->uiapp_info->submode_mainid = strdup(coltxt[i]);
-                       else
-                               info->uiapp_info->submode_mainid = NULL;
+               if (strcmp(colname[i], "app_component") == 0) {
+                       if (coltxt[i]) {
+                               if (strcmp(coltxt[i], "uiapp") == 0) {
+                                       uiapp = calloc(1, sizeof(uiapplication_x));
+                                       if (uiapp == NULL) {
+                                               _LOGE("Out of Memory!!!\n");
+                                               return -1;
+                                       }
+                                       LISTADD(info->manifest_info->uiapplication, uiapp);
+                                       for(j = 0; j < ncols; j++)
+                                       {
+                                               if (strcmp(colname[j], "app_id") == 0) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->appid = strdup(coltxt[j]);
+                                               } else if (strcmp(colname[j], "app_exec") == 0) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->exec = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->exec = NULL;
+                                               } else if (strcmp(colname[j], "app_nodisplay") == 0) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->nodisplay = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->nodisplay = NULL;
+                                               } else if (strcmp(colname[j], "app_type") == 0 ) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->type = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->type = NULL;
+                                               } else if (strcmp(colname[j], "app_multiple") == 0 ) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->multiple = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->multiple = NULL;
+                                               } else if (strcmp(colname[j], "app_taskmanage") == 0 ) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->taskmanage = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->taskmanage = NULL;
+                                               } else if (strcmp(colname[j], "app_hwacceleration") == 0 ) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->hwacceleration = NULL;
+                                               } else if (strcmp(colname[j], "app_screenreader") == 0 ) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->screenreader = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->screenreader = NULL;
+                                               } else if (strcmp(colname[j], "app_enabled") == 0 ) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->enabled= strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->enabled = NULL;
+                                               } else if (strcmp(colname[j], "app_indicatordisplay") == 0){
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->indicatordisplay = NULL;
+                                               } else if (strcmp(colname[j], "app_portraitimg") == 0){
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->portraitimg = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->portraitimg = NULL;
+                                               } else if (strcmp(colname[j], "app_landscapeimg") == 0){
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->landscapeimg = NULL;
+                                               } else if (strcmp(colname[j], "app_guestmodevisibility") == 0){
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->guestmode_visibility = NULL;
+                                               } else if (strcmp(colname[j], "app_recentimage") == 0 ) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->recentimage = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->recentimage = NULL;
+                                               } else if (strcmp(colname[j], "app_mainapp") == 0 ) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->mainapp = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->mainapp = NULL;
+                                               } else if (strcmp(colname[j], "package") == 0 ) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->package = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->package = NULL;
+                                               } else if (strcmp(colname[j], "app_component") == 0) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->app_component = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->app_component = NULL;
+                                               } else if (strcmp(colname[j], "app_permissiontype") == 0 ) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->permission_type = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->permission_type = NULL;
+                                               } else if (strcmp(colname[j], "component_type") == 0 ) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->component_type = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->component_type = NULL;
+                                               } else if (strcmp(colname[j], "app_preload") == 0 ) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->preload = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->preload = NULL;
+                                               } else if (strcmp(colname[j], "app_submode") == 0 ) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->submode = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->submode = NULL;
+                                               } else if (strcmp(colname[j], "app_submode_mainid") == 0 ) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->submode_mainid = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->submode_mainid = NULL;
+                                               } else if (strcmp(colname[j], "app_launch_mode") == 0 ) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->uiapplication->launch_mode = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->uiapplication->launch_mode = NULL;
+                                               } else
+                                                       continue;
+                                       }
+                               } else {
+                                       svcapp = calloc(1, sizeof(serviceapplication_x));
+                                       if (svcapp == NULL) {
+                                               _LOGE("Out of Memory!!!\n");
+                                               return -1;
+                                       }
+                                       LISTADD(info->manifest_info->serviceapplication, svcapp);
+                                       for(j = 0; j < ncols; j++)
+                                       {
+                                               if (strcmp(colname[j], "app_id") == 0) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->serviceapplication->appid = strdup(coltxt[j]);
+                                               } else if (strcmp(colname[j], "app_exec") == 0) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->serviceapplication->exec = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->serviceapplication->exec = NULL;
+                                               } else if (strcmp(colname[j], "app_type") == 0 ){
+                                                       if (coltxt[j])
+                                                               info->manifest_info->serviceapplication->type = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->serviceapplication->type = NULL;
+                                               } else if (strcmp(colname[j], "app_onboot") == 0 ){
+                                                       if (coltxt[j])
+                                                               info->manifest_info->serviceapplication->onboot = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->serviceapplication->onboot = NULL;
+                                               } else if (strcmp(colname[j], "app_autorestart") == 0 ){
+                                                       if (coltxt[j])
+                                                               info->manifest_info->serviceapplication->autorestart = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->serviceapplication->autorestart = NULL;
+                                               } else if (strcmp(colname[j], "package") == 0 ){
+                                                       if (coltxt[j])
+                                                               info->manifest_info->serviceapplication->package = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->serviceapplication->package = NULL;
+                                               } else if (strcmp(colname[j], "app_permissiontype") == 0 ) {
+                                                       if (coltxt[j])
+                                                               info->manifest_info->serviceapplication->permission_type = strdup(coltxt[j]);
+                                                       else
+                                                               info->manifest_info->serviceapplication->permission_type = NULL;
+                                               } else
+                                                       continue;
+                                       }
+                               }
+                       }
                } else
                        continue;
        }
@@ -1346,6 +1883,34 @@ static int __mini_appinfo_cb(void *data, int ncols, char **coltxt, char **colnam
        return 0;
 }
 
+static void __parse_appcontrol(appcontrol_x **appcontrol, char *appcontrol_str)
+{
+       char *dup;
+       char *token;
+       char *ptr;
+       appcontrol_x *ac;
+
+       if (appcontrol_str == NULL)
+               return;
+
+       dup = strdup(appcontrol_str);
+       do {
+               ac = calloc(1, sizeof(appcontrol_x));
+               token = strtok_r(dup, "|", &ptr);
+               if (strcmp(token, "NULL"))
+                       ac->operation = strdup(token);
+               token = strtok_r(NULL, "|", &ptr);
+               if (strcmp(token, "NULL"))
+                       ac->uri = strdup(token);
+               token = strtok_r(NULL, "|", &ptr);
+               if (strcmp(token, "NULL"))
+                       ac->mime = strdup(token);
+               LISTADD(*appcontrol, ac);
+       } while (token = strtok_r(NULL, ";", &ptr));
+
+       free(dup);
+}
+
 static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
 {
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
@@ -1356,6 +1921,7 @@ static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
        metadata_x *metadata = NULL;
        permission_x *permission = NULL;
        image_x *image = NULL;
+       appcontrol_x *appcontrol = NULL;
 
        switch (info->app_component) {
        case PMINFO_UI_APP:
@@ -1429,6 +1995,11 @@ static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
                                        info->uiapp_info->hwacceleration = strdup(coltxt[i]);
                                else
                                        info->uiapp_info->hwacceleration = NULL;
+                       } else if (strcmp(colname[i], "app_screenreader") == 0 ) {
+                               if (coltxt[i])
+                                       info->uiapp_info->screenreader = strdup(coltxt[i]);
+                               else
+                                       info->uiapp_info->screenreader = NULL;
                        } else if (strcmp(colname[i], "app_enabled") == 0 ) {
                                if (coltxt[i])
                                        info->uiapp_info->enabled= strdup(coltxt[i]);
@@ -1533,6 +2104,13 @@ static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
                                        info->uiapp_info->submode_mainid = strdup(coltxt[i]);
                                else
                                        info->uiapp_info->submode_mainid = NULL;
+                       } else if (strcmp(colname[i], "app_launch_mode") == 0 ) {
+                               if (coltxt[i])
+                                       info->uiapp_info->launch_mode = strdup(coltxt[i]);
+                               else
+                                       info->uiapp_info->launch_mode = NULL;
+                       } else if (strcmp(colname[i], "app_control") == 0 ) {
+                               __parse_appcontrol(&info->uiapp_info->appcontrol, coltxt[i]);
                        } else
                                continue;
                }
@@ -1634,6 +2212,8 @@ static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
                                        info->svcapp_info->permission_type = strdup(coltxt[i]);
                                else
                                        info->svcapp_info->permission_type = NULL;
+                       } else if (strcmp(colname[i], "app_control") == 0 ) {
+                               __parse_appcontrol(&info->svcapp_info->appcontrol, coltxt[i]);
                        } else
                                continue;
                }
@@ -1724,7 +2304,7 @@ static int __exec_pkginfo_query(char *query, void *data)
 {
        char *error_message = NULL;
        if (SQLITE_OK !=
-           sqlite3_exec(manifest_db, query, __pkginfo_cb, data, &error_message)) {
+           sqlite3_exec(GET_DB(manifest_db), query, __pkginfo_cb, data, &error_message)) {
                _LOGE("Don't execute query = %s error message = %s\n", query,
                       error_message);
                sqlite3_free(error_message);
@@ -1738,7 +2318,7 @@ static int __exec_certinfo_query(char *query, void *data)
 {
        char *error_message = NULL;
        if (SQLITE_OK !=
-           sqlite3_exec(cert_db, query, __certinfo_cb, data, &error_message)) {
+           sqlite3_exec(GET_DB(cert_db), query, __certinfo_cb, data, &error_message)) {
                _LOGE("Don't execute query = %s error message = %s\n", query,
                       error_message);
                sqlite3_free(error_message);
@@ -1752,7 +2332,7 @@ static int __exec_certindexinfo_query(char *query, void *data)
 {
        char *error_message = NULL;
        if (SQLITE_OK !=
-           sqlite3_exec(cert_db, query, __certindexinfo_cb, data, &error_message)) {
+           sqlite3_exec(GET_DB(cert_db), query, __certindexinfo_cb, data, &error_message)) {
                _LOGE("Don't execute query = %s error message = %s\n", query,
                       error_message);
                sqlite3_free(error_message);
@@ -1765,10 +2345,10 @@ static int __exec_certindexinfo_query(char *query, void *data)
 static int __exec_db_query(sqlite3 *db, char *query, sqlite_query_callback callback, void *data)
 {
        char *error_message = NULL;
-       if (SQLITE_OK !=
-           sqlite3_exec(db, query, callback, data, &error_message)) {
-               _LOGE("Don't execute query = %s error message = %s\n", query,
-                      error_message);
+       int ret = sqlite3_exec(db, query, callback, data, &error_message);
+       if (SQLITE_OK != ret) {
+               _LOGE("Don't execute query = %s error message = %s   ret = %d\n", query,
+                      error_message, ret);
                sqlite3_free(error_message);
                return -1;
        }
@@ -1975,7 +2555,7 @@ long long _pkgmgr_calculate_dir_size(char *dirname)
 
 }
 
-static int __delete_certinfo(const char *pkgid)
+static int __delete_certinfo(const char *pkgid, uid_t uid)
 {
        int ret = -1;
        int i = 0;
@@ -1994,6 +2574,8 @@ static int __delete_certinfo(const char *pkgid)
                ret = PMINFO_R_ERROR;
                goto err;
        }
+
+       __open_cert_db(uid, "w");
        /*populate certinfo from DB*/
        snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
        ret = __exec_certinfo_query(query, (void *)certinfo);
@@ -2033,7 +2615,7 @@ static int __delete_certinfo(const char *pkgid)
                                snprintf(query, MAX_QUERY_LEN, "delete from  package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
                        }
                        if (SQLITE_OK !=
-                           sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
+                           sqlite3_exec(GET_DB(cert_db), query, NULL, NULL, &error_message)) {
                                _LOGE("Don't execute query = %s error message = %s\n", query,
                                       error_message);
                                sqlite3_free(error_message);
@@ -2045,7 +2627,7 @@ static int __delete_certinfo(const char *pkgid)
        /*Now delete the entry from db*/
        snprintf(query, MAX_QUERY_LEN, "delete from package_cert_info where package='%s'", pkgid);
         if (SQLITE_OK !=
-            sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
+            sqlite3_exec(GET_DB(cert_db), query, NULL, NULL, &error_message)) {
                 _LOGE("Don't execute query = %s error message = %s\n", query,
                        error_message);
                sqlite3_free(error_message);
@@ -2068,16 +2650,38 @@ err:
                        (certinfo->cert_info)[i] = NULL;
                }
        }
+       __close_cert_db();
        free(certinfo);
        certinfo = NULL;
        return ret;
 }
 
-API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
+static int __get_pkg_location(const char *pkgid)
+{
+       retvm_if(pkgid == NULL, PMINFO_R_OK, "pkginfo handle is NULL");
+
+       FILE *fp = NULL;
+       char pkg_mmc_path[FILENAME_MAX] = { 0, };
+       snprintf(pkg_mmc_path, FILENAME_MAX, "%s%s", PKG_SD_PATH, pkgid);
+
+       /*check whether application is in external memory or not */
+       fp = fopen(pkg_mmc_path, "r");
+       if (fp != NULL) {
+               fclose(fp);
+               fp = NULL;
+               return PMINFO_EXTERNAL_STORAGE;
+       }
+
+       return PMINFO_INTERNAL_STORAGE;
+}
+
+API int pkgmgrinfo_pkginfo_get_usr_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data, uid_t uid)
 {
        retvm_if(pkg_list_cb == NULL, PMINFO_R_EINVAL, "callback function is NULL\n");
        char *error_message = NULL;
        int ret = PMINFO_R_OK;
+       int ret_db = 0;
+
        char query[MAX_QUERY_LEN] = {'\0'};
        char *syslocale = NULL;
        char *locale = NULL;
@@ -2091,21 +2695,21 @@ API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *us
        syslocale = vconf_get_str(VCONFKEY_LANGSET);
        if (syslocale == NULL) {
                _LOGE("current locale is NULL\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
+               return PMINFO_R_ERROR;
        }
        locale = __convert_system_locale_to_manifest_locale(syslocale);
        if (locale == NULL) {
                _LOGE("manifest locale is NULL\n");
-               ret = PMINFO_R_EINVAL;
-               goto err;
+               free(syslocale);
+               return PMINFO_R_ERROR;
        }
 
-       ret = __open_manifest_db();
-       if (ret == -1) {
+       ret_db = __open_manifest_db(uid);
+       if (ret_db == -1) {
                _LOGE("Fail to open manifest DB\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
+               free(syslocale);
+               free(locale);
+               return PMINFO_R_ERROR;
        }
        pkgmgr_pkginfo_x *tmphead = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
        pkgmgr_pkginfo_x *node = NULL;
@@ -2113,11 +2717,10 @@ API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *us
 
        snprintf(query, MAX_QUERY_LEN, "select * from package_info");
        if (SQLITE_OK !=
-           sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)tmphead, &error_message)) {
+           sqlite3_exec(GET_DB(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;
        }
@@ -2195,6 +2798,7 @@ API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *us
 
        for(node = node->next; node ; node = node->next) {
                pkginfo = node;
+               pkginfo->uid = uid;
                ret = pkg_list_cb( (void *)pkginfo, user_data);
                if(ret < 0)
                        break;
@@ -2203,7 +2807,7 @@ API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *us
        ret = PMINFO_R_OK;
 
 err:
-       sqlite3_close(manifest_db);
+       __close_manifest_db();
        if (syslocale) {
                free(syslocale);
                syslocale = NULL;
@@ -2224,8 +2828,12 @@ err:
        return ret;
 }
 
+API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
+{
+       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");
@@ -2240,15 +2848,18 @@ API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *
        description_x *tmp3 = NULL;
        author_x *tmp4 = NULL;
        privilege_x *tmp5 = NULL;
-       sqlite3 *pkginfo_db = NULL;
+       const char* user_pkg_parser = NULL;
+
+       *handle = NULL;
 
        /*validate pkgid*/
-       ret = db_util_open_with_options(MANIFEST_DB, &pkginfo_db, SQLITE_OPEN_READONLY, NULL);
-       retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
+       user_pkg_parser = getUserPkgParserDBPathUID(uid);
+       ret = __open_manifest_db(uid);
+         retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", user_pkg_parser);
 
        /*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);
+       ret = __exec_db_query(GET_DB(manifest_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);
 
@@ -2274,26 +2885,26 @@ API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *
 
        /*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);
+       ret = __exec_db_query(GET_DB(manifest_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);
+       ret = __exec_db_query(GET_DB(manifest_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);
+       ret = __exec_db_query(GET_DB(manifest_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);
+       ret = __exec_db_query(GET_DB(manifest_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) {
@@ -2324,8 +2935,7 @@ catch:
                *handle = NULL;
                __cleanup_pkginfo(pkginfo);
        }
-       sqlite3_close(pkginfo_db);
-
+       __close_manifest_db();
        if (syslocale) {
                free(syslocale);
                syslocale = NULL;
@@ -2337,6 +2947,10 @@ catch:
        return ret;
 }
 
+API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle)
+{
+       return pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, GLOBAL_USER, handle);
+}
 
 API int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_name)
 {
@@ -2408,9 +3022,7 @@ API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *si
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
        char *val = NULL;
-       char *location = NULL;
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-       location = (char *)info->manifest_info->installlocation;
        val = (char *)info->manifest_info->package_size;
        if (val) {
                *size = atoi(val);
@@ -2666,7 +3278,7 @@ API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **d
                if (ptr->lang) {
                        if (strcmp(ptr->lang, locale) == 0) {
                                *description = (char *)ptr->text;
-                               if (strcasecmp(*description, "(null)") == 0) {
+                               if (strcasecmp(*description, PKGMGR_PARSER_EMPTY_STR) == 0) {
                                        locale = DEFAULT_LOCALE;
                                        continue;
                                } else
@@ -2697,7 +3309,7 @@ API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **a
                if (ptr->lang) {
                        if (strcmp(ptr->lang, locale) == 0) {
                                *author_name = (char *)ptr->text;
-                               if (strcasecmp(*author_name, "(null)") == 0) {
+                               if (strcasecmp(*author_name, PKGMGR_PARSER_EMPTY_STR) == 0) {
                                        locale = DEFAULT_LOCALE;
                                        continue;
                                } else
@@ -2734,52 +3346,16 @@ API int pkgmgrinfo_pkginfo_get_installed_storage(pkgmgrinfo_pkginfo_h handle, pk
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(storage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
-       char *pkgid = NULL;
-       pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
-       if (pkgid == NULL){
-                _LOGE("invalid func parameters\n");
-                return PMINFO_R_ERROR;
-       }
-
-       FILE *fp = NULL;
-       char app_mmc_path[FILENAME_MAX] = { 0, };
-       char app_dir_path[FILENAME_MAX] = { 0, };
-       char app_mmc_internal_path[FILENAME_MAX] = { 0, };
-       snprintf(app_dir_path, FILENAME_MAX,
-       "%s%s", PKG_INSTALLATION_PATH, pkgid);
-       snprintf(app_mmc_path, FILENAME_MAX,
-       "%s%s", PKG_SD_PATH, pkgid);
-       snprintf(app_mmc_internal_path, FILENAME_MAX,
-       "%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid);
+       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
 
-       /*check whether application is in external memory or not */
-       fp = fopen(app_mmc_path, "r");
-       if (fp != NULL) {
-               fclose(fp);
-               fp = NULL;
-               *storage = PMINFO_EXTERNAL_STORAGE;
-               return PMINFO_R_OK;
-       }
+        if (strcmp(info->manifest_info->installed_storage,"installed_internal") == 0)
+               *storage = PMINFO_INTERNAL_STORAGE;
+        else if (strcmp(info->manifest_info->installed_storage,"installed_external") == 0)
+                *storage = PMINFO_EXTERNAL_STORAGE;
+        else
+                return PMINFO_R_ERROR;
 
-       /*check whether application is in internal or not */
-       fp = fopen(app_dir_path, "r");
-       if (fp == NULL) {
-               *storage = -1;
-               return PMINFO_R_ERROR;
-       } else {
-               fclose(fp);
-               /*check whether the application is installed in SD card
-                       but SD card is not present*/
-               fp = fopen(app_mmc_internal_path, "r");
-               if (fp == NULL) {
-                       *storage = PMINFO_INTERNAL_STORAGE;
-                       return PMINFO_R_OK;
-               } else {
-                       fclose(fp);
-                       *storage = PMINFO_EXTERNAL_STORAGE;
-                       return PMINFO_R_OK;
-               }
-       }
+       return PMINFO_R_OK;
 }
 
 API int pkgmgrinfo_pkginfo_get_installed_time(pkgmgrinfo_pkginfo_h handle, int *installed_time)
@@ -2956,7 +3532,7 @@ 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)
+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");
        retvm_if(rhs_package_id == NULL, PMINFO_R_EINVAL, "rhs package ID is NULL");
@@ -2965,25 +3541,147 @@ API int pkgmgrinfo_pkginfo_compare_pkg_cert_info(const char *lhs_package_id, con
        int ret = PMINFO_R_OK;
        char query[MAX_QUERY_LEN] = {'\0'};
        char *error_message = NULL;
-       pkgmgr_cert_x *info= NULL;
+       sqlite3_stmt *stmt = NULL;
+       char *lhs_certinfo = NULL;
+       char *rhs_certinfo = NULL;
        int lcert = 0;
        int rcert = 0;
        int exist = -1;
+       int i;
+       int is_global = 0;
        *compare_result = PMINFO_CERT_COMPARE_ERROR;
+
+       ret = __open_cert_db(uid, "r");
+       if (ret != 0) {
+               ret = PMINFO_R_ERROR;
+               goto err;
+       }
+       _check_create_Cert_db(GET_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(GET_DB(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;
+       }
+       lcert = exist;
+
+       snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", rhs_package_id);
+       if (SQLITE_OK !=
+               sqlite3_exec(GET_DB(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;
+       }
+       rcert = exist;
+
+       if (uid == GLOBAL_USER || uid == ROOT_UID) {
+               snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=(select author_signer_cert from package_cert_info where package=?)");
+               is_global = 1;
+       } else
+               snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=(select author_signer_cert from package_cert_info where package=?) and for_all_users=(select for_all_users from package_cert_info where package=?)");
+       if (SQLITE_OK != sqlite3_prepare_v2(GET_DB(cert_db), query, strlen(query), &stmt, NULL)) {
+               _LOGE("sqlite3_prepare_v2 error: %s", sqlite3_errmsg(GET_DB(cert_db)));
+               ret = PMINFO_R_ERROR;
+               goto err;
+       }
+
+       for (i = 1; i <= 2 - is_global; i++) {
+               if (SQLITE_OK != sqlite3_bind_text(stmt, i, lhs_package_id, -1, SQLITE_STATIC)) {
+                       _LOGE("sqlite3_bind_text error: %s", sqlite3_errmsg(GET_DB(cert_db)));
+                       ret = PMINFO_R_ERROR;
+                       goto err;
+               }
+       }
+       if (SQLITE_ROW != sqlite3_step(stmt) || sqlite3_column_text(stmt, 0) == NULL) {
+               _LOGE("sqlite3_step error: %s", sqlite3_errmsg(GET_DB(cert_db)));
+               ret = PMINFO_R_ERROR;
+               goto err;
+       }
+
+       lhs_certinfo = strdup((const char *)sqlite3_column_text(stmt, 0));
+       sqlite3_reset(stmt);
+       sqlite3_clear_bindings(stmt);
+
+       for (i = 1; i <= 2 - is_global; i++) {
+               if (SQLITE_OK != sqlite3_bind_text(stmt, i, rhs_package_id, -1, SQLITE_STATIC)) {
+                       _LOGE("sqlite3_bind_text error: %s", sqlite3_errmsg(GET_DB(cert_db)));
+                       ret = PMINFO_R_ERROR;
+                       goto err;
+               }
+       }
+       if (SQLITE_ROW != sqlite3_step(stmt) || sqlite3_column_text(stmt, 0) == NULL) {
+               _LOGE("sqlite3_step error: %s", sqlite3_errmsg(GET_DB(cert_db)));
+               ret = PMINFO_R_ERROR;
+               goto err;
+       }
+
+       rhs_certinfo = strdup((const char *)sqlite3_column_text(stmt, 0));
+
+       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 (!strcmp(lhs_certinfo, rhs_certinfo))
+                       *compare_result = PMINFO_CERT_COMPARE_MATCH;
+               else
+                       *compare_result = PMINFO_CERT_COMPARE_MISMATCH;
+       }
+
+err:
+       if (stmt)
+               sqlite3_finalize(stmt);
+       if (lhs_certinfo)
+               free(lhs_certinfo);
+       if (rhs_certinfo)
+               free(rhs_certinfo);
+       sqlite3_free(error_message);
+       __close_cert_db();
+
+       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");
+       retvm_if(rhs_app_id == NULL, PMINFO_R_EINVAL, "rhs app 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 exist = -1;
+       char *lpkgid = NULL;
+       char *rpkgid = NULL;
+       const char* user_pkg_parser = getUserPkgParserDBPath();
+
        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(CERT_DB, &cert_db,
+       ret = db_util_open_with_options(user_pkg_parser, &GET_DB(manifest_db),
                                        SQLITE_OPEN_READONLY, NULL);
        if (ret != SQLITE_OK) {
-               _LOGE("connect db [%s] failed!\n", CERT_DB);
+               _LOGE("connect db [%s] failed!\n", user_pkg_parser);
                ret = PMINFO_R_ERROR;
                goto err;
        }
 
-       snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", lhs_package_id);
+       snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", lhs_app_id);
        if (SQLITE_OK !=
-           sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
+           sqlite3_exec(GET_DB(manifest_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;
@@ -2991,60 +3689,59 @@ API int pkgmgrinfo_pkginfo_compare_pkg_cert_info(const char *lhs_package_id, con
        }
 
        if (exist == 0) {
-               lcert = 0;
+               lpkgid = NULL;
        } else {
-               snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", lhs_package_id);
+               snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", lhs_app_id);
                if (SQLITE_OK !=
-                       sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
+                       sqlite3_exec(GET_DB(manifest_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;
+               lpkgid = strdup(info->pkgid);
+               if (lpkgid == NULL) {
+                       _LOGE("Out of Memory\n");
+                       ret = PMINFO_R_ERROR;
+                       goto err;
+               }
+               free(info->pkgid);
+               info->pkgid = NULL;
        }
 
-       snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", rhs_package_id);
+       snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", rhs_app_id);
        if (SQLITE_OK !=
-               sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
+           sqlite3_exec(GET_DB(manifest_db), query, __validate_cb, (void *)&exist, &error_message)) {
                _LOGE("Don't execute query = %s error message = %s\n", query,
-                          error_message);
+                      error_message);
                ret = PMINFO_R_ERROR;
                goto err;
        }
 
        if (exist == 0) {
-               rcert = 0;
+               rpkgid = NULL;
        } else {
-               snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", rhs_package_id);
+               snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", rhs_app_id);
                if (SQLITE_OK !=
-                       sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
+                       sqlite3_exec(GET_DB(manifest_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;
+               rpkgid = strdup(info->pkgid);
+               if (rpkgid == NULL) {
+                       _LOGE("Out of Memory\n");
+                       ret = PMINFO_R_ERROR;
+                       goto err;
+               }
+               free(info->pkgid);
+               info->pkgid = NULL;
        }
-
-err:
+       ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lpkgid, rpkgid, compare_result);
+ err:
        sqlite3_free(error_message);
-       sqlite3_close(cert_db);
+       __close_manifest_db();
        if (info) {
                if (info->pkgid) {
                        free(info->pkgid);
@@ -3053,11 +3750,18 @@ err:
                free(info);
                info = NULL;
        }
+       if (lpkgid) {
+               free(lpkgid);
+               lpkgid = NULL;
+       }
+       if (rpkgid) {
+               free(rpkgid);
+               rpkgid = NULL;
+       }
        return ret;
 }
 
-
-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)
+API int pkgmgrinfo_pkginfo_compare_usr_app_cert_info(const char *lhs_app_id, const char *rhs_app_id, uid_t uid, pkgmgrinfo_cert_compare_result_type_e *compare_result)
 {
        retvm_if(lhs_app_id == NULL, PMINFO_R_EINVAL, "lhs app ID is NULL");
        retvm_if(rhs_app_id == NULL, PMINFO_R_EINVAL, "rhs app ID is NULL");
@@ -3074,17 +3778,16 @@ API int pkgmgrinfo_pkginfo_compare_app_cert_info(const char *lhs_app_id, const c
        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(MANIFEST_DB, &manifest_db,
-                                       SQLITE_OPEN_READONLY, NULL);
+       ret = __open_manifest_db(uid);
        if (ret != SQLITE_OK) {
-               _LOGE("connect db [%s] failed!\n", MANIFEST_DB);
+               _LOGE("connect db [%s] failed!\n", getUserPkgParserDBPathUID(uid));
                ret = PMINFO_R_ERROR;
                goto err;
        }
 
        snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", lhs_app_id);
        if (SQLITE_OK !=
-           sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) {
+           sqlite3_exec(GET_DB(manifest_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;
@@ -3096,7 +3799,7 @@ API int pkgmgrinfo_pkginfo_compare_app_cert_info(const char *lhs_app_id, const c
        } else {
                snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", lhs_app_id);
                if (SQLITE_OK !=
-                       sqlite3_exec(manifest_db, query, __cert_cb, (void *)info, &error_message)) {
+                       sqlite3_exec(GET_DB(manifest_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;
@@ -3114,7 +3817,7 @@ API int pkgmgrinfo_pkginfo_compare_app_cert_info(const char *lhs_app_id, const c
 
        snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", rhs_app_id);
        if (SQLITE_OK !=
-           sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) {
+           sqlite3_exec(GET_DB(manifest_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;
@@ -3126,7 +3829,7 @@ API int pkgmgrinfo_pkginfo_compare_app_cert_info(const char *lhs_app_id, const c
        } else {
                snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", rhs_app_id);
                if (SQLITE_OK !=
-                       sqlite3_exec(manifest_db, query, __cert_cb, (void *)info, &error_message)) {
+                       sqlite3_exec(GET_DB(manifest_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;
@@ -3141,10 +3844,10 @@ API int pkgmgrinfo_pkginfo_compare_app_cert_info(const char *lhs_app_id, const c
                free(info->pkgid);
                info->pkgid = NULL;
        }
-       ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lpkgid, rpkgid, compare_result);
+       ret = pkgmgrinfo_pkginfo_compare_usr_pkg_cert_info(lpkgid, rpkgid, uid, compare_result);
  err:
        sqlite3_free(error_message);
-       sqlite3_close(manifest_db);
+       __close_manifest_db();
        if (info) {
                if (info->pkgid) {
                        free(info->pkgid);
@@ -3168,6 +3871,8 @@ API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *acce
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
        retvm_if(accessible == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+#if 0 //smack issue occured, check later
        char *pkgid = NULL;
        pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
        if (pkgid == NULL){
@@ -3220,6 +3925,9 @@ API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *acce
        }
 
        _LOGD("pkgmgr_get_pkg_external_validation() end\n");
+#endif
+
+       *accessible = 1;
        return PMINFO_R_OK;
 }
 
@@ -3280,6 +3988,26 @@ API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload
        return PMINFO_R_OK;
 }
 
+API int pkgmgrinfo_pkginfo_is_system(pkgmgrinfo_pkginfo_h handle, bool *system)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+       retvm_if(system == 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->system;
+       if (val) {
+               if (strcasecmp(val, "true") == 0)
+                       *system = 1;
+               else if (strcasecmp(val, "false") == 0)
+                       *system = 0;
+               else
+                       *system = 0;
+       }
+
+       return PMINFO_R_OK;
+}
+
 API int pkgmgrinfo_pkginfo_is_readonly(pkgmgrinfo_pkginfo_h handle, bool *readonly)
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
@@ -3317,6 +4045,26 @@ API int pkgmgrinfo_pkginfo_is_update(pkgmgrinfo_pkginfo_h handle, bool *update)
        return PMINFO_R_OK;
 }
 
+API int pkgmgrinfo_pkginfo_is_for_all_users(pkgmgrinfo_pkginfo_h handle, bool *for_all_users)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+       retvm_if(for_all_users == 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->for_all_users;
+       if (val) {
+               if (strcasecmp(val, "1") == 0)
+                       *for_all_users = 1;
+               else if (strcasecmp(val, "0") == 0)
+                       *for_all_users = 0;
+               else
+                       *for_all_users = 1;
+       }
+       return PMINFO_R_OK;
+}
+
+
 API int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h handle)
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
@@ -3485,7 +4233,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");
@@ -3499,6 +4247,7 @@ API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int
        int ret = 0;
 
        pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
+       filter->uid = uid;
        /*Get current locale*/
        syslocale = vconf_get_str(VCONFKEY_LANGSET);
        if (syslocale == NULL) {
@@ -3512,11 +4261,12 @@ API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int
                return PMINFO_R_ERROR;
        }
 
-       ret = __open_manifest_db();
+       ret = __open_manifest_db(uid);
        if (ret == -1) {
                _LOGE("Fail to open manifest DB\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
+               free(syslocale);
+               free(locale);
+               return PMINFO_R_ERROR;
        }
 
        /*Start constructing query*/
@@ -3536,20 +4286,17 @@ API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int
                        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)) {
+           sqlite3_exec(GET_DB(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;
@@ -3564,12 +4311,17 @@ err:
                free(syslocale);
                syslocale = NULL;
        }
-       sqlite3_close(manifest_db);
+       __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)
+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(pkg_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
@@ -3604,11 +4356,12 @@ API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h ha
                return PMINFO_R_ERROR;
        }
 
-       ret = __open_manifest_db();
+       ret = __open_manifest_db(uid);
        if (ret == -1) {
                _LOGE("Fail to open manifest DB\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
+               free(syslocale);
+               free(locale);
+               return PMINFO_R_ERROR;
        }
        /*Start constructing query*/
        snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_PACKAGE, locale);
@@ -3627,12 +4380,10 @@ API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h ha
                        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");
@@ -3640,12 +4391,12 @@ API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h ha
                goto err;
        }
 
+       tmphead->uid = uid;
        if (SQLITE_OK !=
-           sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)tmphead, &error_message)) {
+           sqlite3_exec(GET_DB(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;
        }
@@ -3714,6 +4465,7 @@ API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h ha
 
        for(node = node->next ; node ; node = node->next) {
                pkginfo = node;
+               pkginfo->uid = uid;
                ret = pkg_cb( (void *)pkginfo, user_data);
                if(ret < 0)
                        break;
@@ -3729,11 +4481,17 @@ err:
                free(syslocale);
                syslocale = NULL;
        }
-       sqlite3_close(manifest_db);
+       __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,
                        pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data)
 {
@@ -3753,8 +4511,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");
@@ -3773,11 +4531,12 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_
        metadata_x *ptr4 = NULL;
        permission_x *ptr5 = NULL;
        image_x *ptr6 = NULL;
-       sqlite3 *appinfo_db = NULL;
+       appcontrol_x *ptr7 = NULL;
+       const char* user_pkg_parser = NULL;
 
        /*get system locale*/
        syslocale = vconf_get_str(VCONFKEY_LANGSET);
-       tryvm_if(syslocale == NULL, ret = PMINFO_R_EINVAL, "current locale is NULL");
+       retvm_if(syslocale == NULL, PMINFO_R_EINVAL, "current locale is NULL");
 
        /*get locale on db*/
        locale = __convert_system_locale_to_manifest_locale(syslocale);
@@ -3804,8 +4563,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(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
-       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
+       user_pkg_parser = getUserPkgParserDBPathUID(uid);
+       ret = __open_manifest_db(uid);
+       tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", user_pkg_parser);
 
        appinfo->package = strdup(info->manifest_info->package);
        snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
@@ -3817,7 +4577,7 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_
        switch(component) {
        case PMINFO_UI_APP:
                /*Populate ui app info */
-               ret = __exec_db_query(appinfo_db, query, __uiapp_list_cb, (void *)info);
+               ret = __exec_db_query(GET_DB(manifest_db), query, __uiapp_list_cb, (void *)info);
                tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
 
                uiapplication_x *tmp = NULL;
@@ -3835,31 +4595,37 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_
                                if (locale) {
                                        free(locale);
                                }
-                               locale = __get_app_locale_by_fallback(appinfo_db, appinfo->uiapp_info->appid, syslocale);
+                               locale = __get_app_locale_by_fallback(GET_DB(manifest_db), appinfo->uiapp_info->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);
+                       ret = __exec_db_query(GET_DB(manifest_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);
+                       ret = __exec_db_query(GET_DB(manifest_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);
+                       ret = __exec_db_query(GET_DB(manifest_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);
+                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
                        tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
 
+                       /*store app control info*/
+                       snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->uiapp_info->appid);
+                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
+                       memset(query, '\0', MAX_QUERY_LEN);
                        if (appinfo->uiapp_info->label) {
                                LISTHEAD(appinfo->uiapp_info->label, ptr2);
                                appinfo->uiapp_info->label = ptr2;
@@ -3884,6 +4650,10 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_
                                LISTHEAD(appinfo->uiapp_info->image, ptr6);
                                appinfo->uiapp_info->image = ptr6;
                        }
+                       if (appinfo->uiapp_info->appcontrol) {
+                               LISTHEAD(appinfo->uiapp_info->appcontrol, ptr7);
+                               appinfo->uiapp_info->appcontrol = ptr7;
+                       }
                        ret = app_func((void *)appinfo, user_data);
                        if (ret < 0)
                                break;
@@ -3892,7 +4662,7 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_
                break;
        case PMINFO_SVC_APP:
                /*Populate svc app info */
-               ret = __exec_db_query(appinfo_db, query, __svcapp_list_cb, (void *)info);
+               ret = __exec_db_query(GET_DB(manifest_db), query, __svcapp_list_cb, (void *)info);
                tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
 
                serviceapplication_x *tmp1 = NULL;
@@ -3908,14 +4678,18 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_
                        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);
+                       ret = __exec_db_query(GET_DB(manifest_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);
+                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
                        tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
 
+                       snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->svcapp_info->appid);
+                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
                        if (appinfo->svcapp_info->label) {
                                LISTHEAD(appinfo->svcapp_info->label, ptr2);
                                appinfo->svcapp_info->label = ptr2;
@@ -3936,6 +4710,10 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_
                                LISTHEAD(appinfo->svcapp_info->permission, ptr5);
                                appinfo->svcapp_info->permission = ptr5;
                        }
+                       if (appinfo->svcapp_info->appcontrol) {
+                               LISTHEAD(appinfo->svcapp_info->appcontrol, ptr7);
+                               appinfo->svcapp_info->appcontrol = ptr7;
+                       }
                        ret = app_func((void *)appinfo, user_data);
                        if (ret < 0)
                                break;
@@ -3947,7 +4725,7 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_
                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);
+               ret = __exec_db_query(GET_DB(manifest_db), query, __allapp_list_cb, (void *)allinfo);
                tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
 
                /*UI Apps*/
@@ -3965,26 +4743,31 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_
                        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);
+                       ret = __exec_db_query(GET_DB(manifest_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);
+                       ret = __exec_db_query(GET_DB(manifest_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);
+                       ret = __exec_db_query(GET_DB(manifest_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);
+                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
                        tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
 
+                       /*store app control info*/
+                       snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->uiapp_info->appid);
+                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
                        if (appinfo->uiapp_info->label) {
                                LISTHEAD(appinfo->uiapp_info->label, ptr2);
                                appinfo->uiapp_info->label = ptr2;
@@ -4009,6 +4792,10 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_
                                LISTHEAD(appinfo->uiapp_info->image, ptr6);
                                appinfo->uiapp_info->image = ptr6;
                        }
+                       if (appinfo->uiapp_info->appcontrol) {
+                               LISTHEAD(appinfo->uiapp_info->appcontrol, ptr7);
+                               appinfo->uiapp_info->appcontrol = ptr7;
+                       }
                        ret = app_func((void *)appinfo, user_data);
                        if (ret < 0)
                                break;
@@ -4030,14 +4817,18 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_
                        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);
+                       ret = __exec_db_query(GET_DB(manifest_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);
+                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
                        tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
 
+                       snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->svcapp_info->appid);
+                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
                        if (appinfo->svcapp_info->label) {
                                LISTHEAD(appinfo->svcapp_info->label, ptr2);
                                appinfo->svcapp_info->label = ptr2;
@@ -4058,6 +4849,10 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_
                                LISTHEAD(appinfo->svcapp_info->permission, ptr5);
                                appinfo->svcapp_info->permission = ptr5;
                        }
+                       if (appinfo->svcapp_info->appcontrol) {
+                               LISTHEAD(appinfo->svcapp_info->appcontrol, ptr7);
+                               appinfo->svcapp_info->appcontrol = ptr7;
+                       }
                        ret = app_func((void *)appinfo, user_data);
                        if (ret < 0)
                                break;
@@ -4088,50 +4883,77 @@ catch:
        }
        __cleanup_pkginfo(allinfo);
 
-       sqlite3_close(appinfo_db);
+       __close_manifest_db();
        return ret;
 }
 
-API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
+API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
+                                               pkgmgrinfo_app_list_cb app_func, void *user_data)
+{
+       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 *info = NULL;
        pkgmgr_appinfo_x *appinfo = NULL;
        uiapplication_x *ptr1 = NULL;
-       sqlite3 *appinfo_db = NULL;
+       serviceapplication_x *ptr2 = NULL;
+       const char* user_pkg_parser = NULL;
 
        /*open db*/
-       ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
-       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
+       user_pkg_parser = getUserPkgParserDBPathUID(uid);
+       ret = __open_manifest_db(uid);
+       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", user_pkg_parser);
 
-       /*calloc appinfo*/
-       info = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
+       /*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 uiapplication_x*/
-       info->uiapp_info= (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
-       tryvm_if(info->uiapp_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!!!");
 
-       /*query package_app_info*/
        snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
-       ret = __exec_db_query(appinfo_db, query, __mini_appinfo_cb, (void *)info);
+       ret = __exec_db_query(GET_DB(manifest_db), query, __mini_appinfo_cb, (void *)info);
        tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
 
-       LISTHEAD(info->uiapp_info, ptr1);
+       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;
+       }
 
-       /*call back*/
-       for(ptr1 = ptr1->next ; ptr1 ; ptr1 = ptr1->next)
+       /*UI Apps*/
+       for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
        {
-               appinfo->uiapp_info= ptr1;
-               appinfo->package = strdup(ptr1->package);
                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)
@@ -4139,19 +4961,24 @@ API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, voi
                free((void *)appinfo->package);
                appinfo->package = NULL;
        }
+       ret = PMINFO_R_OK;
 
 catch:
-       sqlite3_close(appinfo_db);
-
+       __close_manifest_db();
        if (appinfo) {
                free(appinfo);
                appinfo = NULL;
        }
-       __cleanup_appinfo(info);
+       __cleanup_pkginfo(info);
        return ret;
 }
 
-API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
+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");
 
@@ -4168,7 +4995,8 @@ API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, v
        metadata_x *tmp4 = NULL;
        permission_x *tmp5 = NULL;
        image_x *tmp6 = NULL;
-       sqlite3 *appinfo_db = NULL;
+       appcontrol_x *tmp7 = NULL;
+       const char *user_pkg_parser = NULL;
 
        /*get system locale*/
        syslocale = vconf_get_str(VCONFKEY_LANGSET);
@@ -4179,8 +5007,9 @@ API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, v
        tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
 
        /*open db*/
-       ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
-       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
+       user_pkg_parser = getUserPkgParserDBPathUID(uid);
+       ret = __open_manifest_db(uid);
+       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", user_pkg_parser);
 
        /*calloc pkginfo*/
        pkgmgr_pkginfo_x *info = NULL;
@@ -4196,7 +5025,7 @@ API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, v
        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);
+       ret = __exec_db_query(GET_DB(manifest_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) {
@@ -4218,14 +5047,14 @@ API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, v
                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);
+               ret = __exec_db_query(GET_DB(manifest_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);
+                       locale = __get_app_locale_by_fallback(GET_DB(manifest_db), ptr1->appid, syslocale);
                }
 
                memset(query, '\0', MAX_QUERY_LEN);
@@ -4233,7 +5062,7 @@ API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, v
                                "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);
+               ret = __exec_db_query(GET_DB(manifest_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);
@@ -4242,21 +5071,26 @@ API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, v
                                "app_id='%s' and app_locale='%s'",
                                ptr1->appid, DEFAULT_LOCALE);
 
-               ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+               ret = __exec_db_query(GET_DB(manifest_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);
+               ret = __exec_db_query(GET_DB(manifest_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);
+               ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
                tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
 
+               /*store app control info*/
+               snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", ptr1->appid);
+               ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
                if (appinfo->uiapp_info->label) {
                        LISTHEAD(appinfo->uiapp_info->label, tmp1);
                        appinfo->uiapp_info->label = tmp1;
@@ -4281,6 +5115,10 @@ API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, v
                        LISTHEAD(appinfo->uiapp_info->image, tmp6);
                        appinfo->uiapp_info->image = tmp6;
                }
+               if (appinfo->uiapp_info->appcontrol) {
+                       LISTHEAD(appinfo->uiapp_info->appcontrol, tmp7);
+                       appinfo->uiapp_info->appcontrol = tmp7;
+               }
                ret = app_func((void *)appinfo, user_data);
                if (ret < 0)
                        break;
@@ -4298,7 +5136,7 @@ API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, v
                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);
+               ret = __exec_db_query(GET_DB(manifest_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);
@@ -4306,7 +5144,7 @@ API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, v
                                "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);
+               ret = __exec_db_query(GET_DB(manifest_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);
@@ -4314,9 +5152,13 @@ API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, v
                                "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);
+               ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
                tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
 
+               snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", ptr2->appid);
+               ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
                if (appinfo->svcapp_info->label) {
                        LISTHEAD(appinfo->svcapp_info->label, tmp1);
                        appinfo->svcapp_info->label = tmp1;
@@ -4337,6 +5179,10 @@ API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, v
                        LISTHEAD(appinfo->svcapp_info->permission, tmp5);
                        appinfo->svcapp_info->permission = tmp5;
                }
+               if (appinfo->svcapp_info->appcontrol) {
+                       LISTHEAD(appinfo->svcapp_info->appcontrol, tmp7);
+                       appinfo->svcapp_info->appcontrol = tmp7;
+               }
                ret = app_func((void *)appinfo, user_data);
                if (ret < 0)
                        break;
@@ -4354,7 +5200,7 @@ catch:
                free(syslocale);
                syslocale = NULL;
        }
-       sqlite3_close(appinfo_db);
+       __close_manifest_db();
        if (appinfo) {
                free(appinfo);
                appinfo = NULL;
@@ -4363,7 +5209,12 @@ catch:
        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");
@@ -4379,16 +5230,20 @@ API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *
        metadata_x *tmp4 = NULL;
        permission_x *tmp5 = NULL;
        image_x *tmp6 = NULL;
+       appcontrol_x *tmp7 = NULL;
        char query[MAX_QUERY_LEN] = {'\0'};
-       sqlite3 *appinfo_db = NULL;
+       const char* user_pkg_parser = NULL;
 
-       /*open db*/
-       ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
-       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
+       *handle = NULL;
 
+       /*open db*/
+       user_pkg_parser = getUserPkgParserDBPathUID(uid);
+       ret = __open_manifest_db(uid);
+       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", user_pkg_parser);
+  
        /*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);
+       ret = __exec_db_query(GET_DB(manifest_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);
 
@@ -4407,7 +5262,7 @@ API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *
        /*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);
+       ret = __exec_db_query(GET_DB(manifest_db), query, __appcomponent_cb, (void *)appinfo);
        tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
 
        /*calloc app_component*/
@@ -4423,50 +5278,55 @@ API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *
        /*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);
+       ret = __exec_db_query(GET_DB(manifest_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);
+       ret = __exec_db_query(GET_DB(manifest_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);
+       ret = __exec_db_query(GET_DB(manifest_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);
+       ret = __exec_db_query(GET_DB(manifest_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);
+       ret = __exec_db_query(GET_DB(manifest_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);
+       ret = __exec_db_query(GET_DB(manifest_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);
+       ret = __exec_db_query(GET_DB(manifest_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);
+       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
        tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
 
+       /*store app control info*/
+       snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->uiapp_info->appid);
+       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
        switch (appinfo->app_component) {
        case PMINFO_UI_APP:
                if (appinfo->uiapp_info->label) {
@@ -4493,6 +5353,10 @@ API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *
                        LISTHEAD(appinfo->uiapp_info->image, tmp6);
                        appinfo->uiapp_info->image = tmp6;
                }
+               if (appinfo->uiapp_info->appcontrol) {
+                       LISTHEAD(appinfo->uiapp_info->appcontrol, tmp7);
+                       appinfo->uiapp_info->appcontrol = tmp7;
+               }
                break;
        case PMINFO_SVC_APP:
                if (appinfo->svcapp_info->label) {
@@ -4515,6 +5379,10 @@ API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *
                        LISTHEAD(appinfo->svcapp_info->permission, tmp5);
                        appinfo->svcapp_info->permission = tmp5;
                }
+               if (appinfo->svcapp_info->appcontrol) {
+                       LISTHEAD(appinfo->svcapp_info->appcontrol, tmp7);
+                       appinfo->svcapp_info->appcontrol = tmp7;
+               }
                break;
        default:
                break;
@@ -4530,7 +5398,7 @@ catch:
                __cleanup_appinfo(appinfo);
        }
 
-       sqlite3_close(appinfo_db);
+       __close_manifest_db();
        if (syslocale) {
                free(syslocale);
                syslocale = NULL;
@@ -4542,6 +5410,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)
 {
@@ -4674,6 +5546,76 @@ API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h  handle, char **label)
        return PMINFO_R_OK;
 }
 
+static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
+{
+       char *result = NULL;
+       char *query = NULL;
+       sqlite3_stmt *stmt = NULL;
+       sqlite3 *db = NULL;
+       char *val;
+       char *manifest_db;
+
+       manifest_db = getUserPkgParserDBPathUID(uid);
+       if (manifest_db == NULL) {
+               _LOGE("Failed to get manifest db path");
+               goto err;
+       }
+
+       if (sqlite3_open_v2(manifest_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
+               _LOGE("DB open fail\n");
+               goto err;
+       }
+
+       query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
+       if (query == NULL) {
+               _LOGE("Out of memory");
+               goto err;
+       }
+
+       if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
+               _LOGE("prepare_v2 fail\n");
+               goto err;
+       }
+
+       if (sqlite3_step(stmt) == SQLITE_ROW) {
+               val = (char *)sqlite3_column_text(stmt, 0);
+               if (val != NULL)
+                       result = strdup(val);
+       }
+
+err:
+       sqlite3_finalize(stmt);
+       sqlite3_free(query);
+       sqlite3_close(db);
+
+       return result;
+}
+
+API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
+{
+       char *val;
+       int ret;
+
+       retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
+
+       val = _get_localed_label(appid, locale, uid);
+       if (val == NULL)
+               val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
+
+       if (val == NULL) {
+               ret = PMINFO_R_ERROR;
+       } else {
+               *label = val;
+               ret = PMINFO_R_OK;
+       }
+
+       return ret;
+}
+
+API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
+{
+       return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, GLOBAL_USER, label);
+}
 
 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h  handle, pkgmgrinfo_app_component *component)
 {
@@ -4859,7 +5801,12 @@ API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h  handle, pkg
        char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
 
-       val = info->uiapp_info->permission_type;
+       if (info->app_component == PMINFO_UI_APP)
+               val = info->uiapp_info->permission_type;
+       else if (info->app_component == PMINFO_SVC_APP)
+               val = info->svcapp_info->permission_type;
+       else
+               return PMINFO_R_ERROR;
 
        if (strcmp(val, "signature") == 0)
                *permission = PMINFO_PERMISSION_SIGNATURE;
@@ -4900,6 +5847,24 @@ API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h  handle, pkgm
        return PMINFO_R_OK;
 }
 
+API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h  handle, pkgmgrinfo_app_screenreader *screenreader)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(screenreader == 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->screenreader;
+       if (val) {
+               if (strcasecmp(val, "screenreader-off") == 0)
+                       *screenreader = PMINFO_SCREENREADER_OFF;
+               else if (strcasecmp(val, "screenreader-on") == 0)
+                       *screenreader = PMINFO_SCREENREADER_ON;
+               else
+                       *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
+       }
+       return PMINFO_R_OK;
+}
+
 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h  handle, char **portrait_img, char **landscape_img)
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
@@ -4926,6 +5891,106 @@ API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h  handle, char
        return PMINFO_R_OK;
 }
 
+API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+       retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+       if (info->app_component != PMINFO_UI_APP)
+               return PMINFO_R_EINVAL;
+
+       if (info->uiapp_info->launch_mode == NULL)
+               return PMINFO_R_ERROR;
+
+       *mode = (char *)(info->uiapp_info->launch_mode);
+
+       return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
+{
+       retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
+       retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
+       retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+       retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+       int ret = PMINFO_R_OK;
+       char *query = NULL;
+       sqlite3_stmt *stmt = NULL;
+
+       /*open db*/
+       ret = __open_manifest_db(uid);
+       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
+
+       /*Start constructing query*/
+       query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
+
+       /*prepare query*/
+       ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
+       tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
+
+       /*step query*/
+       ret = sqlite3_step(stmt);
+       tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
+
+       *appid = strdup((char *)sqlite3_column_text(stmt, 0));
+       *access = strdup((char *)sqlite3_column_text(stmt, 2));
+
+       ret = PMINFO_R_OK;
+
+catch:
+       sqlite3_free(query);
+       sqlite3_finalize(stmt);
+       __close_manifest_db();
+       return ret;
+}
+
+API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
+{
+       return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, GLOBAL_USER, appid, access);
+}
+
+API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
+{
+       retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
+       retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+       int ret = PMINFO_R_OK;
+       char *query = NULL;
+       sqlite3_stmt *stmt = NULL;
+
+       /*open db*/
+       ret = __open_manifest_db(uid);
+       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
+
+       /*Start constructing query*/
+       query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
+
+       /*prepare query*/
+       ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
+       tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
+
+       /*step query*/
+       ret = sqlite3_step(stmt);
+       tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
+
+       *appid = strdup((char *)sqlite3_column_text(stmt, 0));
+
+       ret = PMINFO_R_OK;
+
+catch:
+       sqlite3_free(query);
+       sqlite3_finalize(stmt);
+       __close_manifest_db();
+       return ret;
+}
+
+API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
+{
+       return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, GLOBAL_USER, appid);
+}
+
 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
                        pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
 {
@@ -4941,9 +6006,11 @@ API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
        else
                return PMINFO_R_EINVAL;
        for (; ptr; ptr = ptr->next) {
-               ret = permission_func(ptr->value, user_data);
-               if (ret < 0)
-                       break;
+               if (ptr->value) {
+                       ret = permission_func(ptr->value, user_data);
+                       if (ret < 0)
+                               break;
+               }
        }
        return PMINFO_R_OK;
 }
@@ -4963,9 +6030,11 @@ API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
        else
                return PMINFO_R_EINVAL;
        for (; ptr; ptr = ptr->next) {
-               ret = category_func(ptr->name, user_data);
-               if (ret < 0)
-                       break;
+               if (ptr->name) {
+                       ret = category_func(ptr->name, user_data);
+                       if (ret < 0)
+                               break;
+               }
        }
        return PMINFO_R_OK;
 }
@@ -4985,9 +6054,11 @@ API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
        else
                return PMINFO_R_EINVAL;
        for (; ptr; ptr = ptr->next) {
-               ret = metadata_func(ptr->key, ptr->value, user_data);
-               if (ret < 0)
-                       break;
+               if (ptr->key) {
+                       ret = metadata_func(ptr->key, ptr->value, user_data);
+                       if (ret < 0)
+                               break;
+               }
        }
        return PMINFO_R_OK;
 }
@@ -4997,182 +6068,35 @@ API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
-       int i = 0;
-       int ret = -1;
-       int oc = 0;
-       int mc = 0;
-       int uc = 0;
-       int sc = 0;
-       char *pkgid = NULL;
-       char *manifest = NULL;
-       char **operation = NULL;
-       char **uri = NULL;
-       char **mime = NULL;
-       char **subapp = NULL;
-       appcontrol_x *appcontrol = NULL;
-       manifest_x *mfx = NULL;
-       operation_x *op = NULL;
-       uri_x *ui = NULL;
-       mime_x *mi = NULL;
-       subapp_x *sa = NULL;
+       int ret;
+       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+       appcontrol_x *appcontrol;
        pkgmgrinfo_app_component component;
-       pkgmgrinfo_appcontrol_x *ptr = NULL;
-       ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
-       if (ret < 0) {
-               _LOGE("Failed to get package name\n");
-               return PMINFO_R_ERROR;
-       }
        ret = pkgmgrinfo_appinfo_get_component(handle, &component);
        if (ret < 0) {
                _LOGE("Failed to get app component name\n");
                return PMINFO_R_ERROR;
        }
-       manifest = pkgmgr_parser_get_manifest_file(pkgid);
-       if (manifest == NULL) {
-               _LOGE("Failed to fetch package manifest file\n");
-               return PMINFO_R_ERROR;
-       }
-       mfx = pkgmgr_parser_process_manifest_xml(manifest);
-       if (mfx == NULL) {
-               _LOGE("Failed to parse package manifest file\n");
-               free(manifest);
-               manifest = NULL;
-               return PMINFO_R_ERROR;
-       }
-       free(manifest);
-       ptr  = calloc(1, sizeof(pkgmgrinfo_appcontrol_x));
-       if (ptr == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               pkgmgr_parser_free_manifest_xml(mfx);
-               return PMINFO_R_ERROR;
-       }
-       /*Get Operation, Uri, Mime*/
        switch (component) {
        case PMINFO_UI_APP:
-               if (mfx->uiapplication) {
-                       if (mfx->uiapplication->appsvc) {
-                               appcontrol = mfx->uiapplication->appsvc;
-                       }
-               }
+               if (info->uiapp_info == NULL)
+                       return PMINFO_R_EINVAL;
+               appcontrol = info->uiapp_info->appcontrol;
                break;
        case PMINFO_SVC_APP:
-               if (mfx->serviceapplication) {
-                       if (mfx->serviceapplication->appsvc) {
-                               appcontrol = mfx->serviceapplication->appsvc;
-                       }
-               }
+               if (info->svcapp_info == NULL)
+                       return PMINFO_R_EINVAL;
+               appcontrol = info->svcapp_info->appcontrol;
                break;
        default:
                break;
        }
        for (; appcontrol; appcontrol = appcontrol->next) {
-               op = appcontrol->operation;
-               for (; op; op = op->next)
-                       oc = oc + 1;
-               op = appcontrol->operation;
-
-               ui = appcontrol->uri;
-               for (; ui; ui = ui->next)
-                       uc = uc + 1;
-               ui = appcontrol->uri;
-
-               mi = appcontrol->mime;
-               for (; mi; mi = mi->next)
-                       mc = mc + 1;
-               mi = appcontrol->mime;
-
-               sa = appcontrol->subapp;
-               for (; sa; sa = sa->next)
-                       sc = sc + 1;
-               sa = appcontrol->subapp;
-
-               operation = (char **)calloc(oc, sizeof(char *));
-               for (i = 0; i < oc; i++) {
-                       operation[i] = strndup(op->name, PKG_STRING_LEN_MAX - 1);
-                       op = op->next;
-               }
-
-               uri = (char **)calloc(uc, sizeof(char *));
-               for (i = 0; i < uc; i++) {
-                       uri[i] = strndup(ui->name, PKG_STRING_LEN_MAX - 1);
-                       ui = ui->next;
-               }
-
-               mime = (char **)calloc(mc, sizeof(char *));
-               for (i = 0; i < mc; i++) {
-                       mime[i] = strndup(mi->name, PKG_STRING_LEN_MAX - 1);
-                       mi = mi->next;
-               }
-
-               subapp = (char **)calloc(sc, sizeof(char *));
-               for (i = 0; i < sc; i++) {
-                       subapp[i] = strndup(sa->name, PKG_STRING_LEN_MAX - 1);
-                       sa = sa->next;
-               }
-
-               /*populate appcontrol handle*/
-               ptr->operation_count = oc;
-               ptr->uri_count = uc;
-               ptr->mime_count = mc;
-               ptr->subapp_count = sc;
-               ptr->operation = operation;
-               ptr->uri = uri;
-               ptr->mime = mime;
-               ptr->subapp = subapp;
-
-               ret = appcontrol_func((void *)ptr, user_data);
-               for (i = 0; i < oc; i++) {
-                       if (operation[i]) {
-                               free(operation[i]);
-                               operation[i] = NULL;
-                       }
-               }
-               if (operation) {
-                       free(operation);
-                       operation = NULL;
-               }
-               for (i = 0; i < uc; i++) {
-                       if (uri[i]) {
-                               free(uri[i]);
-                               uri[i] = NULL;
-                       }
-               }
-               if (uri) {
-                       free(uri);
-                       uri = NULL;
-               }
-               for (i = 0; i < mc; i++) {
-                       if (mime[i]) {
-                               free(mime[i]);
-                               mime[i] = NULL;
-                       }
-               }
-               if (mime) {
-                       free(mime);
-                       mime = NULL;
-               }
-               for (i = 0; i < sc; i++) {
-                       if (subapp[i]) {
-                               free(subapp[i]);
-                               subapp[i] = NULL;
-                       }
-               }
-               if (subapp) {
-                       free(subapp);
-                       subapp = NULL;
-               }
+               ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
                if (ret < 0)
                        break;
-               uc = 0;
-               mc = 0;
-               oc = 0;
-               sc = 0;
-       }
-       pkgmgr_parser_free_manifest_xml(mfx);
-       if (ptr) {
-               free(ptr);
-               ptr = NULL;
        }
+
        return PMINFO_R_OK;
 }
 
@@ -5366,6 +6290,32 @@ API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode
        return PMINFO_R_OK;
 }
 
+API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
+       retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
+
+       category_x *ptr = NULL;
+       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+       *exist = 0;
+
+       ptr = info->uiapp_info->category;
+
+       for (; ptr; ptr = ptr->next) {
+               if (ptr->name) {
+                       if (strcasecmp(ptr->name, category) == 0)
+                       {
+                               *exist = 1;
+                               break;
+                       }
+               }
+       }
+
+       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");
@@ -5547,7 +6497,7 @@ API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
        return PMINFO_R_OK;
 }
 
-API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
+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(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
@@ -5574,11 +6524,12 @@ API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int
                return PMINFO_R_ERROR;
        }
 
-       ret = __open_manifest_db();
+       ret = __open_manifest_db(uid);
        if (ret == -1) {
                _LOGE("Fail to open manifest DB\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
+               free(syslocale);
+               free(locale);
+               return PMINFO_R_ERROR;
        }
 
        /*Start constructing query*/
@@ -5598,20 +6549,17 @@ API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int
                        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)) {
+           sqlite3_exec(GET_DB(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;
@@ -5626,12 +6574,17 @@ err:
                free(syslocale);
                syslocale = NULL;
        }
-       sqlite3_close(manifest_db);
+       __close_manifest_db();
        return ret;
 }
 
-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_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
+{
+       return pkgmgrinfo_appinfo_usr_filter_count(handle, count, GLOBAL_USER);
+}
+
+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 input parameter is NULL\n");
        retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
@@ -5659,11 +6612,12 @@ API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h ha
                return PMINFO_R_ERROR;
        }
 
-       ret = __open_manifest_db();
+       ret = __open_manifest_db(uid);
        if (ret == -1) {
                _LOGE("Fail to open manifest DB\n");
-               ret = PMINFO_R_ERROR;
-               goto err;
+               free(syslocale);
+               free(locale);
+               return PMINFO_R_ERROR;
        }
        /*Start constructing query*/
        snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_APP, locale);
@@ -5681,14 +6635,13 @@ API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h ha
                        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);
        /*To get filtered list*/
        pkgmgr_pkginfo_x *info = NULL;
+       pkgmgr_pkginfo_x *filtinfo = NULL;
        info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
        if (info == NULL) {
                _LOGE("Out of Memory!!!\n");
@@ -5702,7 +6655,6 @@ API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h ha
                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");
@@ -5722,11 +6674,10 @@ API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h ha
                goto err;
        }
        if (SQLITE_OK !=
-           sqlite3_exec(manifest_db, query, __app_list_cb, (void *)info, &error_message)) {
+           sqlite3_exec(GET_DB(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;
        }
@@ -5745,11 +6696,10 @@ API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h ha
                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)) {
+               sqlite3_exec(GET_DB(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;
                }
@@ -5759,11 +6709,10 @@ API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h ha
                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)) {
+               sqlite3_exec(GET_DB(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;
                }
@@ -5775,6 +6724,7 @@ API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h ha
        /*If the callback func return < 0 we break and no more call back is called*/
        while(ptr1 != NULL)
        {
+               appinfo->package = strdup(ptr1->package);
                appinfo->locale = strdup(locale);
                appinfo->uiapp_info = ptr1;
                appinfo->app_component = PMINFO_UI_APP;
@@ -5791,6 +6741,7 @@ API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h ha
        /*If the callback func return < 0 we break and no more call back is called*/
        while(ptr2 != NULL)
        {
+               appinfo->package = strdup(ptr2->package);
                appinfo->locale = strdup(locale);
                appinfo->svcapp_info = ptr2;
                appinfo->app_component = PMINFO_SVC_APP;
@@ -5809,7 +6760,7 @@ err:
                free(syslocale);
                syslocale = NULL;
        }
-       sqlite3_close(manifest_db);
+       __close_manifest_db();
        if (appinfo) {
                free(appinfo);
                appinfo = NULL;
@@ -5819,6 +6770,12 @@ err:
        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));
@@ -5869,8 +6826,8 @@ 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)
+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)
 {
        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");
@@ -5895,9 +6852,13 @@ API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_f
        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();
-       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Fail to open manifest DB\n");
-
+       ret = __open_manifest_db(uid);
+       if (ret == -1) {
+               _LOGE("Fail to open manifest DB\n");
+               free(syslocale);
+               free(locale);
+               return PMINFO_R_ERROR;
+       }
        /*Start constructing query*/
        memset(where, '\0', MAX_QUERY_LEN);
        memset(query, '\0', MAX_QUERY_LEN);
@@ -5914,11 +6875,9 @@ API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_f
                        strncat(where, METADATA_FILTER_QUERY_UNION_CLAUSE, sizeof(where) - strlen(where) - 1);
                }
        }
-       _LOGE("where = %s (%d)\n", where, strlen(where));
        if (strlen(where) > 0) {
                strncat(query, where, sizeof(query) - strlen(query) - 1);
        }
-       _LOGE("query = %s (%d)\n", query, strlen(query));
        /*To get filtered list*/
        info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
        tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
@@ -5936,7 +6895,7 @@ API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_f
        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);
+       ret = sqlite3_exec(GET_DB(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);
        memset(query, '\0', MAX_QUERY_LEN);
 
@@ -5954,7 +6913,7 @@ API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_f
        {
                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);
+               ret = sqlite3_exec(GET_DB(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);
        }
@@ -5963,7 +6922,7 @@ API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_f
        {
                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);
+               ret = sqlite3_exec(GET_DB(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);
        }
@@ -6010,7 +6969,7 @@ catch:
                syslocale = NULL;
        }
        sqlite3_free(error_message);
-       sqlite3_close(manifest_db);
+       __close_manifest_db();
        if (appinfo) {
                free(appinfo);
                appinfo = NULL;
@@ -6020,17 +6979,24 @@ 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");
        pkgmgr_certinfo_x *certinfo = NULL;
        certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
+       *handle = NULL;
        retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
        *handle = (void *)certinfo;
        return PMINFO_R_OK;
 }
 
-API int pkgmgrinfo_pkginfo_load_certinfo(const char *pkgid, pkgmgrinfo_certinfo_h handle)
+API int pkgmgrinfo_pkginfo_load_certinfo(const char *pkgid, pkgmgrinfo_certinfo_h handle, uid_t uid)
 {
        retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
@@ -6042,16 +7008,17 @@ API int pkgmgrinfo_pkginfo_load_certinfo(const char *pkgid, pkgmgrinfo_certinfo_
        int i = 0;
 
        /*Open db.*/
-       ret = db_util_open_with_options(CERT_DB, &cert_db,
-                                       SQLITE_OPEN_READONLY, NULL);
+       ret = __open_cert_db(uid,"r");
        if (ret != SQLITE_OK) {
-               _LOGE("connect db [%s] failed!\n", CERT_DB);
-               return PMINFO_R_ERROR;
+               _LOGE("connect db [%s] failed!\n");
+               ret = PMINFO_R_ERROR;
+               goto err;
        }
+       _check_create_Cert_db(GET_DB(cert_db));
        /*validate pkgid*/
        snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
        if (SQLITE_OK !=
-           sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
+           sqlite3_exec(GET_DB(cert_db), query, __validate_cb, (void *)&exist, &error_message)) {
                _LOGE("Don't execute query = %s error message = %s\n", query,
                       error_message);
                sqlite3_free(error_message);
@@ -6074,7 +7041,10 @@ API int pkgmgrinfo_pkginfo_load_certinfo(const char *pkgid, pkgmgrinfo_certinfo_
        }
        for (i = 0; i < MAX_CERT_TYPE; i++) {
                memset(query, '\0', MAX_QUERY_LEN);
-               snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
+               if (uid == GLOBAL_USER || uid == ROOT_UID)
+                       snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d", (certinfo->cert_id)[i]);
+               else
+                       snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d and for_all_users=%d", (certinfo->cert_id)[i], certinfo->for_all_users);
                ret = __exec_certinfo_query(query, (void *)certinfo);
                if (ret == -1) {
                        _LOGE("Cert Info DB Information retrieval failed\n");
@@ -6088,7 +7058,7 @@ API int pkgmgrinfo_pkginfo_load_certinfo(const char *pkgid, pkgmgrinfo_certinfo_
                }
        }
 err:
-       sqlite3_close(cert_db);
+       __close_cert_db();
        return ret;
 }
 
@@ -6132,6 +7102,7 @@ API int pkgmgrinfo_create_certinfo_set_handle(pkgmgrinfo_instcertinfo_h *handle)
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
        pkgmgr_instcertinfo_x *certinfo = NULL;
+       *handle = NULL;
        certinfo = calloc(1, sizeof(pkgmgr_instcertinfo_x));
        retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
        *handle = (void *)certinfo;
@@ -6150,7 +7121,7 @@ API int pkgmgrinfo_set_cert_value(pkgmgrinfo_instcertinfo_h handle, pkgmgrinfo_i
        return PMINFO_R_OK;
 }
 
-API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h handle)
+API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h handle, uid_t uid)
 {
        retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
@@ -6178,25 +7149,25 @@ API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h ha
        info->pkgid = strdup(pkgid);
 
        /*Open db.*/
-       ret = db_util_open_with_options(CERT_DB, &cert_db,
-                                       SQLITE_OPEN_READWRITE, NULL);
-       if (ret != SQLITE_OK) {
-               _LOGE("connect db [%s] failed!\n", CERT_DB);
+       ret =__open_cert_db(uid, "w");
+       if (ret != 0) {
                ret = PMINFO_R_ERROR;
+               _LOGE("Failed to open cert db \n");
                goto err;
        }
+       _check_create_Cert_db(GET_DB(cert_db));
        /*Begin Transaction*/
-       ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
-       if (ret != SQLITE_OK) {
-               _LOGE("Failed to begin transaction\n");
+       ret = sqlite3_exec(GET_DB(cert_db), "BEGIN EXCLUSIVE", NULL, NULL, NULL);
+       if (ret == -1) {
+               _LOGE("Failed to begin transaction %s\n");
                ret = PMINFO_R_ERROR;
                goto err;
        }
-       _LOGE("Transaction Begin\n");
+
        /*Check if request is to insert/update*/
        snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
        if (SQLITE_OK !=
-           sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
+           sqlite3_exec(GET_DB(cert_db), query, __validate_cb, (void *)&exist, &error_message)) {
                _LOGE("Don't execute query = %s error message = %s\n", query,
                       error_message);
                sqlite3_free(error_message);
@@ -6207,7 +7178,7 @@ API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h ha
                /*Update request.
                We cant just issue update query directly. We need to manage index table also.
                Hence it is better to delete and insert again in case of update*/
-               ret = __delete_certinfo(pkgid);
+               ret = __delete_certinfo(pkgid, uid);
                if (ret < 0)
                        _LOGE("Certificate Deletion Failed\n");
        }
@@ -6239,7 +7210,7 @@ API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h ha
                                memset(query, '\0', MAX_QUERY_LEN);
                                snprintf(query, MAX_QUERY_LEN, "select MAX(cert_id) from package_cert_index_info ");
                                if (SQLITE_OK !=
-                                   sqlite3_exec(cert_db, query, __maxid_cb, (void *)&newid, &error_message)) {
+                                   sqlite3_exec(GET_DB(cert_db), query, __maxid_cb, (void *)&newid, &error_message)) {
                                        _LOGE("Don't execute query = %s error message = %s\n", query,
                                               error_message);
                                        sqlite3_free(error_message);
@@ -6259,7 +7230,6 @@ API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h ha
                        (info->cert_id)[i] = indexinfo->cert_id;
                        (info->is_new)[i] = is_new;
                        (info->ref_count)[i] = indexinfo->cert_ref_count;
-                       _LOGE("Id:Count = %d %d\n", indexinfo->cert_id, indexinfo->cert_ref_count);
                        indexinfo->cert_id = 0;
                        indexinfo->cert_ref_count = 0;
                        is_new = 0;
@@ -6282,7 +7252,7 @@ API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h ha
                (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_ROOT_CERT],(info->cert_id)[PMINFO_SET_DISTRIBUTOR2_INTERMEDIATE_CERT],
                (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT]);
         if (SQLITE_OK !=
-            sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
+            sqlite3_exec(GET_DB(cert_db), vquery, NULL, NULL, &error_message)) {
                _LOGE("Don't execute query = %s error message = %s\n", vquery,
                       error_message);
                sqlite3_free(error_message);
@@ -6314,7 +7284,7 @@ API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h ha
                                "where cert_id=%d",  (info->ref_count)[i] + 1, (info->cert_id)[i]);
                        }
                        if (SQLITE_OK !=
-                           sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
+                           sqlite3_exec(GET_DB(cert_db), vquery, NULL, NULL, &error_message)) {
                                _LOGE("Don't execute query = %s error message = %s\n", vquery,
                                       error_message);
                                sqlite3_free(error_message);
@@ -6324,17 +7294,17 @@ API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h ha
                }
        }
        /*Commit transaction*/
-       ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
+       ret = sqlite3_exec(GET_DB(cert_db), "COMMIT", NULL, NULL, NULL);
        if (ret != SQLITE_OK) {
                _LOGE("Failed to commit transaction, Rollback now\n");
-               sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
+               sqlite3_exec(GET_DB(cert_db), "ROLLBACK", NULL, NULL, NULL);
                ret = PMINFO_R_ERROR;
                goto err;
        }
-       _LOGE("Transaction Commit and End\n");
+
        ret =  PMINFO_R_OK;
 err:
-       sqlite3_close(cert_db);
+       __close_cert_db();
        if (vquery) {
                free(vquery);
                vquery = NULL;
@@ -6367,55 +7337,84 @@ API int pkgmgrinfo_destroy_certinfo_set_handle(pkgmgrinfo_instcertinfo_h handle)
        return PMINFO_R_OK;
 }
 
-API int pkgmgrinfo_delete_certinfo(const char *pkgid)
+API int pkgmgrinfo_delete_usr_certinfo(const char *pkgid, uid_t uid)
 {
        retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
        int ret = -1;
        /*Open db.*/
-       ret = db_util_open_with_options(CERT_DB, &cert_db,
-                                       SQLITE_OPEN_READWRITE, NULL);
-       if (ret != SQLITE_OK) {
-               _LOGE("connect db [%s] failed!\n", CERT_DB);
+       ret = __open_cert_db(uid, "w");
+       if (ret != 0) {
+               _LOGE("connect db [%s] failed!\n", getUserPkgCertDBPathUID(uid));
                ret = PMINFO_R_ERROR;
                goto err;
        }
+       _check_create_Cert_db(GET_DB(cert_db));
        /*Begin Transaction*/
-       ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
+       ret = sqlite3_exec(GET_DB(cert_db), "BEGIN EXCLUSIVE", NULL, NULL, NULL);
        if (ret != SQLITE_OK) {
                _LOGE("Failed to begin transaction\n");
                ret = PMINFO_R_ERROR;
                goto err;
        }
        _LOGE("Transaction Begin\n");
-       ret = __delete_certinfo(pkgid);
+       ret = __delete_certinfo(pkgid, uid);
        if (ret < 0) {
                _LOGE("Certificate Deletion Failed\n");
        } else {
                _LOGE("Certificate Deletion Success\n");
        }
        /*Commit transaction*/
-       ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
+       ret = sqlite3_exec(GET_DB(cert_db), "COMMIT", NULL, NULL, NULL);
        if (ret != SQLITE_OK) {
                _LOGE("Failed to commit transaction, Rollback now\n");
-               sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
+               sqlite3_exec(GET_DB(cert_db), "ROLLBACK", NULL, NULL, NULL);
                ret = PMINFO_R_ERROR;
                goto err;
        }
        _LOGE("Transaction Commit and End\n");
        ret = PMINFO_R_OK;
 err:
-       sqlite3_close(cert_db);
+       __close_cert_db();
        return ret;
 }
 
-API int pkgmgrinfo_create_pkgdbinfo(const char *pkgid, pkgmgrinfo_pkgdbinfo_h *handle)
+
+API int pkgmgrinfo_delete_certinfo(const char *pkgid)
+{
+       return pkgmgrinfo_delete_usr_certinfo(pkgid, GLOBAL_USER);
+}
+
+API int pkgmgrinfo_create_pkgusrdbinfo(const char *pkgid, uid_t uid, pkgmgrinfo_pkgdbinfo_h *handle)
 {
        retvm_if(!pkgid, PMINFO_R_EINVAL, "pkgid is NULL");
        retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
 
        char *manifest = NULL;
        manifest_x *mfx = NULL;
+       *handle = NULL;
+       manifest = pkgmgr_parser_get_usr_manifest_file(pkgid, uid);
+       retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
+
+       mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
+       if (manifest) {
+               free(manifest);
+               manifest = NULL;
+       }
+       retvm_if(mfx == NULL, PMINFO_R_EINVAL, "pkg[%s] parsing fail", pkgid);
+
+       *handle = (void *)mfx;
+
+       return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_create_pkgdbinfo(const char *pkgid, pkgmgrinfo_pkgdbinfo_h *handle)
+{
+       retvm_if(!pkgid, PMINFO_R_EINVAL, "pkgid is NULL");
+       retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
 
+       char *manifest = NULL;
+       manifest_x *mfx = NULL;
+       *handle = NULL;
        manifest = pkgmgr_parser_get_manifest_file(pkgid);
        retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
 
@@ -6640,6 +7639,24 @@ API int pkgmgrinfo_save_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
        }
 }
 
+API int pkgmgrinfo_save_pkgusrdbinfo(pkgmgrinfo_pkgdbinfo_h handle, uid_t uid)
+{
+       retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
+       int ret = 0;
+       manifest_x *mfx = NULL;
+       mfx = (manifest_x *)handle;
+
+       ret = pkgmgr_parser_update_manifest_info_in_usr_db(mfx, uid);
+       if (ret == 0) {
+               _LOGE("Successfully stored info in DB\n");
+               return PMINFO_R_OK;
+       } else {
+               _LOGE("Failed to store info in DB\n");
+               return PMINFO_R_ERROR;
+       }
+}
+
 API int pkgmgrinfo_destroy_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
 {
        retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
@@ -6656,27 +7673,24 @@ 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)
+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");
        int ret = -1;
        char query[MAX_QUERY_LEN] = {'\0'};
-       ret = __open_manifest_db();
 
-       if (access(MANIFEST_DB, 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", MANIFEST_DB);
-                       return PMINFO_R_ERROR;
-               }
+       /* Open db.*/
+       ret = __open_manifest_db(uid);
+       if (ret != SQLITE_OK) {
+               _LOGE("connect db [%s] failed!\n", getUserPkgParserDBPathUID(uid));
+               return PMINFO_R_ERROR;
        }
 
        /*Begin transaction*/
-       ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
+       ret = sqlite3_exec(GET_DB(manifest_db), "BEGIN EXCLUSIVE", NULL, NULL, NULL);
        if (ret != SQLITE_OK) {
                _LOGE("Failed to begin transaction\n");
-               sqlite3_close(manifest_db);
+               __close_manifest_db();
                return PMINFO_R_ERROR;
        }
        _LOGD("Transaction Begin\n");
@@ -6687,7 +7701,7 @@ API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled)
 
        char *error_message = NULL;
        if (SQLITE_OK !=
-           sqlite3_exec(manifest_db, query, NULL, NULL, &error_message)) {
+           sqlite3_exec(GET_DB(manifest_db), query, NULL, NULL, &error_message)) {
                _LOGE("Don't execute query = %s error message = %s\n", query,
                       error_message);
                sqlite3_free(error_message);
@@ -6696,19 +7710,22 @@ API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled)
        sqlite3_free(error_message);
 
        /*Commit transaction*/
-       ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL);
+       ret = sqlite3_exec(GET_DB(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);
+               sqlite3_exec(GET_DB(manifest_db), "ROLLBACK", NULL, NULL, NULL);
+               __close_manifest_db();
                return PMINFO_R_ERROR;
        }
        _LOGD("Transaction Commit and End\n");
-       sqlite3_close(manifest_db);
-
+       __close_manifest_db();
        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)
 {
@@ -6730,53 +7747,45 @@ API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * typ
        data = (pkgmgr_datacontrol_x *)calloc(1, sizeof(pkgmgr_datacontrol_x));
        if (data == NULL) {
                _LOGE("Failed to allocate memory for pkgmgr_datacontrol_x\n");
-               sqlite3_close(datacontrol_db);
+               __close_datacontrol_db();
                return PMINFO_R_ERROR;
        }
 
        snprintf(query, MAX_QUERY_LEN, 
-               "select appinfo.package_name, datacontrol.access from appinfo, datacontrol where datacontrol.id=appinfo.unique_id and datacontrol.provider_id = '%s' and datacontrol.type='%s' COLLATE NOCASE",
+               "select appinfo.package_name, datacontrol.access from appinfo, datacontrol where datacontrol.id=appinfo.unique_id and datacontrol.providerid = '%s' and datacontrol.type='%s' COLLATE NOCASE",
                providerid, type);
 
        if (SQLITE_OK !=
-               sqlite3_exec(datacontrol_db, query, __datacontrol_cb, (void *)data, &error_message)) {
+               sqlite3_exec(GET_DB(datacontrol_db), query, __datacontrol_cb, (void *)data, &error_message)) {
                _LOGE("Don't execute query = %s error message = %s\n", query,
                           error_message);
                sqlite3_free(error_message);
-               sqlite3_close(datacontrol_db);
+               __close_datacontrol_db();
                return PMINFO_R_ERROR;
        }
 
        *appid = (char *)data->appid;
        *access = (char *)data->access;
        free(data);
-       sqlite3_close(datacontrol_db);
+    __close_datacontrol_db();
 
        return PMINFO_R_OK;
 }
 
-API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *label)
+API int pkgmgrinfo_appinfo_set_usr_default_label(const char *appid, const char *label, uid_t uid)
 {
        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();
+       ret = __open_manifest_db(uid);
 
-       if (access(MANIFEST_DB, 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", MANIFEST_DB);
-                       return PMINFO_R_ERROR;
-               }
-       }
 
        /*Begin transaction*/
-       ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
+       ret = sqlite3_exec(GET_DB(manifest_db), "BEGIN EXCLUSIVE", NULL, NULL, NULL);
        if (ret != SQLITE_OK) {
                _LOGE("Failed to begin transaction\n");
-               sqlite3_close(manifest_db);
+               __close_manifest_db();
                return PMINFO_R_ERROR;
        }
        _LOGD("Transaction Begin\n");
@@ -6786,7 +7795,7 @@ API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *labe
                "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)) {
+           sqlite3_exec(GET_DB(manifest_db), query, NULL, NULL, &error_message)) {
                _LOGE("Don't execute query = %s error message = %s\n", query,
                       error_message);
                sqlite3_free(error_message);
@@ -6794,19 +7803,23 @@ API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *labe
        }
 
        /*Commit transaction*/
-       ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL);
+       ret = sqlite3_exec(GET_DB(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);
+               sqlite3_exec(GET_DB(manifest_db), "ROLLBACK", NULL, NULL, NULL);
+               __close_manifest_db();
                return PMINFO_R_ERROR;
        }
        _LOGD("Transaction Commit and End\n");
-       sqlite3_close(manifest_db);
-
+       __close_manifest_db();
        return PMINFO_R_OK;
 }
 
+API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *label)
+{
+       return pkgmgrinfo_appinfo_set_usr_default_label(appid, label, GLOBAL_USER);
+}
+
 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
@@ -6826,12 +7839,11 @@ 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;
        int ret = 0;
-       char *noti_string = NULL;
        int len = 0;
        char query[MAX_QUERY_LEN] = {'\0'};
        char *errmsg = NULL;
@@ -6840,14 +7852,14 @@ API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle,
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
        val = (char *)info->uiapp_info->guestmode_visibility;
        if (val ) {
-                ret =
-                   db_util_open_with_options(MANIFEST_DB, &pkgmgr_parser_db,
-                                SQLITE_OPEN_READWRITE, NULL);
+               ret =
+                 db_util_open_with_options(getUserPkgParserDBPathUID(uid), &pkgmgr_parser_db,
+                               SQLITE_OPEN_READWRITE, NULL);
 
-                if (ret != SQLITE_OK) {
+               if (ret != SQLITE_OK) {
                        _LOGE("DB Open Failed\n");
                        return PMINFO_R_ERROR;
-                }
+               }
 
                /*TODO: Write to DB here*/
                if (status == true)
@@ -6855,23 +7867,160 @@ API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle,
                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)) {
+               ret = sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &errmsg);
+               sqlite3_close(pkgmgr_parser_db);
+               if (ret != SQLITE_OK) {
                        _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_ERROR;
                }
        }
        return PMINFO_R_OK;
 }
+
+API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status)
+{
+       return pkgmgrinfo_appinfo_set_usr_guestmode_visibility(handle, GLOBAL_USER, status);
+}
+
+/* pkgmgrinfo client start*/
+API pkgmgrinfo_client *pkgmgrinfo_client_new(pkgmgrinfo_client_type ctype)
+{
+       int ret = 0;
+       char *errmsg = NULL;
+       void *pc = NULL;
+       void *handle = NULL;
+       pkgmgrinfo_client *(*__pkgmgr_client_new)(pkgmgrinfo_client_type ctype) = NULL;
+
+       handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
+       retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
+
+       __pkgmgr_client_new = dlsym(handle, "pkgmgr_client_new");
+       errmsg = dlerror();
+       tryvm_if((errmsg != NULL) || (__pkgmgr_client_new == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
+
+       pc = __pkgmgr_client_new(ctype);
+       tryvm_if(pc == NULL, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
+
+catch:
+       dlclose(handle);
+       return (pkgmgrinfo_client *) pc;
+}
+
+API int pkgmgrinfo_client_set_status_type(pkgmgrinfo_client *pc, int status_type)
+{
+       int ret = 0;
+       char *errmsg = NULL;
+       void *handle = NULL;
+       int (*__pkgmgr_client_set_status_type)(pkgmgrinfo_client *pc, int status_type) = NULL;
+
+       handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
+       retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
+
+       __pkgmgr_client_set_status_type = dlsym(handle, "pkgmgr_client_set_status_type");
+       errmsg = dlerror();
+       tryvm_if((errmsg != NULL) || (__pkgmgr_client_set_status_type == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
+
+       ret = __pkgmgr_client_set_status_type(pc, status_type);
+       tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
+
+catch:
+        /*
+         * Do not close libpkgmgr-client.so.0 to avoid munmap registered callback
+         *
+         * The lib dependency chain like below
+         * amd --> pkgmgr-info -- dlopen --> libpkgmgr-client --> libpkgmgr-installer-client
+         *
+         * And there is a function in libpkgmgr-installer-client named _on_signal_handle_filter()
+         * which will registered to dbus callback in amd though in fact amd doesn't direct depends
+         * on libpkgmgr-installer-client.
+         *
+         * So when the dlcose happen, then libpkgmgr-installer-client been closed too since no one
+         * link to it then.
+         *
+         * However, when the libdbus call into the callback function, it suddenly fond that the
+         * function address is gone (unmapped), then we receive a SIGSEGV.
+         *
+         * I'm not sure why we're using dlopen/dlclose in this case, I think it's much simple and
+         * robust if we just link to the well-known lib.
+         *
+         * See https://bugs.tizen.org/jira/browse/PTREL-591
+       dlclose(handle);
+         */
+       return ret;
+}
+
+API int pkgmgrinfo_client_listen_status(pkgmgrinfo_client *pc, pkgmgrinfo_handler event_cb, void *data)
+{
+       int ret = 0;
+       char *errmsg = NULL;
+       void *handle = NULL;
+       int (*__pkgmgr_client_listen_status)(pkgmgrinfo_client *pc, pkgmgrinfo_handler event_cb, void *data) = NULL;
+
+       handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
+       retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
+
+       __pkgmgr_client_listen_status = dlsym(handle, "pkgmgr_client_listen_status");
+       errmsg = dlerror();
+       tryvm_if((errmsg != NULL) || (__pkgmgr_client_listen_status == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
+
+       ret = __pkgmgr_client_listen_status(pc, event_cb, data);
+       tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
+
+catch:
+        /* same as pkgmgrinfo_client_new */
+       return ret;
+}
+
+API int pkgmgrinfo_client_free(pkgmgrinfo_client *pc)
+{
+       int ret = 0;
+       char *errmsg = NULL;
+       void *handle = NULL;
+       int (*__pkgmgr_client_free)(pkgmgrinfo_client *pc) = NULL;
+
+       handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
+       retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
+
+       __pkgmgr_client_free = dlsym(handle, "pkgmgr_client_free");
+       errmsg = dlerror();
+       tryvm_if((errmsg != NULL) || (__pkgmgr_client_free == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
+
+       ret = __pkgmgr_client_free(pc);
+       tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
+
+catch:
+        /* same as pkgmgrinfo_client_new */
+       return ret;
+}
+
+API int pkgmgrinfo_client_request_enable_external_pkg(char *pkgid)
+{
+       int ret = 0;
+       DBusConnection *bus;
+       DBusMessage *message;
+
+       retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n");
+
+       if(__get_pkg_location(pkgid) != PMINFO_EXTERNAL_STORAGE)
+               return PMINFO_R_OK;
+
+       bus = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+       retvm_if(bus == NULL, PMINFO_R_EINVAL, "dbus_bus_get() failed.");
+
+       message = dbus_message_new_method_call (SERVICE_NAME, PATH_NAME, INTERFACE_NAME, METHOD_NAME);
+       retvm_if(message == NULL, PMINFO_R_EINVAL, "dbus_message_new_method_call() failed.");
+
+       dbus_message_append_args(message, DBUS_TYPE_STRING, &pkgid, DBUS_TYPE_INVALID);
+
+       ret = dbus_connection_send_with_reply_and_block(bus, message, -1, NULL);
+       retvm_if(!ret, ret = PMINFO_R_EINVAL, "connection_send dbus fail");
+
+       dbus_connection_flush(bus);
+       dbus_message_unref(message);
+
+       return PMINFO_R_OK;
+}
+
+/* pkgmgrinfo client end*/
+