return true;
}
+int PkgmgrForeachAppCallback(const pkgmgrinfo_appinfo_h handle,
+ void *user_data) {
+ auto* data = static_cast<std::vector<std::string>*>(user_data);
+ char* app_id = nullptr;
+ if (pkgmgrinfo_appinfo_get_appid(handle, &app_id) != PMINFO_R_OK)
+ return PMINFO_R_ERROR;
+ data->emplace_back(app_id);
+ return PMINFO_R_OK;
+}
+
} // anonymous namespace
namespace common_installer {
return old_author_certificate;
}
+
+bool QueryAppidsForPkgId(const std::string& pkg_id,
+ std::vector<std::string>* result, uid_t uid) {
+ pkgmgrinfo_pkginfo_h package_info;
+ if (pkgmgrinfo_pkginfo_get_usr_pkginfo(pkg_id.c_str(), uid, &package_info)
+ != PMINFO_R_OK) {
+ return false;
+ }
+
+ bool ret = pkgmgrinfo_appinfo_get_usr_list(package_info, PMINFO_ALL_APP,
+ &PkgmgrForeachAppCallback, result, uid) == PMINFO_R_OK;
+ pkgmgrinfo_pkginfo_destroy_pkginfo(package_info);
+ return ret;
+}
+
bool IsPackageInstalled(const std::string& pkg_id, RequestMode request_mode) {
pkgmgrinfo_pkginfo_h handle;
int ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkg_id.c_str(), getuid(),
#include <unistd.h>
#include <string>
+#include <vector>
#include "common/context_installer.h"
RequestMode request_mode);
std::string QueryCertificateAuthorCertificate(const std::string& pkgid,
uid_t uid);
+bool QueryAppidsForPkgId(const std::string& pkg_id,
+ std::vector<std::string>* result, uid_t uid);
bool IsPackageInstalled(const std::string& pkg_id, RequestMode request_mode);
} // namespace common_installer
#include "common/pkgmgr_signal.h"
+#include <unistd.h>
+#include <sys/types.h>
+
#include <cassert>
#include <map>
+#include <vector>
+#include "common/pkgmgr_registration.h"
#include "common/utils/logging.h"
// Redefine this value as it is not exported by pkgmgr
namespace {
-namespace ci=common_installer;
+namespace ci = common_installer;
-const std::map<ci::RequestType,const char *> kEventStr = {
+const std::map<ci::RequestType, const char*> kEventStr = {
{ci::RequestType::Install, PKGMGR_INSTALLER_INSTALL_EVENT_STR},
{ci::RequestType::Recovery, PKGMGR_INSTALLER_INSTALL_EVENT_STR},
{ci::RequestType::Reinstall, PKGMGR_INSTALLER_INSTALL_EVENT_STR},
{ci::RequestType::Uninstall, PKGMGR_INSTALLER_UNINSTALL_EVENT_STR},
- {ci::RequestType::Unknown, PKGMGR_INSTALLER_INSTALL_EVENT_STR}, //not needed
+ {ci::RequestType::Unknown, PKGMGR_INSTALLER_INSTALL_EVENT_STR}, // not needed
{ci::RequestType::Update, PKGMGR_INSTALLER_UPGRADE_EVENT_STR}
};
if (!SendSignal(PKGMGR_INSTALLER_START_KEY_STR, key->second, type, pkgid)) {
return false;
}
+
state_ = State::STARTED;
+
+ // workaround for pkgmgr client to know all appids which are uninstalled
+ if (request_type_ == ci::RequestType::Uninstall)
+ if (!SendAppids(type, pkgid))
+ return false;
+
return true;
}
}
}
+bool PkgmgrSignal::SendAppids(const std::string& type,
+ const std::string& pkgid) const {
+ std::vector<std::string> appids;
+ if (!QueryAppidsForPkgId(pkgid, &appids, getuid()))
+ return true;
+ for (auto& appid : appids) {
+ if (!pkgmgr_installer_send_app_uninstall_signal(pi_, type.c_str(),
+ pkgid.c_str(),
+ appid.c_str()))
+ return false;
+ }
+ return true;
+}
+
} // namespace common_installer