PkgQueryInterface::PkgQueryInterface(const std::string& pkgid, uid_t uid)
: pkgid_(pkgid), uid_(uid), handle_(nullptr) {
- int ret = pkgmgrinfo_pkginfo_get_usr_all_pkginfo(pkgid_.c_str(), uid_,
+ error_ = pkgmgrinfo_pkginfo_get_usr_all_pkginfo(pkgid_.c_str(), uid_,
&handle_);
- if (ret != PMINFO_R_OK) {
- if (ret != PMINFO_R_ENOENT) {
+ if (error_ != PMINFO_R_OK) {
+ if (error_ != PMINFO_R_ENOENT) {
LOG(ERROR) << "Failed to call pkgmgrinfo_pkginfo_get_usr_pkginfo";
handle_ = nullptr;
}
return handle_ != nullptr;
}
+int PkgQueryInterface::GetLastOperationError() {
+ return error_;
+}
+
std::string PkgQueryInterface::TepPath() {
if (!IsValid())
return {};
char* tep_name = nullptr;
- int ret = pkgmgrinfo_pkginfo_get_tep_name(handle_, &tep_name);
- if (ret != PMINFO_R_OK) {
+ error_ = pkgmgrinfo_pkginfo_get_tep_name(handle_, &tep_name);
+ if (error_ != PMINFO_R_OK) {
LOG(DEBUG) << "pkgmgrinfo_pkginfo_get_tep_name failed with error: "
- << ret;
+ << error_;
return {};
}
std::string tep_name_value;
if (!IsValid())
return {};
char* zip_mount_file = nullptr;
- int ret = pkgmgrinfo_pkginfo_get_zip_mount_file(handle_,
+ error_ = pkgmgrinfo_pkginfo_get_zip_mount_file(handle_,
&zip_mount_file);
- if (ret != PMINFO_R_OK) {
+ if (error_ != PMINFO_R_OK) {
LOG(DEBUG) << "pkgmgrinfo_pkginfo_get_zip_mount_file failed with error: "
- << ret;
+ << error_;
return {};
}
std::string zip_mount_file_value;
std::string installed_location = "installed_internal";
pkgmgrinfo_installed_storage storage;
- bool ok = pkgmgrinfo_pkginfo_get_installed_storage(handle_,
- &storage) == PMINFO_R_OK;
+ error_ = pkgmgrinfo_pkginfo_get_installed_storage(handle_, &storage);
- if (!ok)
+ if (error_ != PMINFO_R_OK)
return "";
if (storage == PMINFO_EXTERNAL_STORAGE)
if (!IsValid())
return false;
bool is_global = false;
- if (pkgmgrinfo_pkginfo_is_for_all_users(handle_, &is_global) != PMINFO_R_OK) {
+ error_ = pkgmgrinfo_pkginfo_is_for_all_users(handle_, &is_global);
+ if (error_ != PMINFO_R_OK) {
LOG(ERROR) << "pkgmgrinfo_pkginfo_is_for_all_users failed";
return false;
}
if (!IsValid())
return false;
bool is_global = false;
- if (pkgmgrinfo_pkginfo_is_for_all_users(handle_, &is_global) != PMINFO_R_OK) {
+ error_ = pkgmgrinfo_pkginfo_is_for_all_users(handle_, &is_global);
+ if (error_ != PMINFO_R_OK) {
LOG(ERROR) << "pkgmgrinfo_pkginfo_is_for_all_users failed";
return false;
}
if (!IsValid())
return false;
bool is_readonly = false;
- if (pkgmgrinfo_pkginfo_is_readonly(handle_, &is_readonly) != PMINFO_R_OK) {
+ error_ = pkgmgrinfo_pkginfo_is_readonly(handle_, &is_readonly);
+ if (error_ != PMINFO_R_OK) {
LOG(ERROR) << "pkgmgrinfo_pkginfo_is_readonly failed";
return false;
}
if (!IsValid())
return false;
bool is_update = false;
- if (pkgmgrinfo_pkginfo_is_update(handle_, &is_update) != PMINFO_R_OK) {
+ error_ = pkgmgrinfo_pkginfo_is_update(handle_, &is_update);
+ if (error_ != PMINFO_R_OK) {
LOG(ERROR) << "pkgmgrinfo_pkginfo_is_update failed";
return false;
}
if (!IsValid())
return false;
bool is_preload = false;
- if (pkgmgrinfo_pkginfo_is_preload(handle_, &is_preload) != PMINFO_R_OK) {
+ error_ = pkgmgrinfo_pkginfo_is_preload(handle_, &is_preload);
+ if (error_ != PMINFO_R_OK) {
LOG(ERROR) << "pkgmgrinfo_pkginfo_is_preload failed";
return false;
}
if (!IsValid())
return false;
bool is_system = false;
- if (pkgmgrinfo_pkginfo_is_system(handle_, &is_system) != PMINFO_R_OK) {
+ error_ = pkgmgrinfo_pkginfo_is_system(handle_, &is_system);
+ if (error_ != PMINFO_R_OK) {
LOG(ERROR) << "pkgmgrinfo_pkginfo_is_system failed";
return false;
}
if (!IsValid())
return false;
bool is_removable = false;
- if (pkgmgrinfo_pkginfo_is_removable(handle_, &is_removable) != PMINFO_R_OK) {
+ error_ = pkgmgrinfo_pkginfo_is_removable(handle_, &is_removable);
+ if (error_ != PMINFO_R_OK) {
LOG(ERROR) << "pkgmgrinfo_pkginfo_is_removable failed";
return false;
}
bool PkgQueryInterface::AppidsForPkgId(std::vector<std::string>* result) {
if (!IsValid())
return false;
- bool ret = pkgmgrinfo_appinfo_get_usr_list(handle_, PMINFO_ALL_APP,
- &PkgmgrForeachAppCallback, result, uid_) == PMINFO_R_OK;
- return ret;
+ error_ = pkgmgrinfo_appinfo_get_usr_list(handle_, PMINFO_ALL_APP,
+ &PkgmgrForeachAppCallback, result, uid_);
+ return error_ == PMINFO_R_OK;
}
bool PkgQueryInterface::PrivilegesForPkgId(std::vector<std::string>* result) {
if (!IsValid())
return false;
- bool ret = pkgmgrinfo_pkginfo_foreach_privilege(handle_,
- &PkgmgrForeachPrivilegeCallback, result) == PMINFO_R_OK;
- return ret;
+ error_ = pkgmgrinfo_pkginfo_foreach_privilege(handle_,
+ &PkgmgrForeachPrivilegeCallback, result);
+ return error_ == PMINFO_R_OK;
}
std::string QueryCertificateAuthorCertificate(const std::string& pkgid,