1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache-2.0 license that can be
3 // found in the LICENSE file.
5 #include "common/step/step_kill_apps.h"
7 #include <app_manager.h>
8 #include <app_manager_extension.h>
12 #include "common/utils/glist_range.h"
16 bool KillApp(const std::string& appid) {
17 bool is_running = false;
18 if (app_manager_is_running(appid.c_str(), &is_running)
19 != APP_MANAGER_ERROR_NONE) {
20 LOG(ERROR) << "app_manager_is_running failed";
26 app_context_h app_context;
27 if (app_manager_get_app_context(appid.c_str(), &app_context)
28 != APP_MANAGER_ERROR_NONE) {
29 LOG(ERROR) << "app_manager_get_app_context failed";
32 if (app_manager_terminate_app(app_context)
33 != APP_MANAGER_ERROR_NONE) {
34 LOG(ERROR) << "app_manager_terminate_app failed";
35 app_context_destroy(app_context);
38 LOG(DEBUG) << "Application '" << appid << "' has been killed";
39 app_context_destroy(app_context);
45 namespace common_installer {
48 Step::Status StepKillApps::process() {
49 manifest_x* old_manifest = context_->old_manifest_data.get() ?
50 context_->old_manifest_data.get() : context_->manifest_data.get();
51 for (application_x* app :
52 GListRange<application_x*>(old_manifest->application)) {
53 (void) KillApp(app->appid);
58 Step::Status StepKillApps::precheck() {
59 if (!context_->manifest_data.get() && !context_->old_manifest_data.get()) {
60 LOG(ERROR) << "manifest_data is empty";
67 } // namespace common_installer