step/step_copy_storage_directories.cc
step/step_create_storage_directories.cc
step/step_generate_xml.cc
+ step/step_recover_application.cc
step/step_recover_files.cc
step/step_recover_icons.cc
step/step_recover_manifest.cc
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#include "common/step/step_recover_application.h"
+
+#include <boost/filesystem.hpp>
+
+#include "common/pkgmgr_registration.h"
+
+namespace bf = boost::filesystem;
+
+namespace common_installer {
+namespace pkgmgr {
+
+Step::Status StepRecoverApplication::RecoveryNew() {
+ if (!SetXmlPaths())
+ return Status::OK;
+ UnregisterAppInPkgmgr(context_->xml_path.get(), context_->pkgid.get(),
+ context_->uid.get());
+ return Status::OK;
+}
+
+Step::Status StepRecoverApplication::RecoveryUpdate() {
+ if (!SetXmlPaths()) {
+ LOG(ERROR) << "Some parameters are lacking";
+ return Status::ERROR;
+ }
+ bf::path xml_path = bf::exists(context_->backup_xml_path.get()) ?
+ context_->backup_xml_path.get() : context_->xml_path.get();
+ UnregisterAppInPkgmgr(xml_path, context_->pkgid.get(),
+ context_->uid.get());
+ if (!RegisterAppInPkgmgr(xml_path,
+ context_->pkgid.get().c_str(),
+ context_->certificate_info.get(),
+ context_->uid.get())) {
+ LOG(ERROR) << "Unsuccessful app registration";
+ return Status::ERROR;
+ }
+ return Status::OK;
+}
+
+bool StepRecoverApplication::SetXmlPaths() {
+ if (context_->pkgid.get().empty())
+ return false;
+ bf::path xml_path = bf::path(getUserManifestPath(context_->uid.get()))
+ / context_->pkgid.get();
+ xml_path += ".xml";
+ context_->xml_path.set(xml_path);
+ xml_path += ".bck";
+ context_->backup_xml_path.set(xml_path);
+ return true;
+}
+
+} // namespace pkgmgr
+} // namespace common_installer
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef COMMON_STEP_STEP_RECOVER_APPLICATION_H_
+#define COMMON_STEP_STEP_RECOVER_APPLICATION_H_
+
+#include "common/context_installer.h"
+#include "common/step/step_recovery.h"
+
+namespace common_installer {
+namespace pkgmgr {
+
+/**
+ * @brief recovers applications entries in pkgmgr
+ *
+ * Part of RecoveryMode. In case of partial installation
+ * app get unregistered with pkgmgr. In case of unsuccessful
+ * update app in state before update gets re-registered
+ */
+class StepRecoverApplication : public recovery::StepRecovery {
+ public:
+ using StepRecovery::StepRecovery;
+ Status RecoveryNew() override;
+ Status RecoveryUpdate() override;
+ private:
+ bool SetXmlPaths();
+
+ SCOPE_LOG_TAG(RecoverApplication)
+};
+
+} // namespace pkgmgr
+} // namespace common_installer
+
+#endif // COMMON_STEP_STEP_RECOVER_APPLICATION_H_