#include <boost/filesystem.hpp>
#include "common/paths.h"
+#include "common/pkgmgr_query.h"
#include "common/pkgmgr_registration.h"
namespace bf = boost::filesystem;
Step::Status StepRecoverApplication::RecoveryNew() {
if (!SetXmlPaths())
return Status::OK;
- if (context_->manifest_data.get())
- UnregisterAppInPkgmgr(context_->manifest_data.get(),
- context_->pkgid.get(),
- context_->uid.get(),
- context_->request_mode.get());
- else
- UnregisterAppInPkgmgrForPkgId(context_->pkgid.get(),
- context_->uid.get(),
- context_->request_mode.get());
+ UnregisterApplication();
return Status::OK;
}
LOG(ERROR) << "Some parameters are lacking";
return Status::ERROR;
}
- UnregisterAppInPkgmgr(context_->manifest_data.get(),
- context_->pkgid.get(),
- context_->uid.get(),
- context_->request_mode.get());
- if (!RegisterAppInPkgmgr(context_->manifest_data.get(),
- context_->pkgid.get(),
- context_->certificate_info.get(),
- context_->uid.get(),
- context_->storage.get(),
- context_->request_mode.get(),
- context_->tep_path.get())) {
+ PkgQueryInterface pkg_query(context_->pkgid.get(), context_->uid.get());
+ if (pkg_query.IsUpdatedPackage())
+ SetExtraAttributes(true);
+ UnregisterApplication();
+ if (!RegisterApplication()) {
LOG(ERROR) << "Unsuccessful app registration";
return Status::RECOVERY_ERROR;
}
}
Step::Status StepRecoverApplication::RecoveryReadonlyUpdateInstall() {
- // Hmm... this is just-work solution...
- manifest_x* manifest_data = context_->manifest_data.get();
- free(manifest_data->system);
- manifest_data->system = strdup("true");
- free(manifest_data->preload);
- manifest_data->preload = strdup("true");
- free(manifest_data->readonly);
- manifest_data->readonly = strdup("true");
- free(manifest_data->removable);
- manifest_data->removable = strdup("false");
- return RecoveryUpdate();
+ if (!SetXmlPaths()) {
+ LOG(ERROR) << "Some parameters are lacking";
+ return Status::ERROR;
+ }
+ SetExtraAttributes(false);
+ UnregisterApplication();
+ if (!RegisterApplication()) {
+ LOG(ERROR) << "Unsuccessful app registration";
+ return Status::RECOVERY_ERROR;
+ }
+ return Status::OK;
}
bool StepRecoverApplication::SetXmlPaths() {
return true;
}
+void StepRecoverApplication::SetExtraAttributes(bool is_updated) {
+ manifest_x* manifest_data = context_->manifest_data.get();
+ free(manifest_data->system);
+ manifest_data->system = strdup("true");
+ free(manifest_data->preload);
+ manifest_data->preload = strdup("true");
+ free(manifest_data->update);
+ manifest_data->update = strdup(is_updated ? "true" : "false");
+ free(manifest_data->readonly);
+ manifest_data->readonly = strdup(is_updated ? "false" : "true");
+ free(manifest_data->removable);
+ manifest_data->removable = strdup(is_updated ? "true" : "false");
+}
+
+bool StepRecoverApplication::UnregisterApplication() {
+ if (context_->manifest_data.get())
+ return UnregisterAppInPkgmgr(context_->manifest_data.get(),
+ context_->pkgid.get(),
+ context_->uid.get(),
+ context_->request_mode.get());
+ else
+ return UnregisterAppInPkgmgrForPkgId(context_->pkgid.get(),
+ context_->uid.get(),
+ context_->request_mode.get());
+}
+
+bool StepRecoverApplication::RegisterApplication() {
+ return RegisterAppInPkgmgr(context_->manifest_data.get(),
+ context_->pkgid.get(),
+ context_->certificate_info.get(),
+ context_->uid.get(),
+ context_->storage.get(),
+ context_->request_mode.get(),
+ context_->tep_path.get());
+}
+
} // namespace pkgmgr
} // namespace common_installer