step/step_recover_files.cc
step/step_recover_icons.cc
step/step_recover_manifest.cc
+ step/step_recover_security.cc
step/step_recover_storage_directories.cc
step/step_recovery.cc
step/step_register_app.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_security.h"
+
+#include <boost/filesystem.hpp>
+
+#include "common/security_registration.h"
+
+namespace common_installer {
+namespace security {
+
+bool StepRecoverSecurity::Check() {
+ if (context_->pkg_path.get().empty())
+ return false;
+ if (!boost::filesystem::exists(context_->pkg_path.get()))
+ return false;
+ if (context_->pkgid.get().empty())
+ return false;
+ if (!context_->manifest_data.get())
+ return false;
+ return true;
+}
+
+Step::Status StepRecoverSecurity::RecoveryNew() {
+ if (!Check())
+ return Status::OK;
+ UnregisterSecurityContextForApps(
+ context_->pkgid.get(), context_->manifest_data.get());
+ return Status::OK;
+}
+
+Step::Status StepRecoverSecurity::RecoveryUpdate() {
+ if (!Check()) {
+ LOG(ERROR) << "Invalid parameters";
+ return Status::ERROR;
+ }
+ if (!RegisterSecurityContextForApps(
+ context_->pkgid.get(), context_->pkg_path.get(),
+ context_->manifest_data.get())) {
+ LOG(ERROR) << "Unsuccessful update";
+ return Status::ERROR;
+ }
+ return Status::OK;
+}
+} // namespace security
+} // 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_SECURITY_H_
+#define COMMON_STEP_STEP_RECOVER_SECURITY_H_
+
+#include "common/context_installer.h"
+#include "common/step/step_recovery.h"
+#include "common/utils/logging.h"
+
+namespace common_installer {
+namespace security {
+
+/**
+ * @brief responsible for restoring security
+ * rules
+ *
+ * Part of Recovery Mode. In case of partial
+ * installation security rules get unregistered
+ * In case of unsuccessful partial update
+ * security rules for the app before update
+ * gets restored
+ */
+class StepRecoverSecurity : public recovery::StepRecovery {
+ public:
+ using StepRecovery::StepRecovery;
+
+ Status RecoveryNew() override;
+ Status RecoveryUpdate() override;
+ private:
+ bool Check();
+
+ SCOPE_LOG_TAG(RecoverSecurity)
+};
+
+} // namespace security
+} // namespace common_installer
+
+#endif // COMMON_STEP_STEP_RECOVER_SECURITY_H_