2 * Copyright 2020 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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.
17 #include "application_manager_aul.h"
18 #include "service_common.h"
23 CApplicationManagerAul::CApplicationManagerAul()
27 CApplicationManagerAul::~CApplicationManagerAul()
31 bool CApplicationManagerAul::is_application_running(pid_t pid)
33 int status = aul_app_get_status_bypid(pid);
35 MAS_LOGE("The process %d does not exist : %d", pid, status);
41 bool CApplicationManagerAul::is_application_running(const std::string& appid)
43 return (!!aul_app_is_running(appid.c_str()));
46 bool CApplicationManagerAul::bring_app_to_foreground(const std::string& appid)
50 /* Bring MA client to foreground - is there a better way other than launching? */
54 MAS_LOGE("Failed creating bundle for aul operation");
58 int result = aul_launch_app(appid.c_str(), b);
59 if (result < AUL_R_OK) {
60 MAS_LOGE("ERROR : aul_launch_app failed. app_id [%s] bundle[%p] result[%d : %s]",
61 appid.c_str(), b, result, get_error_message(result));
65 if (b) bundle_free(b);
71 bool CApplicationManagerAul::launch_app_async(const std::string& appid, bool background)
78 MAS_LOGE("Failed creating bundle for aul operation");
82 int result = aul_svc_set_background_launch(b, background);
83 if (result < AUL_R_OK) {
84 MAS_LOGE("ERROR : aul_svc_set_background_launch failed. app_id [%s] bundle[%p] result[%d : %s]",
85 appid.c_str(), b, result, get_error_message(result));
88 result = aul_launch_app_async(appid.c_str(), b);
89 if (result < AUL_R_OK) {
90 MAS_LOGE("ERROR : aul_launch_app_async failed. app_id [%s] bundle[%p] result[%d : %s]",
91 appid.c_str(), b, result, get_error_message(result));
95 if (b) bundle_free(b);
101 boost::optional<std::string> CApplicationManagerAul::get_appid_by_pid(pid_t pid)
103 boost::optional<std::string> ret;
105 char appid[MAX_APPID_LEN] = {'\0', };
106 if (AUL_R_OK == aul_app_get_appid_bypid(pid, appid, sizeof(appid))) {
107 appid[MAX_APPID_LEN - 1] = '\0';
108 ret = std::string{appid};