Extract aul dependency from service_main.cpp 26/229526/4
authorJi-hoon Lee <dalton.lee@samsng.com>
Wed, 1 Apr 2020 15:03:59 +0000 (00:03 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Wed, 8 Apr 2020 05:05:13 +0000 (14:05 +0900)
Change-Id: Ifd796751933776c0153e8c78d345b94542ac37da

inc/application_manager.h
inc/application_manager_aul.h
inc/service_common.h
inc/service_main.h
src/application_manager_aul.cpp
src/service_main.cpp
tests/utc/client-manager/test_client_manager.cpp

index f6733fc..08b2586 100644 (file)
@@ -18,6 +18,7 @@
 #ifndef __APPLICATION_MANAGER_H__
 #define __APPLICATION_MANAGER_H__
 
+#include <boost/optional.hpp>
 #include <string>
 
 #ifdef __cplusplus
@@ -27,6 +28,10 @@ extern "C" {
 class IApplicationManager {
 public:
        virtual bool is_application_running(int pid) = 0;
+       virtual bool is_application_running(const std::string& appid) = 0;
+       virtual bool bring_app_to_foreground(const std::string& appid) = 0;
+       virtual bool launch_app_async(const std::string& appid, bool background) = 0;
+       virtual boost::optional<std::string> get_appid_by_pid(int pid) = 0;
 };
 
 #ifdef __cplusplus
index 2c47dc2..b0b3dd3 100644 (file)
@@ -20,8 +20,6 @@
 
 #include "application_manager.h"
 
-#include <string>
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -29,6 +27,10 @@ extern "C" {
 class CApplicationManagerAul : public IApplicationManager {
 public:
        virtual bool is_application_running(int pid) override;
+       virtual bool is_application_running(const std::string& appid) override;
+       virtual bool bring_app_to_foreground(const std::string& appid) override;
+       virtual bool launch_app_async(const std::string& appid, bool background) override;
+       virtual boost::optional<std::string> get_appid_by_pid(int pid) override;
 };
 
 #ifdef __cplusplus
index ecef87d..747b57a 100644 (file)
@@ -125,6 +125,8 @@ typedef void (*wakeup_service_voice_key_status_changed_cb)(ma_voice_key_status_e
 #define MAX_SUPPORTED_LANGUAGES_NUM 255
 #define MAX_SUPPORTED_LANGUAGE_LEN 16
 
+#define MAX_APPID_LEN 255
+
 typedef enum {
        VOICE_KEY_SUPPORT_MODE_NONE,
        VOICE_KEY_SUPPORT_MODE_PUSH_TO_TALK,
index 4bfaddd..4a6ddfa 100644 (file)
@@ -37,8 +37,6 @@
 extern "C" {
 #endif
 
-#define MAX_APPID_LEN 255
-
 typedef enum {
        CLIENT_LAUNCH_MODE_ACTIVATION,
        CLIENT_LAUNCH_MODE_PRELAUNCH,
index 2553c93..5cf8855 100644 (file)
@@ -18,6 +18,7 @@
 #include "service_common.h"
 
 #include <aul.h>
+#include <aul_svc.h>
 
 bool CApplicationManagerAul::is_application_running(int pid)
 {
@@ -27,4 +28,77 @@ bool CApplicationManagerAul::is_application_running(int pid)
                return false;
        }
        return true;
-}
\ No newline at end of file
+}
+
+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;
+       }
+
+       int result = aul_launch_app(appid.c_str(), b);
+       if (result < AUL_R_OK) {
+               MAS_LOGE("ERROR : aul_launch_app 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(int 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;
+}
index cad2c4a..5e660f9 100644 (file)
@@ -18,8 +18,6 @@
 #include <service_app.h>
 #include <app_manager.h>
 #include <app.h>
-#include <aul.h>
-#include <aul_svc.h>
 #include <malloc.h>
 #include <Ecore.h>
 #include <vconf.h>
@@ -160,13 +158,12 @@ int CServiceMain::mas_client_send_result(int pid, const char* display_text,
                MAS_LOGE("[ERROR] Fail to send result, ret(%d)", ret);
        }
 
-       const char* pid_appid = NULL;
-       char buf[MAX_APPID_LEN] = {'\0', };
-       if (AUL_R_OK == aul_app_get_appid_bypid(pid, buf, sizeof(buf))) {
-               buf[MAX_APPID_LEN - 1] = '\0';
-               pid_appid = buf;
+       std::string pid_appid;
+       boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
+       if (appid_by_pid) {
+               pid_appid = *appid_by_pid;
        }
-       mServicePlugin.update_recognition_result(pid_appid, MA_RECOGNITION_RESULT_EVENT_SUCCESS);
+       mServicePlugin.update_recognition_result(pid_appid.c_str(), MA_RECOGNITION_RESULT_EVENT_SUCCESS);
 
        return ret;
 }
@@ -179,13 +176,12 @@ int CServiceMain::mas_client_send_recognition_result(int pid, int result)
                MAS_LOGE("[ERROR] Fail to send recognition result, ret(%d)", ret);
        }
 
-       const char* pid_appid = NULL;
-       char buf[MAX_APPID_LEN] = {'\0', };
-       if (AUL_R_OK == aul_app_get_appid_bypid(pid, buf, sizeof(buf))) {
-               buf[MAX_APPID_LEN - 1] = '\0';
-               pid_appid = buf;
+       std::string pid_appid;
+       boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
+       if (appid_by_pid) {
+               pid_appid = *appid_by_pid;
        }
-       mServicePlugin.update_recognition_result(pid_appid, result);
+       mServicePlugin.update_recognition_result(pid_appid.c_str(), result);
 
        return ret;
 }
@@ -229,52 +225,48 @@ int CServiceMain::mas_client_stop_streaming_audio_data(int pid, int type)
 
 int CServiceMain::mas_client_update_voice_feedback_state(int pid, int state)
 {
-       const char* pid_appid = NULL;
-       char buf[MAX_APPID_LEN] = {'\0', };
-       if (AUL_R_OK == aul_app_get_appid_bypid(pid, buf, sizeof(buf))) {
-               buf[MAX_APPID_LEN - 1] = '\0';
-               pid_appid = buf;
+       std::string pid_appid;
+       boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
+       if (appid_by_pid) {
+               pid_appid = *appid_by_pid;
        }
-       mServicePlugin.update_voice_feedback_state(pid_appid, state);
+       mServicePlugin.update_voice_feedback_state(pid_appid.c_str(), state);
        return 0;
 }
 
 int CServiceMain::mas_client_set_assistant_specific_command(int pid, const char *command)
 {
-       const char* pid_appid = NULL;
-       char buf[MAX_APPID_LEN] = {'\0', };
-       if (AUL_R_OK == aul_app_get_appid_bypid(pid, buf, sizeof(buf))) {
-               buf[MAX_APPID_LEN - 1] = '\0';
-               pid_appid = buf;
+       std::string pid_appid;
+       boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
+       if (appid_by_pid) {
+               pid_appid = *appid_by_pid;
        }
-       mServicePlugin.set_assistant_specific_command(pid_appid, command);
+       mServicePlugin.set_assistant_specific_command(pid_appid.c_str(), command);
        return 0;
 }
 
 int CServiceMain::mas_client_set_background_volume(int pid, double ratio)
 {
-       const char* pid_appid = NULL;
-       char buf[MAX_APPID_LEN] = {'\0', };
-       if (AUL_R_OK == aul_app_get_appid_bypid(pid, buf, sizeof(buf))) {
-               buf[MAX_APPID_LEN - 1] = '\0';
-               pid_appid = buf;
+       std::string pid_appid;
+       boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
+       if (appid_by_pid) {
+               pid_appid = *appid_by_pid;
        }
-       mServicePlugin.set_background_volume(pid_appid, ratio);
+       mServicePlugin.set_background_volume(pid_appid.c_str(), ratio);
        return 0;
 }
 
 int CServiceMain::mas_client_set_preprocessing_allow_mode(int pid, ma_preprocessing_allow_mode_e mode, const char* appid)
 {
-       const char* pid_appid = NULL;
-       char buf[MAX_APPID_LEN] = {'\0', };
-       if (AUL_R_OK == aul_app_get_appid_bypid(pid, buf, sizeof(buf))) {
-               buf[MAX_APPID_LEN - 1] = '\0';
-               pid_appid = buf;
+       std::string pid_appid;
+       boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
+       if (appid_by_pid) {
+               pid_appid = *appid_by_pid;
        }
 
        for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM; loop++) {
                if (mClientInfo[loop].used) {
-                       if (pid_appid && strncmp(pid_appid, mClientInfo[loop].appid, MAX_APPID_LEN) == 0) {
+                       if (0 == pid_appid.compare(mClientInfo[loop].appid)) {
                                mClientInfo[loop].preprocessing_allow_mode = mode;
                                if (appid) {
                                        strncpy(mClientInfo[loop].preprocessing_allow_appid, appid, MAX_APPID_LEN);
@@ -293,13 +285,12 @@ int CServiceMain::mas_client_set_preprocessing_allow_mode(int pid, ma_preprocess
 
 int CServiceMain::mas_client_send_preprocessing_result(int pid, bool result)
 {
-       const char* pid_appid = NULL;
-       char buf[MAX_APPID_LEN] = {'\0', };
-       if (AUL_R_OK == aul_app_get_appid_bypid(pid, buf, sizeof(buf))) {
-               buf[MAX_APPID_LEN - 1] = '\0';
-               pid_appid = buf;
+       std::string pid_appid;
+       boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
+       if (appid_by_pid) {
+               pid_appid = *appid_by_pid;
        }
-       if (!is_current_preprocessing_assistant(pid_appid)) return -1;
+       if (!is_current_preprocessing_assistant(pid_appid.c_str())) return -1;
 
        const char *current_maclient_appid = NULL;
        if (mCurrentClientInfo >= 0 && mCurrentClientInfo < MAX_MACLIENT_INFO_NUM) {
@@ -307,7 +298,7 @@ int CServiceMain::mas_client_send_preprocessing_result(int pid, bool result)
        }
 
        if (result) {
-               MAS_LOGD("Preprocessing succeeded, bring (%s) to foreground", pid_appid);
+               MAS_LOGD("Preprocessing succeeded, bring (%s) to foreground", pid_appid.c_str());
                mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_PREPROCESSING_SUCCEEDED);
        } else {
                MAS_LOGD("Preprocessing failed, bring (%s) to foreground", current_maclient_appid);
@@ -325,49 +316,44 @@ int CServiceMain::mas_client_send_preprocessing_result(int pid, bool result)
 
 int CServiceMain::mas_client_set_wake_word_audio_require_flag(int pid, bool require)
 {
-       const char* pid_appid = NULL;
-       char buf[MAX_APPID_LEN] = {'\0', };
-       if (AUL_R_OK == aul_app_get_appid_bypid(pid, buf, sizeof(buf))) {
-               buf[MAX_APPID_LEN - 1] = '\0';
-               pid_appid = buf;
+       std::string pid_appid;
+       boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
+       if (appid_by_pid) {
+               pid_appid = *appid_by_pid;
        }
 
-       mServicePlugin.set_wake_word_audio_require_flag(pid_appid, require);
+       mServicePlugin.set_wake_word_audio_require_flag(pid_appid.c_str(), require);
        return 0;
 }
 
 int CServiceMain::mas_client_set_assistant_language(int pid, const char* language)
 {
-       const char* pid_appid = NULL;
-       char buf[MAX_APPID_LEN] = {'\0', };
-       int ret = aul_app_get_appid_bypid(pid, buf, sizeof(buf));
-       if (AUL_R_OK == ret) {
-               buf[MAX_APPID_LEN - 1] = '\0';
-               pid_appid = buf;
+       std::string pid_appid;
+       boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
+       if (appid_by_pid) {
+               pid_appid = *appid_by_pid;
        }
 
-       mServicePlugin.set_assistant_language(pid_appid, language);
+       mServicePlugin.set_assistant_language(pid_appid.c_str(), language);
        return 0;
 }
 
 int CServiceMain::mas_client_add_wake_word(int pid, const char* wake_word, const char* language)
 {
-       const char* pid_appid = NULL;
-       char buf[MAX_APPID_LEN] = {'\0', };
-       int ret = aul_app_get_appid_bypid(pid, buf, sizeof(buf));
-       if (AUL_R_OK == ret) {
-               buf[MAX_APPID_LEN - 1] = '\0';
-               pid_appid = buf;
+       std::string pid_appid;
+       boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
+       if (appid_by_pid) {
+               pid_appid = *appid_by_pid;
        }
 
        for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM; loop++) {
                if (mClientInfo[loop].used &&
-                       0 == strncmp(buf, mClientInfo[loop].appid, MAX_APPID_LEN)) {
-                       ret = mServiceConfig.add_custom_wake_word(wake_word, language,
+                       0 == pid_appid.compare(mClientInfo[loop].appid)) {
+                       int ret = mServiceConfig.add_custom_wake_word(wake_word, language,
                                mClientInfo[loop].wakeup_word,
                                mClientInfo[loop].wakeup_language);
                        if (0 == ret) {
-                               mServiceConfig.save_custom_wake_words(pid_appid,
+                               mServiceConfig.save_custom_wake_words(pid_appid.c_str(),
                                        mClientInfo[loop].wakeup_word,
                                        mClientInfo[loop].wakeup_language);
                        } else {
@@ -377,35 +363,33 @@ int CServiceMain::mas_client_add_wake_word(int pid, const char* wake_word, const
                }
        }
 
-       mServicePlugin.add_assistant_wakeup_word(pid_appid, wake_word, language);
+       mServicePlugin.add_assistant_wakeup_word(pid_appid.c_str(), wake_word, language);
        return 0;
 }
 
 int CServiceMain::mas_client_remove_wake_word(int pid, const char* wake_word, const char* language)
 {
-       const char* pid_appid = NULL;
-       char buf[MAX_APPID_LEN] = {'\0', };
-       int ret = aul_app_get_appid_bypid(pid, buf, sizeof(buf));
-       if (AUL_R_OK == ret) {
-               buf[MAX_APPID_LEN - 1] = '\0';
-               pid_appid = buf;
+       std::string pid_appid;
+       boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
+       if (appid_by_pid) {
+               pid_appid = *appid_by_pid;
        }
 
        for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM; loop++) {
                if (mClientInfo[loop].used &&
-                       0 == strncmp(buf, mClientInfo[loop].appid, MAX_APPID_LEN)) {
-                       ret = mServiceConfig.remove_custom_wake_word(wake_word, language,
+                       0 == pid_appid.compare(mClientInfo[loop].appid)) {
+                       int ret = mServiceConfig.remove_custom_wake_word(wake_word, language,
                                mClientInfo[loop].wakeup_word,
                                mClientInfo[loop].wakeup_language);
                        if (0 == ret) {
-                               mServiceConfig.save_custom_wake_words(pid_appid,
+                               mServiceConfig.save_custom_wake_words(pid_appid.c_str(),
                                        mClientInfo[loop].wakeup_word,
                                        mClientInfo[loop].wakeup_language);
                        }
                }
        }
 
-       mServicePlugin.remove_assistant_wakeup_word(pid_appid, wake_word, language);
+       mServicePlugin.remove_assistant_wakeup_word(pid_appid.c_str(), wake_word, language);
        return 0;
 }
 
@@ -720,10 +704,8 @@ int CServiceMain::mas_get_client_pid_by_appid(const char *appid)
                ret = mClientManager.find_client_pid_by_appid(std::string{appid});
        }
 
-       int status = aul_app_get_status_bypid(ret);
-       if (-1 != ret && 0 > status) {
-               MAS_LOGE("The PID for %s was %d, but it seems to be terminated : %d",
-                       (appid ? appid : "NULL"), ret, status);
+       if (-1 != ret && !mApplicationManager.is_application_running(ret)) {
+               MAS_LOGE("The PID for %s was %d, but it seems to be terminated", appid, ret);
                on_deinitialize(ret);
                ret = -1;
        }
@@ -879,36 +861,22 @@ int CServiceMain::mas_set_current_client_by_appid(const char *appid)
 
 int CServiceMain::mas_launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE launch_mode)
 {
+       int result = 0;
+
        if (NULL == appid || 0 == strlen(appid)) {
                MAS_LOGE("appid invalid, failed launching MA Client");
                return -1;
        }
 
        if (CLIENT_LAUNCH_MODE_PRELAUNCH == launch_mode) {
-               if (1 == aul_app_is_running(appid)) {
+               if (mApplicationManager.is_application_running(appid)) {
                        MAS_LOGE("appid %s is already running, no need for a prelaunch", appid);
                        return -1;
                }
-       }
-
-       bundle *b = NULL;
-       b = bundle_create();
-       if (NULL == b) {
-               MAS_LOGE("Failed creating bundle for aul operation");
-               return -1;
-       }
 
-       int result = aul_svc_set_background_launch(b,
-               (CLIENT_LAUNCH_MODE_PRELAUNCH == launch_mode ? TRUE : FALSE));
-       if (result < AUL_R_OK) {
-               MAS_LOGE("ERROR : aul_svc_set_background_launch failed. app_id [%s] bundle[%p] result[%d : %s]",
-                       appid, b, result, get_error_message(result));
-       }
-
-       result = aul_launch_app_async(appid, b);
-       if (result < AUL_R_OK) {
-               MAS_LOGE("ERROR : aul_launch_app_async failed. app_id [%s] bundle[%p] result[%d : %s]",
-                       appid, b, result, get_error_message(result));
+               result = mApplicationManager.launch_app_async(appid, true);
+       } else {
+               result = mApplicationManager.launch_app_async(appid, false);
        }
 
        if (CLIENT_LAUNCH_MODE_ACTIVATION == launch_mode) {
@@ -925,37 +893,23 @@ int CServiceMain::mas_launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MO
                MAS_LOGD("mWakeupClientAppId : %s, %d", mWakeupClientAppId.c_str(), found);
        }
 
-       if (b) bundle_free(b);
-       b = NULL;
-
        return result;
 }
 
 int CServiceMain::mas_bring_client_to_foreground(const char* appid)
 {
-       /* Bring MA client to foreground - is there a better way other than launching? */
+       int ret = 0;
+
        if (NULL == appid || 0 == strlen(appid)) {
                MAS_LOGE("appid invalid, failed launching MA Client");
                return -1;
        }
 
-       bundle *b = NULL;
-       b = bundle_create();
-       if (NULL == b) {
-               MAS_LOGE("Failed creating bundle for aul operation");
-               return -1;
-       }
-
-       int result = aul_launch_app(appid, b);
-       if (result < AUL_R_OK) {
-               MAS_LOGE("ERROR : aul_launch_app failed. app_id [%s] bundle[%p] result[%d : %s]",
-                       appid, b, result, get_error_message(result));
+       if (!mApplicationManager.bring_app_to_foreground(appid)) {
+               ret = -1;
        }
 
-       if (b) bundle_free(b);
-       b = NULL;
-
-       return result;
+       return ret;
 }
 
 int CServiceMain::mas_launch_client_by_wakeup_word(const char *wakeup_word)
@@ -972,7 +926,7 @@ int CServiceMain::mas_prelaunch_default_assistant()
        if (prelaunch_mode && *prelaunch_mode) {
                const char *default_assistant = NULL;
                if (0 == mServicePlugin.get_default_assistant(&default_assistant)) {
-                       if (0 == aul_app_is_running(default_assistant)) {
+                       if (!(mApplicationManager.is_application_running(default_assistant))) {
                                MAS_LOGD("prelaunching default_assistant_appid : %s", default_assistant);
                                mas_launch_client_by_appid(default_assistant, CLIENT_LAUNCH_MODE_PRELAUNCH);
                        }
@@ -1382,19 +1336,19 @@ void CServiceMain::app_terminate(void *data)
 int CServiceMain::on_initialize(int pid) {
        MAS_LOGD("[Enter] pid(%d)", pid);
 
-       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';
-
-               MAS_LOGD("appid for pid %d is : %s", pid, (appid ? appid : "Unknown"));
+       std::string pid_appid;
+       boost::optional<std::string> appid_by_pid = mApplicationManager.get_appid_by_pid(pid);
+       if (appid_by_pid) {
+               pid_appid = *appid_by_pid;
+               MAS_LOGD("appid for pid %d is : %s", pid, pid_appid.c_str());
 
                /* Remove existing client that has same appid, if there's any */
-               mClientManager.destroy_client_by_appid(appid);
+               mClientManager.destroy_client_by_appid(pid_appid.c_str());
 
                /* And remove a client that has same pid also */
                mClientManager.destroy_client_by_pid(pid);
 
-               mClientManager.create_client(pid, appid);
+               mClientManager.create_client(pid, pid_appid.c_str());
 
                const char *current_maclient_appid = NULL;
                if (mCurrentClientInfo >= 0 && mCurrentClientInfo < MAX_MACLIENT_INFO_NUM) {
@@ -1405,16 +1359,16 @@ int CServiceMain::on_initialize(int pid) {
                if (MA_VOICE_KEY_STATUS_PRESSED == mLastVoiceKeyStatus) {
                        mas_client_send_voice_key_status_change(pid, mLastVoiceKeyStatus);
                }
-               if (current_maclient_appid && 0 == strncmp(current_maclient_appid, appid, MAX_APPID_LEN)) {
+               if (current_maclient_appid && 0 == pid_appid.compare(current_maclient_appid)) {
                        MAS_LOGD("MA client with current maclient appid connected!");
 
-                       if (0 == mWakeupClientAppId.compare(appid)) {
+                       if (0 == mWakeupClientAppId.compare(pid_appid)) {
                                mWakeupClientAppId.clear();
                                mServiceIpc.active_state_change(pid, MA_ACTIVE_STATE_ACTIVE);
                                mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED);
                        } else {
                                MAS_LOGE("[ERROR] mWakeupClientAppId and appid differ : %s %s",
-                                       mWakeupClientAppId.c_str(), appid);
+                                       mWakeupClientAppId.c_str(), pid_appid.c_str());
                        }
                } else {
                        MAS_LOGD("MA client connected, but its appid does not match with current maclient");
index e77ded9..ef1357f 100644 (file)
@@ -27,6 +27,10 @@ public:
        virtual ~CDummyApplicationManager() {};
 
        bool is_application_running(int pid) { return true; }
+       bool is_application_running(const std::string& appid) { return true; }
+       bool bring_app_to_foreground(const std::string& appid) { return true; }
+       bool launch_app_async(const std::string& appid, bool background) { return true; }
+       boost::optional<std::string> get_appid_by_pid(int pid) { return boost::optional<std::string>{}; }
 };
 
 class StorageWithNoClient : public testing::Test