return is_update;
}
+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 QueryIsUpdatedReadonlyPackage(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_
#include <string>
#include "common/pkgmgr_interface.h"
+#include "common/pkgmgr_query.h"
#include "common/utils/file_util.h"
namespace bf = boost::filesystem;
if (!preload_val || (preload_val && strlen(preload_val) == 0)) {
if (preload_val)
free(context_->manifest_data.get()->preload);
- if (context_->is_readonly_package.get() ||
- context_->is_preload_rw_package.get())
- context_->manifest_data.get()->preload = strdup("true");
- else
- context_->manifest_data.get()->preload = strdup("false");
+ RequestType req_type = context_->request_type.get();
+ if (req_type == RequestType::Update ||
+ req_type == RequestType::ManifestDirectUpdate ||
+ req_type == RequestType::ManifestPartialUpdate ||
+ req_type == RequestType::ReadonlyUpdateInstall) {
+ // In case of update, keep preload value
+ bool is_preload = QueryIsPreloadPackage(context_->pkgid.get(),
+ context_->uid.get());
+ context_->manifest_data.get()->preload =
+ strdup(is_preload ? "true" : "false");
+ } else {
+ if (context_->is_readonly_package.get() ||
+ context_->is_preload_rw_package.get())
+ context_->manifest_data.get()->preload = strdup("true");
+ else
+ context_->manifest_data.get()->preload = strdup("false");
+ }
}
const char* removable_val = context_->manifest_data.get()->removable;