Add path for multiuser support 02/22002/1 submit/tizen_common/20140528.173953
authorSabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
Wed, 21 May 2014 08:22:34 +0000 (10:22 +0200)
committerBaptiste DURAND <baptiste.durand@open.eurogiciel.org>
Wed, 28 May 2014 13:52:02 +0000 (15:52 +0200)
Change-Id: Id3a9c0f28836904677f85e5ba9ec636df8470150
Signed-off-by: Sabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
Signed-off-by: Corentin Lecouvey <corentin.lecouvey@open.eurogiciel.org>
Signed-off-by: Baptiste DURAND <baptiste.durand@open.eurogiciel.org>
CMakeLists.txt
include/pkgmgr-info.h
packaging/pkgmgr-info.spec
parser/pkgmgr_parser.c
parser/pkgmgr_parser.h
parser/pkgmgr_parser_db.c
src/pkgmgr-info.c

index 49c22ed..4b8480e 100644 (file)
@@ -25,7 +25,7 @@ FOREACH(flag ${pkgs_CFLAGS})
 ENDFOREACH(flag)
 
 
-pkg_check_modules(libpkgs REQUIRED glib-2.0 dlog vconf sqlite3 db-util libxml-2.0 dbus-1 dbus-glib-1)
+pkg_check_modules(libpkgs REQUIRED glib-2.0 dlog vconf sqlite3 db-util libxml-2.0 dbus-1 dbus-glib-1 libtzplatform-config)
 
 FOREACH(flag ${libpkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 58043cb..9683079 100755 (executable)
@@ -2236,7 +2236,7 @@ static int get_app_type(const char *appid)
  * @endcode
  */
 int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle);
-
+int pkgmgrinfo_appinfo_get_appinfo_user(const char *appid, uid_t uid, pkgmgrinfo_appinfo_h *handle);
 /**
  * @fn int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
  * @brief      This API gets the application ID
index a7e345a..9a2a9be 100755 (executable)
@@ -45,7 +45,7 @@ Dev package for libpkgmgr-parser
 cp %{SOURCE1001} .
 
 %build
-%cmake .
+%cmake . 
 make %{?jobs:-j%jobs}
 
 %install
index 12bdd9e..f15dbdf 100755 (executable)
@@ -33,9 +33,8 @@
 #include <libxml/xmlschemas.h>
 #include <vconf.h>
 #include <glib.h>
-
-/* For multi-user support */
-#include <tzplatform_config.h>
+#include <pwd.h>
+#include <grp.h>
 
 #include "pkgmgr_parser.h"
 #include "pkgmgr_parser_internal.h"
@@ -65,6 +64,8 @@
 
 #define PKG_TAG_LEN_MAX 128
 
+
+
 /* operation_type */
 typedef enum {
        ACTION_INSTALL = 0,
@@ -170,6 +171,83 @@ static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, con
 static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid);
 static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid);
 static int __validate_appid(const char *pkgid, const char *appid, char **newappid);
+static int __is_admin();
+
+API char *getUserDBLabel(void)
+{
+       char *result;
+       if(__is_admin())
+               result = strdup("System");
+       else
+               result = strdup("User");
+       return result;
+}
+
+API char *getUserPkgParserDBPath(void)
+{
+   return getUserPkgParserDBPathUID(getuid());
+}
+
+API char *getUserPkgParserDBPathUID(uid_t uid)
+{
+       char *result = NULL;
+       if(!uid)
+       {
+               result = tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db");
+       }
+       else
+       {
+               const char *name = "users";
+               struct passwd *userinfo = NULL;
+               struct group *grpinfo = NULL;
+
+               userinfo = getpwuid(uid);
+               if(userinfo == NULL)
+                       _LOGE("getpwuid(%d) returns NULL !", uid);
+
+               grpinfo = getgrnam(name);
+               if(grpinfo == NULL)
+                       _LOGE("getgrnam(users) returns NULL !");
+
+               // Compare git_t type and not group name
+               if (grpinfo->gr_gid != userinfo->pw_gid)
+                       _LOGE("UID [%d] does not belong to 'users' group!", uid);
+
+               result = userinfo->pw_dir;
+               strcat(result,"/.applications/dbspace/.pkgmgr_parser.db");
+       }
+  return result;
+}
+
+API char *getUserPkgParserJournalDBPath(void)
+{
+       char *result;
+       if(getuid())
+               result = tzplatform_mkpath(TZ_USER_HOME, ".applications/dbspace/.pkgmgr_parser-journal.db");
+       else
+               result = tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db-journal");
+    return result;
+}
+
+API char *getUserPkgCertDBPath(void)
+{
+       char *result;
+       if(getuid())
+               result = tzplatform_mkpath(TZ_USER_HOME, ".applications/dbspace/.pkgmgr_cert.db");
+       else
+               result = tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert.db");
+    return result;
+}
+
+API char *getUserPkgCertJournalDBPath(void)
+{
+       char *result;
+       if(getuid())
+               result = tzplatform_mkpath(TZ_USER_HOME, ".applications/dbspace/.pkgmgr_cert-journal.db");
+       else
+               result = tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert-journal.db");
+    return result;
+}
 
 void *__open_lib_handle(char *tag)
 {
@@ -209,6 +287,17 @@ static void __str_trim(char *input)
        return;
 }
 
+static int __is_admin()
+{
+       uid_t uid = getuid();
+       if ((uid_t) 0 == uid )
+               return 1;
+       else
+               return 0;
+}
+
+
+
 static int __validate_appid(const char *pkgid, const char *appid, char **newappid)
 {
        if (!pkgid || !appid || !newappid) {
@@ -4258,9 +4347,37 @@ static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
        return ret;
 }
 
-#define DESKTOP_RW_PATH tzplatform_mkpath(TZ_SYS_SHARE, "applications/")
-#define DESKTOP_RO_PATH "/usr/share/applications/"
-#define MANIFEST_RO_PREFIX "/usr/share/packages/"
+static const char* getUserDesktopPath(void)
+{
+       const char* desktop_path;
+       if(getuid() > 0)
+  {
+    desktop_path = tzplatform_mkpath(TZ_USER_HOME, ".applications/desktop/");
+  }
+  else
+  {
+    desktop_path = tzplatform_mkpath(TZ_SYS_RW_DESKTOP_APP, "/");
+  }
+
+  _LOGD("uid: [%d] / desktop_path: [%s]\n", getuid(), desktop_path);
+  return desktop_path;
+}
+
+static const char* getUserManifestPath(void)
+{
+       const char* manifest_path;
+       if(getuid() > 0)
+  {
+    manifest_path = tzplatform_mkpath(TZ_USER_HOME, ".config/xwalk-service/applications/");
+  }
+  else
+  {
+    manifest_path = tzplatform_mkpath(TZ_SYS_RW_PACKAGES, "/");
+  }
+
+  _LOGD("uid: [%d] / manifest_path: [%s]\n", getuid(), manifest_path);
+  return manifest_path;
+}
 
 static char* __convert_to_system_locale(const char *mlocale)
 {
@@ -4374,17 +4491,14 @@ static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, A
 
                if (manifest != NULL) {
                        /* skip making a deskfile and update ail, if preload app is updated */
-                       if(strstr(manifest, MANIFEST_RO_PREFIX)) {
+                       if(strstr(manifest, getUserManifestPath())) {
                                __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
                    _LOGE("preload app is update : skip and update ail : %s", manifest);
                                continue;
                        }
                }
 
-               if(mfx->readonly && !strcasecmp(mfx->readonly, "True"))
-                       snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid);
-               else
-                       snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
+               snprintf(filepath, sizeof(filepath),"%s%s.desktop", getUserDesktopPath(), mfx->uiapplication->appid);
 
                /* skip if desktop exists
                if (access(filepath, R_OK) == 0)
@@ -4718,7 +4832,7 @@ static int __ps_remove_nativeapp_desktop(manifest_x *mfx)
        uiapplication_x *uiapplication = mfx->uiapplication;
 
        for(; uiapplication; uiapplication=uiapplication->next) {
-               snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
+               snprintf(filepath, sizeof(filepath),"%s%s.desktop", getUserDesktopPath(), uiapplication->appid);
 
                __ail_change_info(AIL_REMOVE, uiapplication->appid);
 
@@ -4770,7 +4884,7 @@ static int __add_preload_info(manifest_x * mfx, const char *manifest)
        char buffer[1024] = { 0 };
        int state = 0;
 
-       if(strstr(manifest, MANIFEST_RO_PREFIX)) {
+       if(strstr(manifest, getUserManifestPath())) {
                free((void *)mfx->readonly);
                mfx->readonly = strdup("True");
 
@@ -4835,10 +4949,10 @@ static int __check_preload_updated(manifest_x * mfx, const char *manifest)
        int ret = 0;
        uiapplication_x *uiapplication = mfx->uiapplication;
 
-       if(strstr(manifest, MANIFEST_RO_PREFIX)) {
+       if(strstr(manifest, getUserManifestPath())) {
                /* if preload app is updated, then remove previous desktop file on RW*/
                for(; uiapplication; uiapplication=uiapplication->next) {
-                               snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
+                               snprintf(filepath, sizeof(filepath),"%s%s.desktop", getUserDesktopPath(), uiapplication->appid);
                        ret = remove(filepath);
                        if (ret <0)
                                return -1;
index e9b933c..03a1fe2 100755 (executable)
@@ -43,6 +43,9 @@
 
 #include <libxml/xmlreader.h>
 
+/* For multi-user support */
+#include <tzplatform_config.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -486,6 +489,14 @@ typedef struct manifest_x {
        struct deviceprofile_x *deviceprofile;          /**< package device profile*/
 } manifest_x;
 
+/* For multiuser support */
+char *getUserDBLabel(void);
+char *getUserPkgParserDBPath(void);
+char *getUserPkgParserDBPathUID(uid_t uid);
+char *getUserPkgParserJournalDBPath(void);
+char *getUserPkgCertDBPath(void);
+char *getUserPkgCertJournalDBPath(void);
+
 /**
  * @fn char *pkgmgr_parser_get_manifest_file(const char *pkgid)
  * @brief      This API gets the manifest file of the package.
index 04228c9..13c1e9d 100755 (executable)
@@ -2114,13 +2114,14 @@ int pkgmgr_parser_check_and_create_db()
 {
        int ret = -1;
        /*Manifest DB*/
-       ret = __pkgmgr_parser_create_db(&pkgmgr_parser_db, PKGMGR_PARSER_DB_FILE);
+       ret = __pkgmgr_parser_create_db(&pkgmgr_parser_db, getUserPkgParserDBPath());
+       _LOGD("create db  %s", getUserPkgParserDBPath());
        if (ret) {
                _LOGD("Manifest DB creation Failed\n");
                return -1;
        }
        /*Cert DB*/
-       ret = __pkgmgr_parser_create_db(&pkgmgr_cert_db, PKGMGR_CERT_DB_FILE);
+       ret = __pkgmgr_parser_create_db(&pkgmgr_cert_db, getUserPkgParserDBPath());
        if (ret) {
                _LOGD("Cert DB creation Failed\n");
                return -1;
@@ -2136,6 +2137,7 @@ void pkgmgr_parser_close_db()
 
 API int pkgmgr_parser_insert_manifest_info_in_db(manifest_x *mfx)
 {
+       _LOGD("pkgmgr_parser_insert_manifest_info_in_db\n");
        if (mfx == NULL) {
                _LOGD("manifest pointer is NULL\n");
                return -1;
index ee3d782..e62d657 100755 (executable)
@@ -492,11 +492,11 @@ static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
 static int __open_manifest_db()
 {
        int ret = -1;
-       if (access(MANIFEST_DB, F_OK) == 0) {
+       if (access(getUserPkgParserDBPath(), F_OK) == 0) {
                ret =
-                   db_util_open_with_options(MANIFEST_DB, &manifest_db,
+                   db_util_open_with_options(getUserPkgParserDBPath(), &manifest_db,
                                 SQLITE_OPEN_READONLY, NULL);
-               retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", MANIFEST_DB);
+               retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", getUserPkgParserDBPath());
                return 0;
        }
        _LOGE("Manifest DB does not exists !!\n");
@@ -2402,8 +2402,8 @@ API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *
        sqlite3 *pkginfo_db = NULL;
 
        /*validate pkgid*/
-       ret = db_util_open_with_options(MANIFEST_DB, &pkginfo_db, SQLITE_OPEN_READONLY, NULL);
-       retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
+       ret = db_util_open_with_options(getUserPkgParserDBPath(), &pkginfo_db, SQLITE_OPEN_READONLY, NULL);
+       retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPath());
 
        /*check pkgid exist on db*/
        snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_info where package='%s')", pkgid);
@@ -3197,10 +3197,10 @@ 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,
+       ret = db_util_open_with_options(getUserPkgParserDBPath(), &manifest_db,
                                        SQLITE_OPEN_READONLY, NULL);
        if (ret != SQLITE_OK) {
-               _LOGE("connect db [%s] failed!\n", MANIFEST_DB);
+               _LOGE("connect db [%s] failed!\n", getUserPkgParserDBPath());
                ret = PMINFO_R_ERROR;
                goto err;
        }
@@ -3952,8 +3952,8 @@ 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);
-       tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
+       ret = db_util_open_with_options(getUserPkgParserDBPath(), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
+       tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPath());
 
        appinfo->package = strdup(info->manifest_info->package);
        snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
@@ -4252,8 +4252,8 @@ API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, voi
        sqlite3 *appinfo_db = 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);
+       ret = db_util_open_with_options(getUserPkgParserDBPath(), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
+       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPath());
 
        /*calloc pkginfo*/
        pkgmgr_pkginfo_x *info = NULL;
@@ -4348,8 +4348,8 @@ 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);
+       ret = db_util_open_with_options(getUserPkgParserDBPath(), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
+       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPath());
 
        /*calloc pkginfo*/
        pkgmgr_pkginfo_x *info = NULL;
@@ -4532,6 +4532,194 @@ catch:
        return ret;
 }
 
+API int pkgmgrinfo_appinfo_get_appinfo_user(const char *appid, uid_t uid, pkgmgrinfo_appinfo_h *handle)
+{
+       retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL");
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+
+       pkgmgr_appinfo_x *appinfo = NULL;
+       char *syslocale = NULL;
+       char *locale = NULL;
+       int ret = -1;
+       int exist = 0;
+       label_x *tmp1 = NULL;
+       icon_x *tmp2 = NULL;
+       category_x *tmp3 = NULL;
+       metadata_x *tmp4 = NULL;
+       permission_x *tmp5 = NULL;
+       image_x *tmp6 = NULL;
+       char query[MAX_QUERY_LEN] = {'\0'};
+       sqlite3 *appinfo_db = NULL;
+
+       if (uid != 0) {
+               /*open db*/
+               _LOGD("getUserPkgParserDBPathUID(%d) returns: [%s]", uid, getUserPkgParserDBPathUID(uid));
+               ret = db_util_open_with_options(getUserPkgParserDBPathUID(uid), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
+               retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPathUID(uid));
+       }else
+       {
+               /*open db*/
+               _LOGD("getUserPkgParserDBPath() returns: [%s]", getUserPkgParserDBPath);
+               ret = db_util_open_with_options(getUserPkgParserDBPath(), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
+               retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPath());
+       }
+  
+       /*check appid exist on db*/
+       snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", appid);
+       ret = __exec_db_query(appinfo_db, query, __validate_cb, (void *)&exist);
+       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec fail");
+       tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "Appid[%s] not found in DB", appid);
+
+       /*get system locale*/
+       syslocale = vconf_get_str(VCONFKEY_LANGSET);
+       tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
+
+       /*get locale on db*/
+       locale = __convert_system_locale_to_manifest_locale(syslocale);
+       tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
+
+       /*calloc appinfo*/
+       appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
+       tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
+
+       /*check app_component from DB*/
+       memset(query, '\0', MAX_QUERY_LEN);
+       snprintf(query, MAX_QUERY_LEN, "select app_component, package from package_app_info where app_id='%s' ", appid);
+       ret = __exec_db_query(appinfo_db, query, __appcomponent_cb, (void *)appinfo);
+       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
+
+       /*calloc app_component*/
+       if (appinfo->app_component == PMINFO_UI_APP) {
+               appinfo->uiapp_info = (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
+               tryvm_if(appinfo->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for uiapp info");
+       } else {
+               appinfo->svcapp_info = (serviceapplication_x *)calloc(1, sizeof(serviceapplication_x));
+               tryvm_if(appinfo->svcapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for svcapp info");
+       }
+       appinfo->locale = strdup(locale);
+
+       /*populate app_info from DB*/
+       memset(query, '\0', MAX_QUERY_LEN);
+       snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' ", appid);
+       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
+
+       memset(query, '\0', MAX_QUERY_LEN);
+       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, locale);
+       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
+
+       /*Also store the values corresponding to default locales*/
+       memset(query, '\0', MAX_QUERY_LEN);
+       snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, DEFAULT_LOCALE);
+       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+
+       /*Populate app category*/
+       memset(query, '\0', MAX_QUERY_LEN);
+       snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_category where app_id='%s'", appid);
+       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Category Info DB Information retrieval failed");
+
+       /*Populate app metadata*/
+       memset(query, '\0', MAX_QUERY_LEN);
+       snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_metadata where app_id='%s'", appid);
+       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Metadata Info DB Information retrieval failed");
+
+       /*Populate app permission*/
+       memset(query, '\0', MAX_QUERY_LEN);
+       snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_permission where app_id='%s'", appid);
+       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App permission Info DB Information retrieval failed");
+
+       /*store setting notification icon section*/
+       memset(query, '\0', MAX_QUERY_LEN);
+       snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appid);
+       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
+
+       /*store app preview image info*/
+       memset(query, '\0', MAX_QUERY_LEN);
+       snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appid);
+       ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
+
+       switch (appinfo->app_component) {
+       case PMINFO_UI_APP:
+               if (appinfo->uiapp_info->label) {
+                       LISTHEAD(appinfo->uiapp_info->label, tmp1);
+                       appinfo->uiapp_info->label = tmp1;
+               }
+               if (appinfo->uiapp_info->icon) {
+                       LISTHEAD(appinfo->uiapp_info->icon, tmp2);
+                       appinfo->uiapp_info->icon = tmp2;
+               }
+               if (appinfo->uiapp_info->category) {
+                       LISTHEAD(appinfo->uiapp_info->category, tmp3);
+                       appinfo->uiapp_info->category = tmp3;
+               }
+               if (appinfo->uiapp_info->metadata) {
+                       LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
+                       appinfo->uiapp_info->metadata = tmp4;
+               }
+               if (appinfo->uiapp_info->permission) {
+                       LISTHEAD(appinfo->uiapp_info->permission, tmp5);
+                       appinfo->uiapp_info->permission = tmp5;
+               }
+               if (appinfo->uiapp_info->image) {
+                       LISTHEAD(appinfo->uiapp_info->image, tmp6);
+                       appinfo->uiapp_info->image = tmp6;
+               }
+               break;
+       case PMINFO_SVC_APP:
+               if (appinfo->svcapp_info->label) {
+                       LISTHEAD(appinfo->svcapp_info->label, tmp1);
+                       appinfo->svcapp_info->label = tmp1;
+               }
+               if (appinfo->svcapp_info->icon) {
+                       LISTHEAD(appinfo->svcapp_info->icon, tmp2);
+                       appinfo->svcapp_info->icon = tmp2;
+               }
+               if (appinfo->svcapp_info->category) {
+                       LISTHEAD(appinfo->svcapp_info->category, tmp3);
+                       appinfo->svcapp_info->category = tmp3;
+               }
+               if (appinfo->svcapp_info->metadata) {
+                       LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
+                       appinfo->svcapp_info->metadata = tmp4;
+               }
+               if (appinfo->svcapp_info->permission) {
+                       LISTHEAD(appinfo->svcapp_info->permission, tmp5);
+                       appinfo->svcapp_info->permission = tmp5;
+               }
+               break;
+       default:
+               break;
+       }
+
+       ret = PMINFO_R_OK;
+
+catch:
+       if (ret == PMINFO_R_OK)
+               *handle = (void*)appinfo;
+       else {
+               *handle = NULL;
+               __cleanup_appinfo(appinfo);
+       }
+
+       sqlite3_close(appinfo_db);
+       if (syslocale) {
+               free(syslocale);
+               syslocale = NULL;
+       }
+       if (locale) {
+               free(locale);
+               locale = NULL;
+       }
+       return ret;
+}
+
 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
 {
        retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL");
@@ -4552,8 +4740,8 @@ API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *
        sqlite3 *appinfo_db = 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);
+       ret = db_util_open_with_options(getUserPkgParserDBPath(), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
+       retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPath());
 
        /*check appid exist on db*/
        snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", appid);
@@ -6861,11 +7049,11 @@ API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled)
        char query[MAX_QUERY_LEN] = {'\0'};
        ret = __open_manifest_db();
 
-       if (access(MANIFEST_DB, F_OK) == 0) {
+       if (access(getUserPkgParserDBPath(), F_OK) == 0) {
                ret = db_util_open(MANIFEST_DB, &manifest_db,
                         DB_UTIL_REGISTER_HOOK_METHOD);
                if (ret != SQLITE_OK) {
-                       _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", MANIFEST_DB);
+                       _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", getUserPkgParserDBPath());
                        return PMINFO_R_ERROR;
                }
        }
@@ -6961,11 +7149,11 @@ API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *labe
        char *error_message = NULL;
        ret = __open_manifest_db();
 
-       if (access(MANIFEST_DB, F_OK) == 0) {
-               ret = db_util_open(MANIFEST_DB, &manifest_db,
+       if (access(getUserPkgParserDBPath(), F_OK) == 0) {
+               ret = db_util_open(getUserPkgParserDBPath(), &manifest_db,
                         DB_UTIL_REGISTER_HOOK_METHOD);
                if (ret != SQLITE_OK) {
-                       _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", MANIFEST_DB);
+                       _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", getUserPkgParserDBPath());
                        return PMINFO_R_ERROR;
                }
        }
@@ -7039,7 +7227,7 @@ API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle,
        val = (char *)info->uiapp_info->guestmode_visibility;
        if (val ) {
                 ret =
-                   db_util_open_with_options(MANIFEST_DB, &pkgmgr_parser_db,
+                   db_util_open_with_options(getUserPkgParserDBPath(), &pkgmgr_parser_db,
                                 SQLITE_OPEN_READWRITE, NULL);
 
                 if (ret != SQLITE_OK) {