// send START signal as soon as possible if not sent
if (pi_->state() == PkgmgrSignal::State::NOT_SENT) {
if (!context_->pkgid.get().empty()) {
- pi_->SendStarted(context_->pkg_type.get(), context_->pkgid.get());
+ pi_->SendStarted(context_->pkg_type.get(), context_->pkgid.get(),
+ context_->recovery_info.get());
}
}
if (pi_) {
// send START if pkgid was not parsed
if (pi_->state() == PkgmgrSignal::State::NOT_SENT) {
- pi_->SendStarted(context_->pkg_type.get(), context_->pkgid.get());
+ pi_->SendStarted(context_->pkg_type.get(), context_->pkgid.get(),
+ context_->recovery_info.get());
}
pi_->SendFinished(process_status,
context_->pkg_type.get(),
}
bool PkgmgrSignal::SendStarted(
- const std::string& type, const std::string& pkgid) {
+ const std::string& type, const std::string& pkgid,
+ const RecoveryInfo& recovery_info) {
if (state_ != State::NOT_SENT) {
return false;
}
if (key == kEventStr.end()) {
return false;
}
- if (!SendSignal(PKGMGR_INSTALLER_START_KEY_STR, key->second, type, pkgid)) {
+ const char* value;
+ if (request_type_ == ci::RequestType::Recovery) {
+ value = GetRecoverySignalValue(recovery_info.recovery_file->type());
+ if (!value)
+ return false;
+ }
+ else {
+ value = key->second;
+ }
+ if (!SendSignal(PKGMGR_INSTALLER_START_KEY_STR, value, type, pkgid)) {
return false;
}
for (auto l : user_list_) {
key = kEventStr.find(l.second);
if (key == kEventStr.end())
continue;
- SendSignal(l.first, PKGMGR_INSTALLER_START_KEY_STR, key->second, type,
+ SendSignal(l.first, PKGMGR_INSTALLER_START_KEY_STR, value, type,
pkgid);
}
return true;
}
+const char* PkgmgrSignal::GetRecoverySignalValue(RequestType recovery_type) {
+ switch (recovery_type) {
+ case RequestType::Install:
+ case RequestType::Uninstall:
+ case RequestType::MountInstall:
+ return PKGMGR_INSTALLER_UNINSTALL_EVENT_STR;
+ case RequestType::Update:
+ case RequestType::Reinstall:
+ case RequestType::Delta:
+ case RequestType::MountUpdate:
+ case RequestType::ReadonlyUpdateInstall:
+ return PKGMGR_INSTALLER_UPGRADE_EVENT_STR;
+ default:
+ LOG(ERROR) << "Unsupported request type for recovery";
+ return nullptr;
+ }
+}
+
bool PkgmgrSignal::SendProgress(int progress,
const std::string& type, const std::string& pkgid) {
if (state_ != State::STARTED) {
*
* \param type package type
* \param pkgid package pkgid
+ * \param recovery_info recovery information
*
* \return true if success
*/
bool SendStarted(
const std::string& type = std::string(),
- const std::string& pkgid = std::string());
+ const std::string& pkgid = std::string(),
+ const RecoveryInfo& recovery_info = RecoveryInfo());
/**
* "progress" Signal sending
bool SendAppids(uid_t uid, const std::string& type,
const std::string& pkgid) const;
bool SetupUserList(const std::string& pkgid);
+ const char* GetRecoverySignalValue(RequestType recovery_type);
pkgmgr_installer* pi_;
static State state_;