bool UnregisterAppInPkgmgrForPkgId(const std::string& pkgid, uid_t uid,
RequestMode request_mode) {
- manifest_x* manifest =
- static_cast<manifest_x*>(calloc(1, sizeof(manifest_x)));
+ manifest_x* manifest = PkgmgrGenerateManifestInfoFromDB(pkgid, uid);
if (!manifest) {
- LOG(ERROR) << "Out of memory";
+ LOG(ERROR) << "Failed to get manifest_x from DB";
return false;
}
- PkgmgrGenerateManifestInfoFromDB(manifest, pkgid, uid);
bool res = UnregisterAppInPkgmgr(manifest, pkgid, uid, request_mode);
pkgmgr_parser_free_manifest_xml(manifest);
return res;
if (!bf::exists(xml_path) &&
pkg_query.IsPackageInstalled()) {
context_->force_clean_from_db.set(true);
- manifest_x* manifest =
- static_cast<manifest_x*>(calloc(1, sizeof(manifest_x)));
+ manifest_x* manifest = PkgmgrGenerateManifestInfoFromDB(
+ context_->pkgid.get(),context_->uid.get());
if (!manifest) {
- LOG(ERROR) << "Out of memory";
+ LOG(ERROR) << "Failed to get manifest_x from DB";
return Status::ERROR;
}
- if (!PkgmgrGenerateManifestInfoFromDB(manifest, context_->pkgid.get(),
- context_->uid.get())) {
- context_->manifest_data.set(manifest);
- }
+
+ context_->manifest_data.set(manifest);
}
return Status::OK;
return xml_path;
}
-int PkgmgrGenerateManifestInfoFromDB(manifest_x* mfx,
- const std::string &pkgid,
- uid_t uid) {
+manifest_x* PkgmgrGenerateManifestInfoFromDB(const std::string &pkgid,
+ uid_t uid) {
pkgmgrinfo_appinfo_filter_h filter;
- mfx->package = strdup(pkgid.c_str());
-
if (pkgmgrinfo_appinfo_filter_create(&filter))
- return PMINFO_R_ERROR;
+ return nullptr;
if (pkgmgrinfo_appinfo_filter_add_string(filter,
PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid.c_str())) {
pkgmgrinfo_appinfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
+ return nullptr;
}
+ manifest_x* mfx = static_cast<manifest_x*>(calloc(1, sizeof(manifest_x)));
+ if (!mfx) {
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ LOG(ERROR) << "Out of memory";
+ return nullptr;
+ }
if (pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(filter,
PkgmgrAppInfoCallback,
mfx, uid)) {
+ pkgmgr_parser_free_manifest_xml(mfx);
pkgmgrinfo_appinfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
+ return nullptr;
}
+ mfx->package = strdup(pkgid.c_str());
pkgmgrinfo_appinfo_filter_destroy(filter);
- return PMINFO_R_OK;
+ return mfx;
}
} // namespace common_installer
namespace bf = boost::filesystem;
namespace common_installer {
-int PkgmgrGenerateManifestInfoFromDB(manifest_x* mfx,
- const std::string& pkgid,
- uid_t uid);
+manifest_x* PkgmgrGenerateManifestInfoFromDB(const std::string& pkgid,
+ uid_t uid);
bf::path GetManifestLocation(const std::string& pkgid,
uid_t uid,