Merge branch 'tizen_5.5' into tizen 57/239157/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Wed, 22 Jul 2020 07:47:22 +0000 (16:47 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Wed, 22 Jul 2020 07:47:22 +0000 (16:47 +0900)
Change-Id: If37f3299bee58ac0bfc4562761c4fa56238ab013

1  2 
src/application_manager_aul.cpp

index 00b6ecb,0000000..f1fd82a
mode 100644,000000..100644
--- /dev/null
@@@ -1,124 -1,0 +1,124 @@@
-       int result = aul_launch_app(appid.c_str(), b);
 +/*
 + * Copyright 2020 Samsung Electronics Co., Ltd
 + *
 + * Licensed under the Flora License, Version 1.1 (the License);
 + * you may not use this file except in compliance with the License.
 + * You may obtain a copy of the License at
 + *
 + * http://floralicense.org/license/
 + *
 + * Unless required by applicable law or agreed to in writing, software
 + * distributed under the License is distributed on an AS IS BASIS,
 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 + * See the License for the specific language governing permissions and
 + * limitations under the License.
 + */
 +
 +#include "application_manager_aul.h"
 +#include "service_common.h"
 +
 +#include <aul.h>
 +#include <aul_svc.h>
 +
 +CApplicationManagerAul::CApplicationManagerAul()
 +{
 +}
 +
 +CApplicationManagerAul::~CApplicationManagerAul()
 +{
 +}
 +
 +bool CApplicationManagerAul::is_application_running(pid_t pid)
 +{
 +      int status = aul_app_get_status_bypid(pid);
 +      if (0 > status) {
 +              MAS_LOGE("The process %d does not exist : %d", pid, status);
 +              return false;
 +      }
 +      return true;
 +}
 +
 +bool CApplicationManagerAul::is_application_running(const std::string& appid)
 +{
 +      return (!!aul_app_is_running(appid.c_str()));
 +}
 +
 +bool CApplicationManagerAul::bring_app_to_foreground(const std::string& appid)
 +{
 +      bool ret = true;
 +
 +      /* Bring MA client to foreground - is there a better way other than launching? */
 +      bundle *b = NULL;
 +      b = bundle_create();
 +      if (NULL == b) {
 +              MAS_LOGE("Failed creating bundle for aul operation");
 +              return -1;
 +      }
 +
-               MAS_LOGE("ERROR : aul_launch_app failed. app_id [%s] bundle[%p] result[%d : %s]",
++      int result = aul_launch_app_async(appid.c_str(), b);
 +      if (result < AUL_R_OK) {
- }
++              MAS_LOGE("ERROR : aul_launch_app_async failed. app_id [%s] bundle[%p] result[%d : %s]",
 +                      appid.c_str(), b, result, get_error_message(result));
 +              ret = false;
 +      }
 +
 +      if (b) bundle_free(b);
 +      b = NULL;
 +
 +      return ret;
 +}
 +
 +bool CApplicationManagerAul::launch_app_async(const std::string& appid, bool background)
 +{
 +      bool ret = true;
 +
 +      bundle *b = NULL;
 +      b = bundle_create();
 +      if (NULL == b) {
 +              MAS_LOGE("Failed creating bundle for aul operation");
 +              return false;
 +      }
 +
 +      int result = aul_svc_set_background_launch(b, background);
 +      if (result < AUL_R_OK) {
 +              MAS_LOGE("ERROR : aul_svc_set_background_launch failed. app_id [%s] bundle[%p] result[%d : %s]",
 +                      appid.c_str(), b, result, get_error_message(result));
 +      }
 +
 +      result = aul_launch_app_async(appid.c_str(), b);
 +      if (result < AUL_R_OK) {
 +              MAS_LOGE("ERROR : aul_launch_app_async failed. app_id [%s] bundle[%p] result[%d : %s]",
 +                      appid.c_str(), b, result, get_error_message(result));
 +              ret = false;
 +      }
 +
 +      if (b) bundle_free(b);
 +      b = NULL;
 +
 +      return ret;
 +}
 +
 +boost::optional<std::string> CApplicationManagerAul::get_appid_by_pid(pid_t pid)
 +{
 +      boost::optional<std::string> ret;
 +
 +      char appid[MAX_APPID_LEN] = {'\0', };
 +      if (AUL_R_OK == aul_app_get_appid_bypid(pid, appid, sizeof(appid))) {
 +              appid[MAX_APPID_LEN - 1] = '\0';
 +              ret = std::string{appid};
 +      }
 +
 +      return ret;
 +}
 +
 +boost::optional<pid_t> CApplicationManagerAul::get_pid_by_appid(const std::string& appid)
 +{
 +      boost::optional<pid_t> ret;
 +
 +      pid_t pid = aul_app_get_pid(appid.c_str());
 +      if (pid >= 0) {
 +              ret = pid;
 +      }
 +
 +      return ret;
++}