From 1ee444568b6f228f12b1b4a379c7161a7f038672 Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Wed, 22 Mar 2017 15:21:43 +0900 Subject: [PATCH] Add new api to get external image path Change-Id: I198cfdd2d4b489ce314a8ce0dcbd273511967b05 Signed-off-by: jongmyeongko (cherry picked from commit a3c37400077cabe6cdc6dd83326cf34d99888d6a) --- include/pkgmgr-info.h | 41 +++++++++++++++++++++++++++++++++++++++++ src/pkgmgrinfo_pkginfo.c | 18 ++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/include/pkgmgr-info.h b/include/pkgmgr-info.h index 4f2171c..471c881 100644 --- a/include/pkgmgr-info.h +++ b/include/pkgmgr-info.h @@ -620,6 +620,47 @@ static int get_zip_mount_file(const char *pkgid) int pkgmgrinfo_pkginfo_get_zip_mount_file(pkgmgrinfo_pkginfo_h handle, char **zip_mount_file); /** + * @fn int pkgmgrinfo_pkginfo_get_external_image_path(pkgmgrinfo_pkginfo_h handle, char **ext_image_path) + * @brief This API gets package external image path associated with the package + * if package is installed in external storage. + * Otherwise, the return value will be PMINFO_R_ENOENT. + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * + * @param[in] handle pointer to the pkginfo handle. + * @param[out] ext_image_path pointer to hold external image path + * @return 0 if success, error code(<0) if fail + * @retval PMINFO_R_OK success + * @retval PMINFO_R_EINVAL invalid argument + * @retval PMINFO_R_ERROR internal error + * @revall PMINFO_R_ENOENT no valid data + * @pre pkgmgrinfo_pkginfo_get_pkginfo() + * @post pkgmgrinfo_pkginfo_destroy_pkginfo() + * @see pkgmgrinfo_pkginfo_get_pkgid() + * @code +static int get_external_image_path(const char *pkgid) +{ + int ret = 0; + char *ext_image_path = NULL; + pkgmgrinfo_pkginfo_h handle = NULL; + ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_pkginfo_get_external_image_path(handle, &ext_image_path); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return -1; + } + printf("external image path is: %s\n", ext_image_path); + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return 0; +} + * @endcode + */ +int pkgmgrinfo_pkginfo_get_external_image_path(pkgmgrinfo_pkginfo_h handle, char **ext_image_path); + +/** * @fn int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location) * @brief This API gets the package install location from the package ID * diff --git a/src/pkgmgrinfo_pkginfo.c b/src/pkgmgrinfo_pkginfo.c index fe4b52a..0272937 100644 --- a/src/pkgmgrinfo_pkginfo.c +++ b/src/pkgmgrinfo_pkginfo.c @@ -1097,6 +1097,24 @@ API int pkgmgrinfo_pkginfo_get_zip_mount_file(pkgmgrinfo_pkginfo_h handle, char return PMINFO_R_OK; } +API int pkgmgrinfo_pkginfo_get_external_image_path(pkgmgrinfo_pkginfo_h handle, char **ext_image_path) +{ + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + + retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n"); + retvm_if(ext_image_path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); + + if (info->pkg_info == NULL) + return PMINFO_R_ERROR; + + if (info->pkg_info->external_path == NULL) + return PMINFO_R_ENOENT; + + *ext_image_path = (char *)info->pkg_info->external_path; + + return PMINFO_R_OK; +} + API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location) { char *val; -- 2.7.4