App-manager is used to kill apps.
Change-Id: I2b34b860bfb6b217b6de6190e8b82d1bb25c491c
PKG_CHECK_MODULES(LIBXML_DEPS REQUIRED libxml-2.0)
PKG_CHECK_MODULES(PRIVILEGE_CHECKER_DEPS REQUIRED capi-security-privilege-manager)
PKG_CHECK_MODULES(ENCRYPTION_DEPS REQUIRED libwebappenc)
+PKG_CHECK_MODULES(APPMANAGER_DEPS REQUIRED capi-appfw-app-manager)
FIND_PACKAGE(Boost REQUIRED COMPONENTS system filesystem regex)
FIND_PACKAGE(GTest REQUIRED)
BuildRequires: pkgconfig(manifest-handlers)
BuildRequires: pkgconfig(capi-security-privilege-manager)
BuildRequires: pkgconfig(libwebappenc)
+BuildRequires: pkgconfig(capi-appfw-app-manager)
Requires: ca-certificates-tizen
Requires: libtzplatform-config
step/step_copy_storage_directories.cc
step/step_create_storage_directories.cc
step/step_fail.cc
+ step/step_kill_apps.cc
step/step_recover_application.cc
step/step_recover_files.cc
step/step_recover_icons.cc
MINIZIP_DEPS
ZLIB_DEPS
PRIVILEGE_CHECKER_DEPS
+ APPMANAGER_DEPS
Boost
)
--- /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_kill_apps.h"
+
+#include <app_manager.h>
+#include <app_manager_extension.h>
+
+#include <string>
+
+#include "common/utils/clist_helpers.h"
+
+namespace {
+
+bool KillApp(const std::string& appid) {
+ bool is_running = false;
+ if (app_manager_is_running(appid.c_str(), &is_running)
+ != APP_MANAGER_ERROR_NONE) {
+ LOG(ERROR) << "app_manager_is_running failed";
+ return false;
+ }
+ if (!is_running) {
+ return false;
+ }
+ app_context_h app_context;
+ if (app_manager_get_app_context(appid.c_str(), &app_context)
+ != APP_MANAGER_ERROR_NONE) {
+ LOG(ERROR) << "app_manager_get_app_context failed";
+ return false;
+ }
+ if (app_manager_terminate_app(app_context)
+ != APP_MANAGER_ERROR_NONE) {
+ LOG(ERROR) << "app_manager_terminate_app failed";
+ app_context_destroy(app_context);
+ return false;
+ }
+ LOG(DEBUG) << "Application '" << appid << "' has been killed";
+ app_context_destroy(app_context);
+ return true;
+}
+
+} // namespace
+
+namespace common_installer {
+namespace pkgmgr {
+
+Step::Status StepKillApps::process() {
+ manifest_x* old_manifest = context_->old_manifest_data.get() ?
+ context_->old_manifest_data.get() : context_->manifest_data.get();
+ uiapplication_x* ui = nullptr;
+ PKGMGR_LIST_MOVE_NODE_TO_HEAD(old_manifest->uiapplication, ui);
+ for (; ui; ui = ui->next) {
+ if (!ui->appid)
+ continue;
+ (void) KillApp(ui->appid);
+ }
+ serviceapplication_x * svc = nullptr;
+ PKGMGR_LIST_MOVE_NODE_TO_HEAD(old_manifest->serviceapplication, svc);
+ for (; svc; svc = svc->next) {
+ if (!svc->appid)
+ continue;
+ (void) KillApp(svc->appid);
+ }
+ return Status::OK;
+}
+
+Step::Status StepKillApps::precheck() {
+ if (!context_->manifest_data.get() && !context_->old_manifest_data.get()) {
+ LOG(ERROR) << "manifest_data is empty";
+ return Status::ERROR;
+ }
+ return Status::OK;
+}
+
+} // 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_KILL_APPS_H_
+#define COMMON_STEP_STEP_KILL_APPS_H_
+
+#include "common/context_installer.h"
+#include "common/step/step.h"
+#include "common/utils/logging.h"
+
+namespace common_installer {
+namespace pkgmgr {
+
+class StepKillApps : public Step {
+ public:
+ using Step::Step;
+
+ Status process() override;
+ Status clean() override { return Status::OK; }
+ Status undo() override { return Status::OK; }
+ Status precheck() override;
+
+ SCOPE_LOG_TAG(KillApps)
+};
+
+} // namespace pkgmgr
+} // namespace common_installer
+
+#endif // COMMON_STEP_STEP_KILL_APPS_H_
#include "common/step/step_copy_backup.h"
#include "common/step/step_check_old_certificate.h"
#include "common/step/step_fail.h"
+#include "common/step/step_kill_apps.h"
#include "common/step/step_old_manifest.h"
#include "common/step/step_open_recovery_file.h"
#include "common/step/step_parse.h"
AddStep<ci::security::StepPrivilegeCompatibility>();
AddStep<ci::security::StepCheckOldCertificate>();
AddStep<ci::backup::StepOldManifest>();
+ AddStep<ci::pkgmgr::StepKillApps>();
AddStep<ci::backup::StepBackupManifest>();
AddStep<ci::backup::StepBackupIcons>();
AddStep<ci::backup::StepCopyBackup>();
void TpkInstaller::UninstallSteps() {
AddStep<ci::configuration::StepConfigure>(pkgmgr_);
AddStep<ci::parse::StepParse>();
+ AddStep<ci::pkgmgr::StepKillApps>();
AddStep<ci::backup::StepBackupManifest>();
AddStep<ci::pkgmgr::StepUnregisterApplication>();
AddStep<ci::security::StepRollbackDeinstallationSecurity>();
#include "common/step/step_copy_backup.h"
#include "common/step/step_copy_storage_directories.h"
#include "common/step/step_fail.h"
+#include "common/step/step_kill_apps.h"
#include "common/step/step_open_recovery_file.h"
#include "common/step/step_parse.h"
#include "common/step/step_privilege_compatibility.h"
AddStep<ci::security::StepCheckOldCertificate>();
AddStep<wgt::filesystem::StepWgtResourceDirectory>();
AddStep<ci::backup::StepOldManifest>();
+ AddStep<ci::pkgmgr::StepKillApps>();
AddStep<ci::backup::StepBackupManifest>();
AddStep<ci::backup::StepBackupIcons>();
AddStep<ci::backup::StepCopyBackup>();
case ci::RequestType::Uninstall: {
AddStep<ci::configuration::StepConfigure>(pkgmgr_);
AddStep<ci::parse::StepParse>();
+ AddStep<ci::pkgmgr::StepKillApps>();
AddStep<ci::backup::StepBackupManifest>();
AddStep<ci::pkgmgr::StepUnregisterApplication>();
AddStep<ci::security::StepRollbackDeinstallationSecurity>();
case ci::RequestType::Reinstall: {
AddStep<ci::configuration::StepConfigure>(pkgmgr_);
AddStep<wgt::parse::StepParse>(false);
+ AddStep<ci::pkgmgr::StepKillApps>();
AddStep<ci::backup::StepOldManifest>();
AddStep<wgt::rds::StepRDSParse>();
AddStep<wgt::rds::StepRDSModify>();