diff options
author | Hwankyu Jhun <h.jhun@samsung.com> | 2016-08-30 16:20:54 +0900 |
---|---|---|
committer | Hwankyu Jhun <h.jhun@samsung.com> | 2016-08-30 16:35:04 +0900 |
commit | ad71c29332c5ccfeb7a1c420388ce469f4d5dcb5 (patch) | |
tree | 9f3f37618e7b321a3d8163f602ffd82f422ccdfd | |
parent | f0a14f08749220ce80b3fb0e90cd53426bf35975 (diff) | |
download | widget-service-ad71c29332c5ccfeb7a1c420388ce469f4d5dcb5.tar.gz widget-service-ad71c29332c5ccfeb7a1c420388ce469f4d5dcb5.tar.bz2 widget-service-ad71c29332c5ccfeb7a1c420388ce469f4d5dcb5.zip |
Fix widget plugin parsersubmit/tizen/20160830.074519accepted/tizen/wearable/20160831.124220accepted/tizen/tv/20160831.124202accepted/tizen/mobile/20160831.124149accepted/tizen/ivi/20160831.124238accepted/tizen/common/20160830.150339
- Use pkgmgr API to get app root path
Change-Id: I5dae1335a88e31c87f1627a090d7c7c9b214acc7
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r-- | parser/widget_plugin_parser_db.c | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/parser/widget_plugin_parser_db.c b/parser/widget_plugin_parser_db.c index 2173b64..e186711 100644 --- a/parser/widget_plugin_parser_db.c +++ b/parser/widget_plugin_parser_db.c @@ -24,12 +24,15 @@ #include <dlog.h> #include <tzplatform_config.h> +#include <pkgmgr-info.h> #include <pkgmgr_installer_info.h> #include "widget_plugin_parser_internal.h" static int target_uid_initialized; static uid_t target_uid; +static int root_path_initialized; +static char root_path[PATH_MAX]; static uid_t __get_target_uid(void) { @@ -55,20 +58,32 @@ static int _bind_text(sqlite3_stmt *stmt, int idx, const char *text) static const char *_get_root_path(const char *pkgid) { - const char *path; + pkgmgrinfo_pkginfo_h pkginfo; + char *path = NULL; uid_t uid = __get_target_uid(); + int ret; + + if (root_path_initialized) + return root_path; + + ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &pkginfo); + if (ret != PMINFO_R_OK) { + LOGE("Failed to get pkginfo - %d(%s)", ret, pkgid); + return NULL; + } - if (uid == 0) { - path = tzplatform_mkpath(TZ_SYS_RO_APP, pkgid); - } else if (uid == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)) { - path = tzplatform_mkpath(TZ_SYS_RW_APP, pkgid); - } else { - tzplatform_set_user(uid); - path = tzplatform_mkpath(TZ_USER_APP, pkgid); - tzplatform_reset_user(); + ret = pkgmgrinfo_pkginfo_get_root_path(pkginfo, &path); + if (ret != PMINFO_R_OK) { + LOGE("Failed to get root path - %d(%s)", ret, pkgid); + pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo); + return NULL; } - return path; + snprintf(root_path, sizeof(root_path), "%s", path); + pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo); + root_path_initialized = 1; + + return root_path; } static int _insert_support_size(sqlite3 *db, const char *pkgid, @@ -97,12 +112,13 @@ static int _insert_support_size(sqlite3 *db, const char *pkgid, _bind_text(stmt, idx++, classid); /* adjust preview image path */ if (size->preview != NULL) { - if (size->preview[0] == '/') + if (size->preview[0] == '/') { snprintf(buf, sizeof(buf), "%s", size->preview); - else + } else { snprintf(buf, sizeof(buf), "%s/shared/res/%s", _get_root_path(pkgid), size->preview); + } _bind_text(stmt, idx++, buf); } else { _bind_text(stmt, idx++, NULL); @@ -194,11 +210,12 @@ static int _insert_icon(sqlite3 *db, const char *pkgid, _bind_text(stmt, idx++, classid); _bind_text(stmt, idx++, icon->lang); /* adjust icon path */ - if (icon->icon[0] == '/') + if (icon->icon[0] == '/') { snprintf(buf, sizeof(buf), "%s", icon->icon); - else + } else { snprintf(buf, sizeof(buf), "%s/shared/res/%s", _get_root_path(pkgid), icon->icon); + } _bind_text(stmt, idx++, buf); ret = sqlite3_step(stmt); |