9 #include <pkgmgr-info.h>
10 #include <package-manager.h>
13 #include <notification.h>
15 #include "installer_util.h"
16 #include "installer_package_manager.h"
18 #define KEY_PACKAGE_LABEL "__KEY_PACKAGE_LABEL__"
19 #define KEY_PACKAGE_PATH "__KEY_PACKAGE_PATH__"
20 #define KEY_PACKAGE_ICON_PATH "__KEY_PACKAGE_ICON_PATH__"
27 bool is_package_installed(const char *pkgid)
31 LOGE("%s pkgid is empty.", __func__);
35 pkgmgrinfo_pkginfo_h pPackageInfoHandle = NULL;
37 result = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &pPackageInfoHandle);
40 LOGD("%s pkgmgrinfo_pkginfo_get_pkginfo() failed. result=[%d], package=[%s]", __func__, result, pkgid);
44 if (pPackageInfoHandle)
46 pkgmgrinfo_pkginfo_destroy_pkginfo(pPackageInfoHandle);
49 SECURE_LOGD("%s pkgid = [%s] is installed. ", __func__, pkgid);
53 int get_package_version(const char *pkgid, char **version)
57 LOGE("%s pkgid is empty.", __func__);
62 char *ver_temp = NULL;
63 pkgmgrinfo_pkginfo_h handle = NULL;
65 result = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
69 result = pkgmgrinfo_pkginfo_get_version(handle, &ver_temp);
72 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
76 *version = strdup(ver_temp);
80 int launch_install_service(const char *file_path, const package_manager_pkg_detail_info_t *pkg_info)
84 SECURE_LOGD("%s file_path(%s), label(%s), icon_path(%s)", __func__, file_path, pkg_info->label, pkg_info->icon_buf);
86 bundle_add(b, KEY_PACKAGE_PATH, file_path);
87 bundle_add(b, KEY_PACKAGE_LABEL, pkg_info->label);
88 bundle_add(b, KEY_PACKAGE_ICON_PATH, pkg_info->icon_buf);
90 if(!aul_app_is_running("org.tizen.installer-service"))
92 int res = aul_launch_app("org.tizen.installer-service", b);
95 LOGE("%s aul_launch_app() failed.(%d)", __func__, res);
110 package_manager_pkg_detail_info_t* get_package_info_from_file(const char *file_path)
114 if (file_path == NULL)
116 LOGE("%s file_path is empty.", __func__);
119 LOGD("%s packagePath = [%s]", __func__, file_path);
121 ret = access(file_path, F_OK);
127 LOGE("%s access() failed. file_path is not existed. (%s)", __func__, file_path);
131 LOGE("%s access() failed. path: %s errno: %d (%s)", __func__, file_path, errno, strerror(errno));
136 char *extension = NULL;
137 extension = get_file_extension(file_path);
138 SECURE_LOGD("%s pacagePath = [%s], extension = [%s]", __func__, file_path, extension);
140 package_manager_pkg_detail_info_t* pkg_info = NULL;
141 pkg_info = pkgmgr_client_check_pkginfo_from_file(file_path);
143 if (pkg_info == NULL)
145 LOGE("%s pkgmgr_client_check_pkginfo_from_file(%s) is failed.", __func__, file_path);