return true;
}
+bool QueryIsGlobalPackage(const std::string& pkg_id, uid_t uid) {
+ pkgmgrinfo_pkginfo_h handle;
+ int ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkg_id.c_str(), uid, &handle);
+ if (ret != PMINFO_R_OK) {
+ if (ret != PMINFO_R_ENOENT)
+ LOG(ERROR) << "Failed to call pkgmgrinfo_pkginfo_get_usr_pkginfo";
+ return false;
+ }
+
+ bool is_global = false;
+ if (pkgmgrinfo_pkginfo_is_for_all_users(handle, &is_global) != PMINFO_R_OK) {
+ LOG(ERROR) << "pkgmgrinfo_pkginfo_is_for_all_users failed";
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return false;
+ }
+
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return is_global;
+}
+
+bool QueryIsPreloadPackage(const std::string& pkg_id, uid_t uid) {
+ pkgmgrinfo_pkginfo_h handle;
+ int ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkg_id.c_str(), uid, &handle);
+ if (ret != PMINFO_R_OK) {
+ if (ret != PMINFO_R_ENOENT)
+ LOG(ERROR) << "Failed to call pkgmgrinfo_pkginfo_get_usr_pkginfo";
+ return false;
+ }
+
+ bool is_preload = false;
+ if (pkgmgrinfo_pkginfo_is_preload(handle, &is_preload) != PMINFO_R_OK) {
+ LOG(ERROR) << "pkgmgrinfo_pkginfo_is_preload failed";
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return false;
+ }
+
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return is_preload;
+}
+
} // namespace common_installer
*/
bool QueryIsPackageInstalled(const std::string& pkg_id, uid_t uid);
+/**
+ * \brief Adapter interface for external PkgMgr module used for checking
+ * if given package is global package
+ *
+ * \param pkg_id package id
+ * \param uid user id
+ *
+ * \return true if package is global package
+ */
+bool QueryIsGlobalPackage(const std::string& pkg_id, uid_t uid);
+
+/**
+ * \brief Adapter interface for external PkgMgr module used for checking
+ * if given package is preloaded package
+ *
+ * \param pkg_id package id
+ * \param uid user id
+ *
+ * \return true if package is preloaded
+ */
+bool QueryIsPreloadPackage(const std::string& pkg_id, uid_t uid);
+
} // namespace common_installer
#endif // COMMON_PKGMGR_QUERY_H_
break;
}
case ManifestLocation::INSTALLED: {
+ uid_t uid;
+ bool is_preload;
+ if (QueryIsGlobalPackage(context_->pkgid.get(), context_->uid.get())) {
+ uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+ is_preload = QueryIsPreloadPackage(context_->pkgid.get(),
+ context_->uid.get());
+ } else {
+ uid = context_->uid.get();
+ is_preload = context_->is_preload_request.get();
+ }
bf::path xml_path =
- bf::path(getUserManifestPath(context_->uid.get(),
- context_->is_preload_request.get()))
+ bf::path(getUserManifestPath(uid, is_preload))
/ bf::path(context_->pkgid.get());
xml_path += ".xml";
context_->xml_path.set(xml_path);