2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
18 #include <sys/types.h>
21 #include <klay/exception.h>
22 #include <klay/audit/logger.h>
24 #include "launchpad.h"
26 Launchpad::Launchpad(const uid_t uid) :
30 throw runtime::Exception("No logined user for launching app");
34 bool Launchpad::isRunning(const std::string& appid)
36 return ::aul_app_is_running_for_uid(appid.c_str(), user);
39 void Launchpad::launch(const std::string& appid)
41 launch(appid, Bundle());
44 void Launchpad::launch(const std::string& appid, const Bundle& bundle)
46 if (::aul_launch_app_for_uid(appid.c_str(), bundle.get(), user) < 0) {
47 throw runtime::Exception("Failed to launch app " + appid);
51 void Launchpad::resume(const std::string& appid)
53 if (::aul_resume_app_for_uid(appid.c_str(), user) < 0) {
54 throw runtime::Exception("Failed to resume app " + appid);
58 void Launchpad::terminate(const std::string& appid)
60 int pid = ::aul_app_get_pid_for_uid(appid.c_str(), user);
62 if (::aul_terminate_pid_for_uid(pid, user) < 0) {
63 WARN("Failed to terminate app PID=" + std::to_string(pid));