configuration.
Previously, AppInstaller included the general logic and some setup of
InstallerContext. However, InstallerContext should be only used within steps
(AppInstaller) should not mix the data and the logic.
Hence, Almost all context setup was moved to separate, new step - Configure
Change-Id: I508d2383bd6fca66326aa18df1bedb6f52fae3a6
security_registration.cc
step/step_unzip.cc
step/step_check_signature.cc
+ step/step_configure.cc
step/step_copy.cc
step/step_generate_xml.cc
step/step_register_app.cc
#include "common/pkgmgr_signal.h"
#include "utils/logging.h"
-#define STR_EMPTY ""
-
namespace {
const unsigned kProgressRange = 100;
: context_(new ContextInstaller()) {
PkgMgrPtr pkgmgr = PkgMgrInterface::Instance();
pi_.reset(new PkgmgrSignal(pkgmgr.get()->GetRawPi()));
+
+ // TODO(p.sikorski) below property is only used in AppInstaller.
+ // maybe it should then be kept in AppInstaller
context_->pkg_type.set(package_type);
- switch (pkgmgr->GetRequestType()) {
- case PkgMgrInterface::Type::Install:
- context_->file_path.set(pkgmgr->GetRequestInfo());
- context_->pkgid.set(STR_EMPTY);
- break;
- case PkgMgrInterface::Type::Uninstall:
- context_->pkgid.set(pkgmgr->GetRequestInfo());
- context_->file_path.set(STR_EMPTY);
- break;
- default:
- // currently, only installation and uninstallation handled
- // TODO(p.sikorski): should return unsupported, and display error
- break;
- }
}
AppInstaller::~AppInstaller() {
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#include "common/step/step_configure.h"
+
+#include "common/pkgmgr_interface.h"
+
+namespace common_installer {
+namespace configure {
+
+const char *kStrEmpty = "";
+
+Step::Status StepConfigure::process() {
+ PkgMgrPtr pkgmgr = PkgMgrInterface::Instance();
+
+ switch (pkgmgr->GetRequestType()) {
+ case PkgMgrInterface::Type::Install:
+ context_->file_path.set(pkgmgr->GetRequestInfo());
+ context_->pkgid.set(kStrEmpty);
+ break;
+ case PkgMgrInterface::Type::Uninstall:
+ context_->pkgid.set(pkgmgr->GetRequestInfo());
+ context_->file_path.set(kStrEmpty);
+ break;
+ default:
+ // currently, only installation and uninstallation handled
+ // TODO(p.sikorski): should return unsupported, and display error
+ LOG(ERROR) << "Only installation and uninstallation is now supported";
+ return Status::ERROR;
+ break;
+ }
+
+ return Status::OK;
+}
+
+} // namespace configure
+} // namespace common_installer
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef COMMON_STEP_STEP_CONFIGURE_H_
+#define COMMON_STEP_STEP_CONFIGURE_H_
+
+#include "common/context_installer.h"
+
+#include "common/step/step.h"
+#include "utils/logging.h"
+
+namespace common_installer {
+namespace configure {
+
+class StepConfigure : public Step {
+ public:
+ using Step::Step;
+
+ Status process() override;
+ Status clean() override { return Status::OK; }
+ Status undo() override { return Status::OK; }
+
+ SCOPE_LOG_TAG(Configure)
+};
+
+} // namespace configure
+} // namespace common_installer
+
+#endif // COMMON_STEP_STEP_CONFIGURE_H_
#else
#include "common/pkgmgr_interface.h"
#include "common/app_installer.h"
+#include "common/step/step_configure.h"
#include "common/step/step_copy.h"
#include "common/step/step_generate_xml.h"
#include "common/step/step_parse.h"
int Task::Install() {
ci::AppInstaller ai(kPkgType);
+ ai.AddStep<ci::configure::StepConfigure>();
ai.AddStep<ci::unzip::StepUnzip>();
ai.AddStep<ci::signature::StepCheckSignature>();
ai.AddStep<tpk::step::StepParse>();
int Task::Uninstall() {
ci::AppInstaller ai(kPkgType);
+ ai.AddStep<ci::configure::StepConfigure>();
ai.AddStep<ci::parse::StepParse>();
ai.AddStep<ci::unregister_app::StepUnregisterApplication>();
ai.AddStep<ci::remove::StepRemoveFiles>();
#include "common/app_installer.h"
#include "common/pkgmgr_interface.h"
+#include "common/step/step_configure.h"
#include "common/step/step_copy.h"
#include "common/step/step_generate_xml.h"
#include "common/step/step_parse.h"
/* treat the request */
switch (pkgmgr->GetRequestType()) {
case ci::PkgMgrInterface::Type::Install : {
+ installer.AddStep<ci::configure::StepConfigure>();
installer.AddStep<ci::unzip::StepUnzip>();
installer.AddStep<ci::signature::StepCheckSignature>();
installer.AddStep<wgt::parse::StepParse>();
break;
}
case ci::PkgMgrInterface::Type::Uninstall: {
+ installer.AddStep<ci::configure::StepConfigure>();
installer.AddStep<ci::parse::StepParse>();
installer.AddStep<ci::unregister_app::StepUnregisterApplication>();
installer.AddStep<ci::remove::StepRemoveFiles>();