From 702ab10c82b63ed4cf02def6690918ef1f864bfa Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Mon, 13 Apr 2020 21:25:04 +0900 Subject: [PATCH 01/16] Send audio data to the dedicated audio processing app if exists Change-Id: Id361946ae510d939acdfc1c5dbb82394be4fab6e --- inc/application_manager.h | 1 + inc/application_manager_aul.h | 1 + inc/service_ipc_dbus.h | 4 ++++ inc/service_main.h | 3 +++ src/application_manager_aul.cpp | 12 ++++++++++++ src/service_ipc_dbus.cpp | 24 ++++++++++++++++-------- src/service_main.cpp | 18 ++++++++++++++++++ src/service_plugin.cpp | 6 +++++- tests/utc/client-manager/test_client_manager.cpp | 1 + tests/utc/service-main/test_service_main.cpp | 1 + 10 files changed, 62 insertions(+), 9 deletions(-) diff --git a/inc/application_manager.h b/inc/application_manager.h index 1effd84..05bdcca 100644 --- a/inc/application_manager.h +++ b/inc/application_manager.h @@ -32,6 +32,7 @@ public: 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 get_appid_by_pid(pid_t pid) = 0; + virtual boost::optional get_pid_by_appid(const std::string& appid) = 0; }; #ifdef __cplusplus diff --git a/inc/application_manager_aul.h b/inc/application_manager_aul.h index 4b46f59..9e3bedb 100644 --- a/inc/application_manager_aul.h +++ b/inc/application_manager_aul.h @@ -34,6 +34,7 @@ public: 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 get_appid_by_pid(pid_t pid) override; + boost::optional get_pid_by_appid(const std::string& appid) override; }; #ifdef __cplusplus diff --git a/inc/service_ipc_dbus.h b/inc/service_ipc_dbus.h index 9c5e40b..b462aec 100644 --- a/inc/service_ipc_dbus.h +++ b/inc/service_ipc_dbus.h @@ -59,6 +59,9 @@ public: void set_client_manager(CClientManager* manager) { mClientManager = manager; } + void set_application_manager(IApplicationManager* manager) { + mApplicationManager = manager; + } void set_service_ipc_observer(IServiceIpcObserver* observer) { mDispatcher.set_ipc_observer(observer); } @@ -79,6 +82,7 @@ private: int mStreamingDataSerial{0}; CClientManager* mClientManager{nullptr}; + IApplicationManager* mApplicationManager{nullptr}; }; #ifdef __cplusplus diff --git a/inc/service_main.h b/inc/service_main.h index a6e0c00..6aed620 100644 --- a/inc/service_main.h +++ b/inc/service_main.h @@ -101,6 +101,7 @@ public: int mas_ui_client_change_assistant(const char* appid); int mas_get_current_client_pid(); int mas_get_current_preprocessing_client_pid(); + pid_t mas_get_current_audio_processing_pid(); int mas_get_client_pid_by_wakeup_word(const char *wakeup_word); int mas_get_client_pid_by_appid(const char *appid); std::string mas_get_client_appid_by_pid(int pid); @@ -177,6 +178,8 @@ private: ma_preprocessing_allow_mode_e preprocessing_allow_mode; char preprocessing_allow_appid[MAX_APPID_LEN]; + + boost::optional audio_processing_appid; } ma_client_info; ma_client_info mClientInfo[MAX_MACLIENT_INFO_NUM]; diff --git a/src/application_manager_aul.cpp b/src/application_manager_aul.cpp index 41ae5f2..6b2ca7a 100644 --- a/src/application_manager_aul.cpp +++ b/src/application_manager_aul.cpp @@ -110,3 +110,15 @@ boost::optional CApplicationManagerAul::get_appid_by_pid(pid_t pid) return ret; } + +boost::optional CApplicationManagerAul::get_pid_by_appid(const std::string& appid) +{ + boost::optional ret; + + int pid = aul_app_get_pid(appid.c_str()); + if (pid >= 0) { + ret = pid; + } + + return ret; +} \ No newline at end of file diff --git a/src/service_ipc_dbus.cpp b/src/service_ipc_dbus.cpp index f6fba74..1d176c6 100644 --- a/src/service_ipc_dbus.cpp +++ b/src/service_ipc_dbus.cpp @@ -244,10 +244,14 @@ int CServiceIpcDbus::send_streaming_audio_data(int pid, int event, void* data, u bundle *b = bundle_create(); if (b) { bundle_add_byte(b, "content", pending_buffer, pending_buffer_size); - int ret = message_port_send_message( - mClientManager->find_client_appid_by_pid(pid).c_str(), message_port, b); - if (MESSAGE_PORT_ERROR_NONE != ret) - masc_message_port_error(ret); + boost::optional appid = mApplicationManager->get_appid_by_pid(pid); + if (appid) { + int ret = message_port_send_message((*appid).c_str(), message_port, b); + if (MESSAGE_PORT_ERROR_NONE != ret) + masc_message_port_error(ret); + } else { + MAS_LOGE("AppID for PID %d not found!!!", pid); + } pending_buffer_size = 0; bundle_free(b); @@ -265,10 +269,14 @@ int CServiceIpcDbus::send_streaming_audio_data(int pid, int event, void* data, u bundle *b = bundle_create(); if (b) { bundle_add_byte(b, "content", buffer, total_size); - int ret = message_port_send_message( - mClientManager->find_client_appid_by_pid(pid).c_str(), message_port, b); - if (MESSAGE_PORT_ERROR_NONE != ret) - masc_message_port_error(ret); + boost::optional appid = mApplicationManager->get_appid_by_pid(pid); + if (appid) { + int ret = message_port_send_message((*appid).c_str(), message_port, b); + if (MESSAGE_PORT_ERROR_NONE != ret) + masc_message_port_error(ret); + } else { + MAS_LOGE("AppID for PID %d not found!!!", pid); + } bundle_free(b); } else { diff --git a/src/service_main.cpp b/src/service_main.cpp index 85cee29..ac58436 100644 --- a/src/service_main.cpp +++ b/src/service_main.cpp @@ -700,6 +700,23 @@ int CServiceMain::mas_get_current_preprocessing_client_pid() return ret; } +pid_t CServiceMain::mas_get_current_audio_processing_pid() +{ + pid_t ret = -1; + if (mCurrentClientInfo >= 0 && mCurrentClientInfo < MAX_MACLIENT_INFO_NUM) { + boost::optional audio_processing_appid = + mClientInfo[mCurrentClientInfo].audio_processing_appid; + if (audio_processing_appid) { + boost::optional optional_pid_t; + optional_pid_t = mApplicationManager.get_pid_by_appid((*audio_processing_appid).c_str()); + if (optional_pid_t) { + ret = *optional_pid_t; + } + } + } + return ret; +} + int CServiceMain::mas_get_client_pid_by_appid(const char *appid) { int ret = -1; @@ -1299,6 +1316,7 @@ bool CServiceMain::app_create(void *data) mClientManager.set_application_manager(&mApplicationManager); mServiceIpc.set_client_manager(&mClientManager); + mServiceIpc.set_application_manager(&mApplicationManager); mServiceIpc.set_service_ipc_observer(this); mServicePlugin.set_service_ipc(&mServiceIpc); diff --git a/src/service_plugin.cpp b/src/service_plugin.cpp index f12323e..64dd796 100644 --- a/src/service_plugin.cpp +++ b/src/service_plugin.cpp @@ -352,7 +352,11 @@ static void __audio_streaming_cb(mas_speech_streaming_event_e event, void* buffe } if (service_ipc && service_main) { - int pid = service_main->mas_get_current_client_pid(); + /* First check if we have dedicated audio processing app for current client */ + pid_t pid = service_main->mas_get_current_audio_processing_pid(); + /* If not, send audio data to the main client */ + if (-1 == pid) pid = service_main->mas_get_current_client_pid(); + int preprocessing_pid = service_main->mas_get_current_preprocessing_client_pid(); if (pid == -1) { MAS_LOGE("[ERROR] Fail to retrieve pid of current MA client"); diff --git a/tests/utc/client-manager/test_client_manager.cpp b/tests/utc/client-manager/test_client_manager.cpp index 7db0af8..73f9cbe 100644 --- a/tests/utc/client-manager/test_client_manager.cpp +++ b/tests/utc/client-manager/test_client_manager.cpp @@ -31,6 +31,7 @@ public: bool bring_app_to_foreground(const std::string& appid) override { return true; } bool launch_app_async(const std::string& appid, bool background) override { return true; } boost::optional get_appid_by_pid(pid_t pid) override { return boost::optional{}; } + boost::optional get_pid_by_appid(const std::string& appid) override { return boost::optional{-1}; }; }; class StorageWithNoClient : public testing::Test diff --git a/tests/utc/service-main/test_service_main.cpp b/tests/utc/service-main/test_service_main.cpp index b14cf72..6d8f175 100644 --- a/tests/utc/service-main/test_service_main.cpp +++ b/tests/utc/service-main/test_service_main.cpp @@ -42,6 +42,7 @@ public: return true; } boost::optional get_appid_by_pid(pid_t pid) override { return boost::optional{}; } + boost::optional get_pid_by_appid(const std::string& appid) override { return boost::optional{-1}; }; public: boost::optional launched_appid; boost::optional launched_option_background; -- 2.7.4 From 1deff787f0914637eab3b38efebb39728b4db9b1 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Mon, 13 Apr 2020 21:52:19 +0900 Subject: [PATCH 02/16] Replace int with pid_t for representing a process ID Change-Id: I9dc8f8fb5204b1591e67cc0fa65c27a379e2f234 --- inc/client_manager.h | 14 ++-- inc/service_ipc_dbus.h | 24 +++--- inc/service_ipc_dbus_dispatcher.h | 40 +++++----- inc/service_main.h | 90 +++++++++++----------- src/application_manager_aul.cpp | 2 +- src/client_manager.cpp | 18 ++--- src/service_ipc_dbus.cpp | 24 +++--- src/service_ipc_dbus_dispatcher.cpp | 40 +++++----- src/service_main.cpp | 98 ++++++++++++------------ src/service_plugin.cpp | 10 +-- tests/utc/client-manager/test_client_manager.cpp | 34 ++++---- 11 files changed, 197 insertions(+), 197 deletions(-) diff --git a/inc/client_manager.h b/inc/client_manager.h index b174b14..0ecad4e 100644 --- a/inc/client_manager.h +++ b/inc/client_manager.h @@ -28,7 +28,7 @@ extern "C" { #endif typedef struct { - int pid; + pid_t pid; std::string appid; } ma_client_s; @@ -38,20 +38,20 @@ public: virtual ~CClientManager() {} int set_application_manager(IApplicationManager* manager); - int create_client(int pid, std::string appid); - int destroy_client_by_pid(int pid); + int create_client(pid_t pid, std::string appid); + int destroy_client_by_pid(pid_t pid); int destroy_client_by_appid(std::string appid); int get_client_num(); - int find_client_pid_by_index(unsigned int index); + pid_t find_client_pid_by_index(unsigned int index); - int find_client_pid_by_appid(std::string appid); - std::string find_client_appid_by_pid(int pid); + pid_t find_client_pid_by_appid(std::string appid); + std::string find_client_appid_by_pid(pid_t pid); bool check_client_validity_by_appid(std::string appid); private: ma_client_s* find_client_by_appid(std::string appid); - ma_client_s* find_client_by_pid(int pid); + ma_client_s* find_client_by_pid(pid_t pid); ma_client_s* get_client_by_index(unsigned int index); int destroy_client(ma_client_s* client); diff --git a/inc/service_ipc_dbus.h b/inc/service_ipc_dbus.h index b462aec..abe1990 100644 --- a/inc/service_ipc_dbus.h +++ b/inc/service_ipc_dbus.h @@ -35,22 +35,22 @@ public: int open_connection(); int close_connection(); - int send_hello(int pid); + int send_hello(pid_t pid); int send_error_message(int reason, const char* err_msg); - int send_streaming_audio_data(int pid, int event, void* data, unsigned int data_size); - int change_active_state(int pid, int state); - int send_preprocessing_information(int pid, const char* app_id); - int send_streaming_section_changed(int pid, int section); - int send_preprocessing_result(int pid, bool result); - int send_wakeup_engine_command(int pid, const char* command); - int change_service_state(int pid, int state); - int change_voice_key_status(int pid, int status); + int send_streaming_audio_data(pid_t pid, int event, void* data, unsigned int data_size); + int change_active_state(pid_t pid, int state); + int send_preprocessing_information(pid_t pid, const char* app_id); + int send_streaming_section_changed(pid_t pid, int section); + int send_preprocessing_result(pid_t pid, bool result); + int send_wakeup_engine_command(pid_t pid, const char* command); + int change_service_state(pid_t pid, int state); + int change_voice_key_status(pid_t pid, int status); int masc_ui_dbus_send_hello(void); - int masc_ui_dbus_send_asr_result(int pid, int event, const char* asr_result); - int masc_ui_dbus_send_result(int pid, const char* display_text, const char* utterance_text, const char* result_json); + int masc_ui_dbus_send_asr_result(pid_t pid, int event, const char* asr_result); + int masc_ui_dbus_send_result(pid_t pid, const char* display_text, const char* utterance_text, const char* result_json); int masc_ui_dbus_change_assistant(const char* app_id); int masc_ui_dbus_send_error_message(int reason, const char* err_msg); - int masc_ui_dbus_send_recognition_result(int pid, int result); + int masc_ui_dbus_send_recognition_result(pid_t pid, int result); int masc_ui_dbus_enable_common_ui(int enable); DBusConnection* get_connection_listener() { return mConnectionListener; } diff --git a/inc/service_ipc_dbus_dispatcher.h b/inc/service_ipc_dbus_dispatcher.h index ae36c70..9a88a99 100644 --- a/inc/service_ipc_dbus_dispatcher.h +++ b/inc/service_ipc_dbus_dispatcher.h @@ -29,28 +29,28 @@ class CServiceMain; class IServiceIpcObserver { public: - virtual int on_initialize(int pid) = 0; - virtual int on_deinitialize(int pid) = 0; - virtual int on_get_audio_format(int pid, int& rate, int& channel, int& audio_type) = 0; - virtual int on_get_audio_source_type(int pid, std::string& type) = 0; - virtual int on_send_asr_result(int pid, int event, std::string asr_result) = 0; - virtual int on_send_result(int pid, + virtual int on_initialize(pid_t pid) = 0; + virtual int on_deinitialize(pid_t pid) = 0; + virtual int on_get_audio_format(pid_t pid, int& rate, int& channel, int& audio_type) = 0; + virtual int on_get_audio_source_type(pid_t pid, std::string& type) = 0; + virtual int on_send_asr_result(pid_t pid, int event, std::string asr_result) = 0; + virtual int on_send_result(pid_t pid, std::string display_text, std::string utterance_text, std::string result_json) = 0; - virtual int on_send_recognition_result(int pid, int result) = 0; - virtual int on_start_streaming_audio_data(int pid, int type) = 0; - virtual int on_stop_streaming_audio_data(int pid, int type) = 0; - virtual int on_update_voice_feedback_state(int pid, int state) = 0; - virtual int on_send_assistant_specific_command(int pid, std::string command) = 0; - virtual int on_set_background_volume(int pid, double ratio) = 0; - virtual int on_set_preprocessing_allow_mode(int pid, int mode, std::string app_id) = 0; - virtual int on_send_preprocessing_result(int pid, int result) = 0; - virtual int on_set_wake_word_audio_require_flag(int pid, int require) = 0; - virtual int on_set_assistant_language(int pid, std::string language) = 0; - virtual int on_add_wake_word(int pid, std::string wake_word, std::string language) = 0; - virtual int on_remove_wake_word(int pid, std::string wake_word, std::string language) = 0; + virtual int on_send_recognition_result(pid_t pid, int result) = 0; + virtual int on_start_streaming_audio_data(pid_t pid, int type) = 0; + virtual int on_stop_streaming_audio_data(pid_t pid, int type) = 0; + virtual int on_update_voice_feedback_state(pid_t pid, int state) = 0; + virtual int on_send_assistant_specific_command(pid_t pid, std::string command) = 0; + virtual int on_set_background_volume(pid_t pid, double ratio) = 0; + virtual int on_set_preprocessing_allow_mode(pid_t pid, int mode, std::string app_id) = 0; + virtual int on_send_preprocessing_result(pid_t pid, int result) = 0; + virtual int on_set_wake_word_audio_require_flag(pid_t pid, int require) = 0; + virtual int on_set_assistant_language(pid_t pid, std::string language) = 0; + virtual int on_add_wake_word(pid_t pid, std::string wake_word, std::string language) = 0; + virtual int on_remove_wake_word(pid_t pid, std::string wake_word, std::string language) = 0; - virtual int on_ui_initialize(int pid) = 0; - virtual int on_ui_deinitialize(int pid) = 0; + virtual int on_ui_initialize(pid_t pid) = 0; + virtual int on_ui_deinitialize(pid_t pid) = 0; virtual int on_ui_change_assistant(std::string app_id) = 0; }; diff --git a/inc/service_main.h b/inc/service_main.h index 6aed620..c33b6c1 100644 --- a/inc/service_main.h +++ b/inc/service_main.h @@ -76,35 +76,35 @@ public: {} virtual ~CServiceMain() {} - int mas_client_get_audio_format(int pid, int* rate, int* channel, int* audio_type); - int mas_client_get_audio_source_type(int pid, char** type); - int mas_client_send_preprocessing_information(int pid); - int mas_client_send_voice_key_status_change(int pid, ma_voice_key_status_e status); - int mas_client_request_speech_data(int pid); - int mas_client_send_asr_result(int pid, int event, const char* asr_result); - int mas_client_send_result(int pid, const char* display_text, + int mas_client_get_audio_format(pid_t pid, int* rate, int* channel, int* audio_type); + int mas_client_get_audio_source_type(pid_t pid, char** type); + int mas_client_send_preprocessing_information(pid_t pid); + int mas_client_send_voice_key_status_change(pid_t pid, ma_voice_key_status_e status); + int mas_client_request_speech_data(pid_t pid); + int mas_client_send_asr_result(pid_t pid, int event, const char* asr_result); + int mas_client_send_result(pid_t pid, const char* display_text, const char* utterance_text, const char* result_json); - int mas_client_send_recognition_result(int pid, int result); - int mas_client_start_streaming_audio_data(int pid, int type); - int mas_client_stop_streaming_audio_data(int pid, int type); - int mas_client_update_voice_feedback_state(int pid, int state); - int mas_client_set_assistant_specific_command(int pid, const char *command); - int mas_client_set_background_volume(int pid, double ratio); - int mas_client_set_preprocessing_allow_mode(int pid, ma_preprocessing_allow_mode_e mode, const char* appid); - int mas_client_send_preprocessing_result(int pid, bool result); - int mas_client_set_wake_word_audio_require_flag(int pid, bool require); - int mas_client_set_assistant_language(int pid, const char* language); - int mas_client_add_wake_word(int pid, const char* wake_word, const char* language); - int mas_client_remove_wake_word(int pid, const char* wake_word, const char* language); - int mas_ui_client_initialize(int pid); - int mas_ui_client_deinitialize(int pid); + int mas_client_send_recognition_result(pid_t pid, int result); + int mas_client_start_streaming_audio_data(pid_t pid, int type); + int mas_client_stop_streaming_audio_data(pid_t pid, int type); + int mas_client_update_voice_feedback_state(pid_t pid, int state); + int mas_client_set_assistant_specific_command(pid_t pid, const char *command); + int mas_client_set_background_volume(pid_t pid, double ratio); + int mas_client_set_preprocessing_allow_mode(pid_t pid, ma_preprocessing_allow_mode_e mode, const char* appid); + int mas_client_send_preprocessing_result(pid_t pid, bool result); + int mas_client_set_wake_word_audio_require_flag(pid_t pid, bool require); + int mas_client_set_assistant_language(pid_t pid, const char* language); + int mas_client_add_wake_word(pid_t pid, const char* wake_word, const char* language); + int mas_client_remove_wake_word(pid_t pid, const char* wake_word, const char* language); + int mas_ui_client_initialize(pid_t pid); + int mas_ui_client_deinitialize(pid_t pid); int mas_ui_client_change_assistant(const char* appid); - int mas_get_current_client_pid(); - int mas_get_current_preprocessing_client_pid(); + pid_t mas_get_current_client_pid(); + pid_t mas_get_current_preprocessing_client_pid(); pid_t mas_get_current_audio_processing_pid(); int mas_get_client_pid_by_wakeup_word(const char *wakeup_word); int mas_get_client_pid_by_appid(const char *appid); - std::string mas_get_client_appid_by_pid(int pid); + std::string mas_get_client_appid_by_pid(pid_t pid); bool mas_get_client_custom_ui_option_by_appid(const char *appid); const char* mas_get_client_appid_by_wakeup_word(const char *wakeup_word); int mas_set_current_client_by_wakeup_word(const char *wakeup_word); @@ -118,28 +118,28 @@ public: int mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT event); int mas_update_voice_key_support_mode(); - virtual int on_initialize(int pid) override; - virtual int on_deinitialize(int pid) override; - virtual int on_get_audio_format(int pid, int& rate, int& channel, int& audio_type) override; - virtual int on_get_audio_source_type(int pid, std::string& type) override; - virtual int on_send_asr_result(int pid, int event, std::string asr_result) override; - virtual int on_send_result(int pid, std::string display_text, + virtual int on_initialize(pid_t pid) override; + virtual int on_deinitialize(pid_t pid) override; + virtual int on_get_audio_format(pid_t pid, int& rate, int& channel, int& audio_type) override; + virtual int on_get_audio_source_type(pid_t pid, std::string& type) override; + virtual int on_send_asr_result(pid_t pid, int event, std::string asr_result) override; + virtual int on_send_result(pid_t pid, std::string display_text, std::string utterance_text, std::string result_json) override; - virtual int on_send_recognition_result(int pid, int result) override; - virtual int on_start_streaming_audio_data(int pid, int type) override; - virtual int on_stop_streaming_audio_data(int pid, int type) override; - virtual int on_update_voice_feedback_state(int pid, int state) override; - virtual int on_send_assistant_specific_command(int pid, std::string command) override; - virtual int on_set_background_volume(int pid, double ratio) override; - virtual int on_set_preprocessing_allow_mode(int pid, int mode, std::string app_id) override; - virtual int on_send_preprocessing_result(int pid, int result) override; - virtual int on_set_wake_word_audio_require_flag(int pid, int require) override; - virtual int on_set_assistant_language(int pid, std::string language) override; - virtual int on_add_wake_word(int pid, std::string wake_word, std::string language) override; - virtual int on_remove_wake_word(int pid, std::string wake_word, std::string language) override; - - virtual int on_ui_initialize(int pid) override; - virtual int on_ui_deinitialize(int pid) override; + virtual int on_send_recognition_result(pid_t pid, int result) override; + virtual int on_start_streaming_audio_data(pid_t pid, int type) override; + virtual int on_stop_streaming_audio_data(pid_t pid, int type) override; + virtual int on_update_voice_feedback_state(pid_t pid, int state) override; + virtual int on_send_assistant_specific_command(pid_t pid, std::string command) override; + virtual int on_set_background_volume(pid_t pid, double ratio) override; + virtual int on_set_preprocessing_allow_mode(pid_t pid, int mode, std::string app_id) override; + virtual int on_send_preprocessing_result(pid_t pid, int result) override; + virtual int on_set_wake_word_audio_require_flag(pid_t pid, int require) override; + virtual int on_set_assistant_language(pid_t pid, std::string language) override; + virtual int on_add_wake_word(pid_t pid, std::string wake_word, std::string language) override; + virtual int on_remove_wake_word(pid_t pid, std::string wake_word, std::string language) override; + + virtual int on_ui_initialize(pid_t pid) override; + virtual int on_ui_deinitialize(pid_t pid) override; virtual int on_ui_change_assistant(std::string app_id) override; bool app_create(void *data); diff --git a/src/application_manager_aul.cpp b/src/application_manager_aul.cpp index 6b2ca7a..00b6ecb 100644 --- a/src/application_manager_aul.cpp +++ b/src/application_manager_aul.cpp @@ -115,7 +115,7 @@ boost::optional CApplicationManagerAul::get_pid_by_appid(const std::strin { boost::optional ret; - int pid = aul_app_get_pid(appid.c_str()); + pid_t pid = aul_app_get_pid(appid.c_str()); if (pid >= 0) { ret = pid; } diff --git a/src/client_manager.cpp b/src/client_manager.cpp index f9cf2f9..01cd9d5 100644 --- a/src/client_manager.cpp +++ b/src/client_manager.cpp @@ -23,7 +23,7 @@ int CClientManager::set_application_manager(IApplicationManager* manager) return 0; } -int CClientManager::create_client(int pid, std::string appid) +int CClientManager::create_client(pid_t pid, std::string appid) { ma_client_s* data = NULL; @@ -60,7 +60,7 @@ int CClientManager::destroy_client(ma_client_s* client) return 0; } -int CClientManager::destroy_client_by_pid(int pid) +int CClientManager::destroy_client_by_pid(pid_t pid) { ma_client_s* client = find_client_by_pid(pid); return destroy_client(client); @@ -94,7 +94,7 @@ ma_client_s* CClientManager::find_client_by_appid(std::string appid) return NULL; } -ma_client_s* CClientManager::find_client_by_pid(int pid) +ma_client_s* CClientManager::find_client_by_pid(pid_t pid) { ma_client_s *data = NULL; @@ -126,9 +126,9 @@ ma_client_s* CClientManager::get_client_by_index(unsigned int index) return static_cast(g_slist_nth_data(mClientList, index)); } -int CClientManager::find_client_pid_by_index(unsigned int index) +pid_t CClientManager::find_client_pid_by_index(unsigned int index) { - int pid = -1; + pid_t pid = -1; ma_client_s* client = get_client_by_index(index); if (client) { pid = client->pid; @@ -136,9 +136,9 @@ int CClientManager::find_client_pid_by_index(unsigned int index) return pid; } -int CClientManager::find_client_pid_by_appid(std::string appid) +pid_t CClientManager::find_client_pid_by_appid(std::string appid) { - int pid = -1; + pid_t pid = -1; if (nullptr == mApplicationManager) { MAS_LOGE("ApplicationManager is NULL, can't check if app is running or not"); @@ -158,7 +158,7 @@ int CClientManager::find_client_pid_by_appid(std::string appid) return pid; } -std::string CClientManager::find_client_appid_by_pid(int pid) +std::string CClientManager::find_client_appid_by_pid(pid_t pid) { std::string appid; @@ -182,7 +182,7 @@ std::string CClientManager::find_client_appid_by_pid(int pid) bool CClientManager::check_client_validity_by_appid(std::string appid) { - int pid = find_client_pid_by_appid(appid); + pid_t pid = find_client_pid_by_appid(appid); if (0 < pid) return true; return false; } diff --git a/src/service_ipc_dbus.cpp b/src/service_ipc_dbus.cpp index 1d176c6..bb1c3fa 100644 --- a/src/service_ipc_dbus.cpp +++ b/src/service_ipc_dbus.cpp @@ -74,7 +74,7 @@ int CServiceIpcDbus::mas_check_dbus_connection() return 0; } -int CServiceIpcDbus::send_hello(int pid) +int CServiceIpcDbus::send_hello(pid_t pid) { if (0 != __dbus_check()) { return -1; //MAS_ERROR_OPERATION_FAILED; @@ -206,7 +206,7 @@ static void masc_message_port_error(int error) "MESSAGE_PORT_ERROR_UNKNOWN"); } -int CServiceIpcDbus::send_streaming_audio_data(int pid, int event, void* data, unsigned int data_size) +int CServiceIpcDbus::send_streaming_audio_data(pid_t pid, int event, void* data, unsigned int data_size) { if (nullptr == mClientManager) { MAS_LOGE("mClientManager variable is NULL"); @@ -289,7 +289,7 @@ int CServiceIpcDbus::send_streaming_audio_data(int pid, int event, void* data, u return 0; } -int CServiceIpcDbus::change_active_state(int pid, int state) +int CServiceIpcDbus::change_active_state(pid_t pid, int state) { if (0 != __dbus_check()) { return -1; //MAS_ERROR_OPERATION_FAILED; @@ -339,7 +339,7 @@ int CServiceIpcDbus::change_active_state(int pid, int state) return 0; } -int CServiceIpcDbus::send_preprocessing_information(int pid, const char* app_id) +int CServiceIpcDbus::send_preprocessing_information(pid_t pid, const char* app_id) { if (0 != __dbus_check()) { return -1; //MAS_ERROR_OPERATION_FAILED; @@ -403,7 +403,7 @@ int CServiceIpcDbus::send_preprocessing_information(int pid, const char* app_id) return 0; } -int CServiceIpcDbus::send_streaming_section_changed(int pid, int section) +int CServiceIpcDbus::send_streaming_section_changed(pid_t pid, int section) { if (nullptr == mClientManager) { MAS_LOGE("mClientManager variable is NULL"); @@ -438,7 +438,7 @@ int CServiceIpcDbus::send_streaming_section_changed(int pid, int section) return 0; } -int CServiceIpcDbus::send_preprocessing_result(int pid, bool result) +int CServiceIpcDbus::send_preprocessing_result(pid_t pid, bool result) { if (0 != __dbus_check()) { return -1; //MAS_ERROR_OPERATION_FAILED; @@ -491,7 +491,7 @@ int CServiceIpcDbus::send_preprocessing_result(int pid, bool result) return 0; } -int CServiceIpcDbus::send_wakeup_engine_command(int pid, const char* command) +int CServiceIpcDbus::send_wakeup_engine_command(pid_t pid, const char* command) { if (0 != __dbus_check()) { return -1; //MAS_ERROR_OPERATION_FAILED; @@ -555,7 +555,7 @@ int CServiceIpcDbus::send_wakeup_engine_command(int pid, const char* command) return 0; } -int CServiceIpcDbus::change_service_state(int pid, int state) +int CServiceIpcDbus::change_service_state(pid_t pid, int state) { if (0 != __dbus_check()) { return -1; //MAS_ERROR_OPERATION_FAILED; @@ -605,7 +605,7 @@ int CServiceIpcDbus::change_service_state(int pid, int state) return 0; } -int CServiceIpcDbus::change_voice_key_status(int pid, int status) +int CServiceIpcDbus::change_voice_key_status(pid_t pid, int status) { if (0 != __dbus_check()) { return -1; //MAS_ERROR_OPERATION_FAILED; @@ -699,7 +699,7 @@ int CServiceIpcDbus::masc_ui_dbus_send_hello(void) return result; } -int CServiceIpcDbus::masc_ui_dbus_send_asr_result(int pid, int event, const char* asr_result) +int CServiceIpcDbus::masc_ui_dbus_send_asr_result(pid_t pid, int event, const char* asr_result) { if (0 != __dbus_check()) { return -1; //MAS_ERROR_OPERATION_FAILED; @@ -753,7 +753,7 @@ int CServiceIpcDbus::masc_ui_dbus_send_asr_result(int pid, int event, const char return 0; } -int CServiceIpcDbus::masc_ui_dbus_send_result(int pid, const char* display_text, const char* utterance_text, const char* result_json) +int CServiceIpcDbus::masc_ui_dbus_send_result(pid_t pid, const char* display_text, const char* utterance_text, const char* result_json) { if (0 != __dbus_check()) { return -1; //MA_ERROR_OPERATION_FAILED; @@ -933,7 +933,7 @@ int CServiceIpcDbus::masc_ui_dbus_send_error_message(int reason, const char* err return 0; } -int CServiceIpcDbus::masc_ui_dbus_send_recognition_result(int pid, int result) +int CServiceIpcDbus::masc_ui_dbus_send_recognition_result(pid_t pid, int result) { if (0 != __dbus_check()) { return -1; //MAS_ERROR_OPERATION_FAILED; diff --git a/src/service_ipc_dbus_dispatcher.cpp b/src/service_ipc_dbus_dispatcher.cpp index 26e7ac1..2e9a044 100644 --- a/src/service_ipc_dbus_dispatcher.cpp +++ b/src/service_ipc_dbus_dispatcher.cpp @@ -54,7 +54,7 @@ int CServiceIpcDbusDispatcher::on_initialize(DBusConnection* conn, DBusMessage* DBusError err; dbus_error_init(&err); - int pid = -1; + pid_t pid = -1; int ret = 0; dbus_message_get_args(msg, &err, @@ -110,7 +110,7 @@ int CServiceIpcDbusDispatcher::on_deinitialize(DBusConnection* conn, DBusMessage DBusError err; dbus_error_init(&err); - int pid = -1; + pid_t pid = -1; int ret = 0; dbus_message_get_args(msg, &err, @@ -166,7 +166,7 @@ int CServiceIpcDbusDispatcher::on_get_audio_format(DBusConnection* conn, DBusMes DBusError err; dbus_error_init(&err); - int pid = -1; + pid_t pid = -1; int rate, channel, audio_type; int ret; @@ -225,7 +225,7 @@ int CServiceIpcDbusDispatcher::on_get_audio_source_type(DBusConnection* conn, DB DBusError err; dbus_error_init(&err); - int pid = -1; + pid_t pid = -1; std::string type; int ret; @@ -292,7 +292,7 @@ int CServiceIpcDbusDispatcher::on_send_asr_result(DBusConnection* conn, DBusMess DBusError err; dbus_error_init(&err); - int pid, event; + pid_t pid, event; char *asr_result; int ret = 0; @@ -354,7 +354,7 @@ int CServiceIpcDbusDispatcher::on_send_result(DBusConnection* conn, DBusMessage* DBusError err; dbus_error_init(&err); - int pid; + pid_t pid; char* display_text; char* utterance_text; char* result_json; @@ -421,7 +421,7 @@ int CServiceIpcDbusDispatcher::on_send_recognition_result(DBusConnection* conn, DBusError err; dbus_error_init(&err); - int pid; + pid_t pid; int result; int ret = 0; @@ -457,7 +457,7 @@ int CServiceIpcDbusDispatcher::on_start_streaming_audio_data(DBusConnection* con DBusError err; dbus_error_init(&err); - int pid; + pid_t pid; int type; int ret = 0; @@ -493,7 +493,7 @@ int CServiceIpcDbusDispatcher::on_stop_streaming_audio_data(DBusConnection* conn DBusError err; dbus_error_init(&err); - int pid; + pid_t pid; int type; int ret = 0; @@ -529,7 +529,7 @@ int CServiceIpcDbusDispatcher::on_update_voice_feedback_state(DBusConnection* co DBusError err; dbus_error_init(&err); - int pid; + pid_t pid; int state; int ret = 0; @@ -565,7 +565,7 @@ int CServiceIpcDbusDispatcher::on_send_assistant_specific_command(DBusConnection DBusError err; dbus_error_init(&err); - int pid; + pid_t pid; int ret = 0; char* command; @@ -602,7 +602,7 @@ int CServiceIpcDbusDispatcher::on_set_background_volume(DBusConnection* conn, DB DBusError err; dbus_error_init(&err); - int pid; + pid_t pid; int ret = 0; double ratio; @@ -638,7 +638,7 @@ int CServiceIpcDbusDispatcher::on_set_preprocessing_allow_mode(DBusConnection* c DBusError err; dbus_error_init(&err); - int pid; + pid_t pid; int ret = 0; int mode; char* app_id; @@ -678,7 +678,7 @@ int CServiceIpcDbusDispatcher::on_send_preprocessing_result(DBusConnection* conn DBusError err; dbus_error_init(&err); - int pid; + pid_t pid; int ret = 0; int result; @@ -714,7 +714,7 @@ int CServiceIpcDbusDispatcher::on_set_wake_word_audio_require_flag(DBusConnectio DBusError err; dbus_error_init(&err); - int pid; + pid_t pid; int ret = 0; int require; @@ -750,7 +750,7 @@ int CServiceIpcDbusDispatcher::on_set_assistant_language(DBusConnection* conn, D DBusError err; dbus_error_init(&err); - int pid; + pid_t pid; int ret = 0; char* language; @@ -787,7 +787,7 @@ int CServiceIpcDbusDispatcher::on_add_wake_word(DBusConnection* conn, DBusMessag DBusError err; dbus_error_init(&err); - int pid; + pid_t pid; int ret = 0; char* wake_word; char* language; @@ -826,7 +826,7 @@ int CServiceIpcDbusDispatcher::on_remove_wake_word(DBusConnection* conn, DBusMes DBusError err; dbus_error_init(&err); - int pid; + pid_t pid; int ret = 0; char* wake_word; char* language; @@ -866,7 +866,7 @@ int CServiceIpcDbusDispatcher::on_ui_initialize(DBusConnection* conn, DBusMessag DBusError err; dbus_error_init(&err); - int pid = -1; + pid_t pid = -1; int ret = 0; dbus_message_get_args(msg, &err, @@ -922,7 +922,7 @@ int CServiceIpcDbusDispatcher::on_ui_deinitialize(DBusConnection* conn, DBusMess DBusError err; dbus_error_init(&err); - int pid = -1; + pid_t pid = -1; int ret = 0; dbus_message_get_args(msg, &err, diff --git a/src/service_main.cpp b/src/service_main.cpp index ac58436..424b653 100644 --- a/src/service_main.cpp +++ b/src/service_main.cpp @@ -74,7 +74,7 @@ bool CServiceMain::is_current_preprocessing_assistant(const char* appid) return ret; } -int CServiceMain::mas_client_get_audio_format(int pid, int* rate, int* channel, int* audio_type) +int CServiceMain::mas_client_get_audio_format(pid_t pid, int* rate, int* channel, int* audio_type) { MAS_LOGD("[Enter] pid(%d)", pid); @@ -87,7 +87,7 @@ int CServiceMain::mas_client_get_audio_format(int pid, int* rate, int* channel, } #define MAX_LOCAL_VARIABLE_STRING_LEN 256 -int CServiceMain::mas_client_get_audio_source_type(int pid, char** type) +int CServiceMain::mas_client_get_audio_source_type(pid_t pid, char** type) { MAS_LOGD("[Enter] pid(%d)", pid); @@ -106,7 +106,7 @@ int CServiceMain::mas_client_get_audio_source_type(int pid, char** type) return ret; } -int CServiceMain::mas_client_send_preprocessing_information(int pid) +int CServiceMain::mas_client_send_preprocessing_information(pid_t pid) { int ret = -1; MAS_LOGD("[Enter] pid(%d)", pid); @@ -121,7 +121,7 @@ int CServiceMain::mas_client_send_preprocessing_information(int pid) return ret; } -int CServiceMain::mas_client_send_voice_key_status_change(int pid, ma_voice_key_status_e status) +int CServiceMain::mas_client_send_voice_key_status_change(pid_t pid, ma_voice_key_status_e status) { int ret = -1; MAS_LOGD("[Enter] pid(%d)", pid); @@ -135,7 +135,7 @@ int CServiceMain::mas_client_send_voice_key_status_change(int pid, ma_voice_key_ return ret; } -int CServiceMain::mas_client_send_asr_result(int pid, int event, const char* asr_result) +int CServiceMain::mas_client_send_asr_result(pid_t pid, int event, const char* asr_result) { MAS_LOGD("[Enter] pid(%d), event(%d), asr_result(%s)", pid, event, asr_result); int ret = mServiceIpc.masc_ui_dbus_send_asr_result(pid, event, asr_result); @@ -148,7 +148,7 @@ int CServiceMain::mas_client_send_asr_result(int pid, int event, const char* asr return ret; } -int CServiceMain::mas_client_send_result(int pid, const char* display_text, +int CServiceMain::mas_client_send_result(pid_t pid, const char* display_text, const char* utterance_text, const char* result_json) { MAS_LOGD("[Enter] pid(%d), display_text(%s), utterance_text(%s), result_json(%s)", pid, display_text, utterance_text, result_json); @@ -167,7 +167,7 @@ int CServiceMain::mas_client_send_result(int pid, const char* display_text, return ret; } -int CServiceMain::mas_client_send_recognition_result(int pid, int result) +int CServiceMain::mas_client_send_recognition_result(pid_t pid, int result) { MAS_LOGD("[Enter] pid(%d), result(%d)", pid, result); int ret = mServiceIpc.masc_ui_dbus_send_recognition_result(pid, result); @@ -185,7 +185,7 @@ int CServiceMain::mas_client_send_recognition_result(int pid, int result) return ret; } -int CServiceMain::mas_client_start_streaming_audio_data(int pid, int type) +int CServiceMain::mas_client_start_streaming_audio_data(pid_t pid, int type) { int ret = -1; switch(type) { @@ -205,7 +205,7 @@ int CServiceMain::mas_client_start_streaming_audio_data(int pid, int type) return ret; } -int CServiceMain::mas_client_stop_streaming_audio_data(int pid, int type) +int CServiceMain::mas_client_stop_streaming_audio_data(pid_t pid, int type) { int ret = -1; switch(type) { @@ -222,7 +222,7 @@ int CServiceMain::mas_client_stop_streaming_audio_data(int pid, int type) return ret; } -int CServiceMain::mas_client_update_voice_feedback_state(int pid, int state) +int CServiceMain::mas_client_update_voice_feedback_state(pid_t pid, int state) { std::string pid_appid; boost::optional appid_by_pid = mApplicationManager.get_appid_by_pid(pid); @@ -233,7 +233,7 @@ int CServiceMain::mas_client_update_voice_feedback_state(int pid, int state) return 0; } -int CServiceMain::mas_client_set_assistant_specific_command(int pid, const char *command) +int CServiceMain::mas_client_set_assistant_specific_command(pid_t pid, const char *command) { std::string pid_appid; boost::optional appid_by_pid = mApplicationManager.get_appid_by_pid(pid); @@ -244,7 +244,7 @@ int CServiceMain::mas_client_set_assistant_specific_command(int pid, const char return 0; } -int CServiceMain::mas_client_set_background_volume(int pid, double ratio) +int CServiceMain::mas_client_set_background_volume(pid_t pid, double ratio) { std::string pid_appid; boost::optional appid_by_pid = mApplicationManager.get_appid_by_pid(pid); @@ -255,7 +255,7 @@ int CServiceMain::mas_client_set_background_volume(int pid, double ratio) return 0; } -int CServiceMain::mas_client_set_preprocessing_allow_mode(int pid, ma_preprocessing_allow_mode_e mode, const char* appid) +int CServiceMain::mas_client_set_preprocessing_allow_mode(pid_t pid, ma_preprocessing_allow_mode_e mode, const char* appid) { std::string pid_appid; boost::optional appid_by_pid = mApplicationManager.get_appid_by_pid(pid); @@ -282,7 +282,7 @@ int CServiceMain::mas_client_set_preprocessing_allow_mode(int pid, ma_preprocess return 0; } -int CServiceMain::mas_client_send_preprocessing_result(int pid, bool result) +int CServiceMain::mas_client_send_preprocessing_result(pid_t pid, bool result) { std::string pid_appid; boost::optional appid_by_pid = mApplicationManager.get_appid_by_pid(pid); @@ -305,7 +305,7 @@ int CServiceMain::mas_client_send_preprocessing_result(int pid, bool result) } if (current_maclient_appid) { - int pid_by_appid = mClientManager.find_client_pid_by_appid( + pid_t pid_by_appid = mClientManager.find_client_pid_by_appid( std::string{current_maclient_appid}); mServiceIpc.send_preprocessing_result(pid_by_appid, result); } @@ -313,7 +313,7 @@ int CServiceMain::mas_client_send_preprocessing_result(int pid, bool result) return 0; } -int CServiceMain::mas_client_set_wake_word_audio_require_flag(int pid, bool require) +int CServiceMain::mas_client_set_wake_word_audio_require_flag(pid_t pid, bool require) { std::string pid_appid; boost::optional appid_by_pid = mApplicationManager.get_appid_by_pid(pid); @@ -325,7 +325,7 @@ int CServiceMain::mas_client_set_wake_word_audio_require_flag(int pid, bool requ return 0; } -int CServiceMain::mas_client_set_assistant_language(int pid, const char* language) +int CServiceMain::mas_client_set_assistant_language(pid_t pid, const char* language) { std::string pid_appid; boost::optional appid_by_pid = mApplicationManager.get_appid_by_pid(pid); @@ -337,7 +337,7 @@ int CServiceMain::mas_client_set_assistant_language(int pid, const char* languag return 0; } -int CServiceMain::mas_client_add_wake_word(int pid, const char* wake_word, const char* language) +int CServiceMain::mas_client_add_wake_word(pid_t pid, const char* wake_word, const char* language) { std::string pid_appid; boost::optional appid_by_pid = mApplicationManager.get_appid_by_pid(pid); @@ -366,7 +366,7 @@ int CServiceMain::mas_client_add_wake_word(int pid, const char* wake_word, const return 0; } -int CServiceMain::mas_client_remove_wake_word(int pid, const char* wake_word, const char* language) +int CServiceMain::mas_client_remove_wake_word(pid_t pid, const char* wake_word, const char* language) { std::string pid_appid; boost::optional appid_by_pid = mApplicationManager.get_appid_by_pid(pid); @@ -392,14 +392,14 @@ int CServiceMain::mas_client_remove_wake_word(int pid, const char* wake_word, co return 0; } -int CServiceMain::mas_ui_client_initialize(int pid) +int CServiceMain::mas_ui_client_initialize(pid_t pid) { MAS_LOGD("[Enter] pid(%d)", pid); return 0; } -int CServiceMain::mas_ui_client_deinitialize(int pid) +int CServiceMain::mas_ui_client_deinitialize(pid_t pid) { MAS_LOGD("[Enter] pid(%d)", pid); @@ -419,7 +419,7 @@ int CServiceMain::mas_ui_client_change_assistant(const char* appid) mServiceIpc.masc_ui_dbus_enable_common_ui(!use_custom_ui); mas_set_current_client_by_appid(appid); - int pid = mas_get_client_pid_by_appid(appid); + pid_t pid = mas_get_client_pid_by_appid(appid); if (pid != -1) { mas_bring_client_to_foreground(appid); mas_client_send_preprocessing_information(pid); @@ -688,9 +688,9 @@ int CServiceMain::mas_get_current_client_pid() return ret; } -int CServiceMain::mas_get_current_preprocessing_client_pid() +pid_t CServiceMain::mas_get_current_preprocessing_client_pid() { - int ret = -1; + pid_t ret = -1; if (mCurrentPreprocessingClientInfo >= 0 && mCurrentPreprocessingClientInfo < MAX_MACLIENT_INFO_NUM) { const char *appid = mClientInfo[mCurrentPreprocessingClientInfo].appid; if (appid) { @@ -717,9 +717,9 @@ pid_t CServiceMain::mas_get_current_audio_processing_pid() return ret; } -int CServiceMain::mas_get_client_pid_by_appid(const char *appid) +pid_t CServiceMain::mas_get_client_pid_by_appid(const char *appid) { - int ret = -1; + pid_t ret = -1; if (appid) { ret = mClientManager.find_client_pid_by_appid(std::string{appid}); @@ -846,7 +846,7 @@ int CServiceMain::mas_set_current_client_by_wakeup_word(const char *wakeup_word) if (mCurrentClientInfo != prev_selection) { if (prev_selection >= 0 && prev_selection < MAX_MACLIENT_INFO_NUM) { - int pid = mas_get_client_pid_by_appid(mClientInfo[prev_selection].appid); + pid_t pid = mas_get_client_pid_by_appid(mClientInfo[prev_selection].appid); mServiceIpc.change_active_state(pid, MA_ACTIVE_STATE_INACTIVE); } } @@ -872,7 +872,7 @@ int CServiceMain::mas_set_current_client_by_appid(const char *appid) if (mCurrentClientInfo != prev_selection) { if (prev_selection >= 0 && prev_selection < MAX_MACLIENT_INFO_NUM) { - int pid = mas_get_client_pid_by_appid(mClientInfo[prev_selection].appid); + pid_t pid = mas_get_client_pid_by_appid(mClientInfo[prev_selection].appid); mServiceIpc.change_active_state(pid, MA_ACTIVE_STATE_INACTIVE); } } @@ -1117,7 +1117,7 @@ int CServiceMain::mas_set_current_service_state(ma_service_state_e state) int i; for (i = 0; i < count; i++) { - int pid = mClientManager.find_client_pid_by_index(i); + pid_t pid = mClientManager.find_client_pid_by_index(i); if (-1 != pid) { int ret = mServiceIpc.change_service_state(pid, state); @@ -1384,7 +1384,7 @@ void CServiceMain::app_terminate(void *data) return; } -int CServiceMain::on_initialize(int pid) { +int CServiceMain::on_initialize(pid_t pid) { MAS_LOGD("[Enter] pid(%d)", pid); std::string pid_appid; @@ -1433,13 +1433,13 @@ int CServiceMain::on_initialize(int pid) { return 0; } -int CServiceMain::on_deinitialize(int pid) { +int CServiceMain::on_deinitialize(pid_t pid) { MAS_LOGD("[Enter] pid(%d)", pid); mClientManager.destroy_client_by_pid(pid); return 0; } -int CServiceMain::on_get_audio_format(int pid, int& rate, int& channel, int& audio_type) { +int CServiceMain::on_get_audio_format(pid_t pid, int& rate, int& channel, int& audio_type) { int main_rate, main_channel, main_audio_type; int ret = mas_client_get_audio_format(pid, &main_rate, &main_channel, &main_audio_type); @@ -1449,7 +1449,7 @@ int CServiceMain::on_get_audio_format(int pid, int& rate, int& channel, int& aud return ret; } -int CServiceMain::on_get_audio_source_type(int pid, std::string& type) { +int CServiceMain::on_get_audio_source_type(pid_t pid, std::string& type) { char *main_type = nullptr; int ret = mas_client_get_audio_source_type(pid, &main_type); if (0 == ret && main_type) { @@ -1458,71 +1458,71 @@ int CServiceMain::on_get_audio_source_type(int pid, std::string& type) { return ret; } -int CServiceMain::on_send_asr_result(int pid, int event, std::string asr_result) { +int CServiceMain::on_send_asr_result(pid_t pid, int event, std::string asr_result) { return mas_client_send_asr_result(pid, event, asr_result.c_str()); } -int CServiceMain::on_send_result(int pid, std::string display_text, +int CServiceMain::on_send_result(pid_t pid, std::string display_text, std::string utterance_text, std::string result_json) { return mas_client_send_result(pid, display_text.c_str(), utterance_text.c_str(), result_json.c_str()); } -int CServiceMain::on_send_recognition_result(int pid, int result) { +int CServiceMain::on_send_recognition_result(pid_t pid, int result) { return mas_client_send_recognition_result(pid, result); } -int CServiceMain::on_start_streaming_audio_data(int pid, int type) { +int CServiceMain::on_start_streaming_audio_data(pid_t pid, int type) { return mas_client_start_streaming_audio_data(pid, type); } -int CServiceMain::on_stop_streaming_audio_data(int pid, int type) { +int CServiceMain::on_stop_streaming_audio_data(pid_t pid, int type) { return mas_client_stop_streaming_audio_data(pid, type); } -int CServiceMain::on_update_voice_feedback_state(int pid, int state) { +int CServiceMain::on_update_voice_feedback_state(pid_t pid, int state) { return mas_client_update_voice_feedback_state(pid, state); } -int CServiceMain::on_send_assistant_specific_command(int pid, std::string command) { +int CServiceMain::on_send_assistant_specific_command(pid_t pid, std::string command) { return mas_client_set_assistant_specific_command(pid, command.c_str()); } -int CServiceMain::on_set_background_volume(int pid, double ratio) { +int CServiceMain::on_set_background_volume(pid_t pid, double ratio) { return mas_client_set_background_volume(pid, ratio); } -int CServiceMain::on_set_preprocessing_allow_mode(int pid, int mode, std::string app_id) { +int CServiceMain::on_set_preprocessing_allow_mode(pid_t pid, int mode, std::string app_id) { return mas_client_set_preprocessing_allow_mode(pid, static_cast(mode), app_id.c_str()); } -int CServiceMain::on_send_preprocessing_result(int pid, int result) { +int CServiceMain::on_send_preprocessing_result(pid_t pid, int result) { return mas_client_send_preprocessing_result(pid, result); } -int CServiceMain::on_set_wake_word_audio_require_flag(int pid, int require) { +int CServiceMain::on_set_wake_word_audio_require_flag(pid_t pid, int require) { return mas_client_set_wake_word_audio_require_flag(pid, require); } -int CServiceMain::on_set_assistant_language(int pid, std::string language) { +int CServiceMain::on_set_assistant_language(pid_t pid, std::string language) { return mas_client_set_assistant_language(pid, language.c_str()); } -int CServiceMain::on_add_wake_word(int pid, std::string wake_word, std::string language) { +int CServiceMain::on_add_wake_word(pid_t pid, std::string wake_word, std::string language) { return mas_client_add_wake_word(pid, wake_word.c_str(), language.c_str()); } -int CServiceMain::on_remove_wake_word(int pid, std::string wake_word, std::string language) { +int CServiceMain::on_remove_wake_word(pid_t pid, std::string wake_word, std::string language) { return mas_client_remove_wake_word(pid, wake_word.c_str(), language.c_str()); } -int CServiceMain::on_ui_initialize(int pid) +int CServiceMain::on_ui_initialize(pid_t pid) { return mas_ui_client_initialize(pid); } -int CServiceMain::on_ui_deinitialize(int pid) +int CServiceMain::on_ui_deinitialize(pid_t pid) { return mas_ui_client_deinitialize(pid); } diff --git a/src/service_plugin.cpp b/src/service_plugin.cpp index 64dd796..339cf79 100644 --- a/src/service_plugin.cpp +++ b/src/service_plugin.cpp @@ -92,7 +92,7 @@ static Eina_Bool process_wakeup_event_by_appid_timer(void* data) char* appid = static_cast(param->data); MAS_LOGD("[ENTER] appid(%s)", appid); - int pid = -1; + pid_t pid = -1; if (!appid) return ECORE_CALLBACK_CANCEL; CServicePlugin* plugin = param->plugin; @@ -262,7 +262,7 @@ static void __wakeup_event_cb(mas_wakeup_event_info wakeup_info, void* user_data } } -static bool __validate_streaming_event_order(int pid, mas_speech_streaming_event_e *event) +static bool __validate_streaming_event_order(pid_t pid, mas_speech_streaming_event_e *event) { bool ret = false; @@ -437,7 +437,7 @@ static void __streaming_section_changed_cb(ma_audio_streaming_data_section_e sec CServiceIpcDbus *service_ipc = plugin->get_service_ipc(); CServiceMain* service_main = plugin->get_service_main(); if (service_ipc && service_main) { - int pid = service_main->mas_get_current_client_pid(); + pid_t pid = service_main->mas_get_current_client_pid(); int ret = service_ipc->send_streaming_section_changed(pid, (int)section); if (0 != ret) { MAS_LOGE("[ERROR] Fail to send streaming section changed information, ret(%d)", ret); @@ -455,7 +455,7 @@ static void __wakeup_engine_command_cb(mas_wakeup_engine_command_target_e target CServiceIpcDbus *service_ipc = plugin->get_service_ipc(); CServiceMain* service_main = plugin->get_service_main(); if (service_ipc && service_main) { - int pid = service_main->mas_get_client_pid_by_appid(assistant_name); + pid_t pid = service_main->mas_get_client_pid_by_appid(assistant_name); if (-1 != pid) { int ret = service_ipc->send_wakeup_engine_command(pid, command); if (0 != ret) { @@ -488,7 +488,7 @@ static void __wakeup_service_voice_key_status_changed_cb(ma_voice_key_status_e s CServiceIpcDbus *service_ipc = plugin->get_service_ipc(); CServiceMain* service_main = plugin->get_service_main(); if (service_ipc && service_main) { - int pid = service_main->mas_get_current_client_pid(); + pid_t pid = service_main->mas_get_current_client_pid(); int ret = service_ipc->change_voice_key_status(pid, status); if (0 != ret) { MAS_LOGE("[ERROR] Fail to send voice key status changed information, ret(%d)", ret); diff --git a/tests/utc/client-manager/test_client_manager.cpp b/tests/utc/client-manager/test_client_manager.cpp index 73f9cbe..1900dcc 100644 --- a/tests/utc/client-manager/test_client_manager.cpp +++ b/tests/utc/client-manager/test_client_manager.cpp @@ -52,7 +52,7 @@ public: TEST_F(StorageWithNoClient, HasOneClientAfterCreate) { const std::string arbitrary_client_appid{"Client1"}; - const int arbitrary_client_pid{1}; + const pid_t arbitrary_client_pid{1}; client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid); @@ -63,7 +63,7 @@ TEST_F(StorageWithNoClient, HasOneClientAfterCreate) { TEST_F(StorageWithNoClient, ValidityReturnsTrueForCreatedClient) { const std::string arbitrary_client_appid{"Client1"}; - const int arbitrary_client_pid{1}; + const pid_t arbitrary_client_pid{1}; client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid); @@ -74,7 +74,7 @@ TEST_F(StorageWithNoClient, ValidityReturnsTrueForCreatedClient) { TEST_F(StorageWithNoClient, ValidityReturnsFalseForNotCreatedClient) { const std::string arbitrary_client_appid{"Client1"}; - const int arbitrary_client_pid{1}; + const pid_t arbitrary_client_pid{1}; const std::string noexist_client_appid{"Client987654321"}; @@ -98,82 +98,82 @@ public: void TearDown() override { } const std::string preloaded_client_appid_1{"Client1"}; - const int preloaded_client_pid_1{1}; + const pid_t preloaded_client_pid_1{1}; CClientManager client_manager; CDummyApplicationManager application_manager; }; TEST_F(StorageWithOneClient, ReturnsExistingPIDByIndex) { const std::string arbitrary_client_appid{"Client2"}; - const int arbitrary_client_pid{2}; + const pid_t arbitrary_client_pid{2}; client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid); - int pid = client_manager.find_client_pid_by_index(0); + pid_t pid = client_manager.find_client_pid_by_index(0); ASSERT_EQ(pid, preloaded_client_pid_1); } TEST_F(StorageWithOneClient, ReturnsCreatedPIDByIndex) { const std::string arbitrary_client_appid{"Client2"}; - const int arbitrary_client_pid{2}; + const pid_t arbitrary_client_pid{2}; client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid); - int pid = client_manager.find_client_pid_by_index(1); + pid_t pid = client_manager.find_client_pid_by_index(1); ASSERT_EQ(pid, arbitrary_client_pid); } TEST_F(StorageWithOneClient, PreservesExistingItemNotRequestedForRemoval) { const std::string arbitrary_client_appid{"Client2"}; - const int arbitrary_client_pid{2}; + const pid_t arbitrary_client_pid{2}; client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid); client_manager.destroy_client_by_pid(arbitrary_client_pid); - int pid = client_manager.find_client_pid_by_index(0); + pid_t pid = client_manager.find_client_pid_by_index(0); ASSERT_EQ(pid, preloaded_client_pid_1); } TEST_F(StorageWithOneClient, PreservesCreatedItemNotRequestedForRemoval) { const std::string arbitrary_client_appid{"Client2"}; - const int arbitrary_client_pid{2}; + const pid_t arbitrary_client_pid{2}; client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid); client_manager.destroy_client_by_pid(preloaded_client_pid_1); - int pid = client_manager.find_client_pid_by_index(0); + pid_t pid = client_manager.find_client_pid_by_index(0); ASSERT_EQ(pid, arbitrary_client_pid); } TEST_F(StorageWithOneClient, ReturnsCorrectExistingPIDByAppID) { const std::string arbitrary_client_appid{"Client2"}; - const int arbitrary_client_pid{2}; + const pid_t arbitrary_client_pid{2}; client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid); - int pid = client_manager.find_client_pid_by_appid(preloaded_client_appid_1); + pid_t pid = client_manager.find_client_pid_by_appid(preloaded_client_appid_1); ASSERT_EQ(pid, preloaded_client_pid_1); } TEST_F(StorageWithOneClient, ReturnsCorrectCreatedPIDByAppID) { const std::string arbitrary_client_appid{"Client2"}; - const int arbitrary_client_pid{2}; + const pid_t arbitrary_client_pid{2}; client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid); - int pid = client_manager.find_client_pid_by_appid(arbitrary_client_appid); + pid_t pid = client_manager.find_client_pid_by_appid(arbitrary_client_appid); ASSERT_EQ(pid, arbitrary_client_pid); } TEST_F(StorageWithOneClient, ReturnsCorrectExistingAppIDByPID) { const std::string arbitrary_client_appid{"Client2"}; - const int arbitrary_client_pid{2}; + const pid_t arbitrary_client_pid{2}; client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid); -- 2.7.4 From 7a4a09ce041cf53125b586911206c1ff7a331511 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Mon, 13 Apr 2020 21:58:22 +0900 Subject: [PATCH 03/16] Remove unnecessary mas_ prefix in CServiceMain Change-Id: I94bee8d42fb51c612e319526ee3eb3124485b80f --- inc/service_main.h | 80 ++++++------ src/service_main.cpp | 184 +++++++++++++-------------- src/service_plugin.cpp | 34 ++--- tests/utc/service-main/test_service_main.cpp | 2 +- 4 files changed, 150 insertions(+), 150 deletions(-) diff --git a/inc/service_main.h b/inc/service_main.h index c33b6c1..64803ad 100644 --- a/inc/service_main.h +++ b/inc/service_main.h @@ -76,47 +76,47 @@ public: {} virtual ~CServiceMain() {} - int mas_client_get_audio_format(pid_t pid, int* rate, int* channel, int* audio_type); - int mas_client_get_audio_source_type(pid_t pid, char** type); - int mas_client_send_preprocessing_information(pid_t pid); - int mas_client_send_voice_key_status_change(pid_t pid, ma_voice_key_status_e status); - int mas_client_request_speech_data(pid_t pid); - int mas_client_send_asr_result(pid_t pid, int event, const char* asr_result); - int mas_client_send_result(pid_t pid, const char* display_text, + int client_get_audio_format(pid_t pid, int* rate, int* channel, int* audio_type); + int client_get_audio_source_type(pid_t pid, char** type); + int client_send_preprocessing_information(pid_t pid); + int client_send_voice_key_status_change(pid_t pid, ma_voice_key_status_e status); + int client_request_speech_data(pid_t pid); + int client_send_asr_result(pid_t pid, int event, const char* asr_result); + int client_send_result(pid_t pid, const char* display_text, const char* utterance_text, const char* result_json); - int mas_client_send_recognition_result(pid_t pid, int result); - int mas_client_start_streaming_audio_data(pid_t pid, int type); - int mas_client_stop_streaming_audio_data(pid_t pid, int type); - int mas_client_update_voice_feedback_state(pid_t pid, int state); - int mas_client_set_assistant_specific_command(pid_t pid, const char *command); - int mas_client_set_background_volume(pid_t pid, double ratio); - int mas_client_set_preprocessing_allow_mode(pid_t pid, ma_preprocessing_allow_mode_e mode, const char* appid); - int mas_client_send_preprocessing_result(pid_t pid, bool result); - int mas_client_set_wake_word_audio_require_flag(pid_t pid, bool require); - int mas_client_set_assistant_language(pid_t pid, const char* language); - int mas_client_add_wake_word(pid_t pid, const char* wake_word, const char* language); - int mas_client_remove_wake_word(pid_t pid, const char* wake_word, const char* language); - int mas_ui_client_initialize(pid_t pid); - int mas_ui_client_deinitialize(pid_t pid); - int mas_ui_client_change_assistant(const char* appid); - pid_t mas_get_current_client_pid(); - pid_t mas_get_current_preprocessing_client_pid(); - pid_t mas_get_current_audio_processing_pid(); - int mas_get_client_pid_by_wakeup_word(const char *wakeup_word); - int mas_get_client_pid_by_appid(const char *appid); - std::string mas_get_client_appid_by_pid(pid_t pid); - bool mas_get_client_custom_ui_option_by_appid(const char *appid); - const char* mas_get_client_appid_by_wakeup_word(const char *wakeup_word); - int mas_set_current_client_by_wakeup_word(const char *wakeup_word); - int mas_set_current_client_by_appid(const char *appid); - int mas_launch_client_by_wakeup_word(const char *wakeup_word); - int mas_prelaunch_default_assistant(); - int mas_set_current_service_state(ma_service_state_e state); - int mas_bring_client_to_foreground(const char* appid); - ma_service_state_e mas_get_current_service_state(); - int mas_launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE launch_mode); - int mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT event); - int mas_update_voice_key_support_mode(); + int client_send_recognition_result(pid_t pid, int result); + int client_start_streaming_audio_data(pid_t pid, int type); + int client_stop_streaming_audio_data(pid_t pid, int type); + int client_update_voice_feedback_state(pid_t pid, int state); + int client_set_assistant_specific_command(pid_t pid, const char *command); + int client_set_background_volume(pid_t pid, double ratio); + int client_set_preprocessing_allow_mode(pid_t pid, ma_preprocessing_allow_mode_e mode, const char* appid); + int client_send_preprocessing_result(pid_t pid, bool result); + int client_set_wake_word_audio_require_flag(pid_t pid, bool require); + int client_set_assistant_language(pid_t pid, const char* language); + int client_add_wake_word(pid_t pid, const char* wake_word, const char* language); + int client_remove_wake_word(pid_t pid, const char* wake_word, const char* language); + int ui_client_initialize(pid_t pid); + int ui_client_deinitialize(pid_t pid); + int ui_client_change_assistant(const char* appid); + pid_t get_current_client_pid(); + pid_t get_current_preprocessing_client_pid(); + pid_t get_current_audio_processing_pid(); + int get_client_pid_by_wakeup_word(const char *wakeup_word); + int get_client_pid_by_appid(const char *appid); + std::string get_client_appid_by_pid(pid_t pid); + bool get_client_custom_ui_option_by_appid(const char *appid); + const char* get_client_appid_by_wakeup_word(const char *wakeup_word); + int set_current_client_by_wakeup_word(const char *wakeup_word); + int set_current_client_by_appid(const char *appid); + int launch_client_by_wakeup_word(const char *wakeup_word); + int prelaunch_default_assistant(); + int set_current_service_state(ma_service_state_e state); + int bring_client_to_foreground(const char* appid); + ma_service_state_e get_current_service_state(); + int launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE launch_mode); + int process_preprocessing_state_event(PREPROCESSING_STATE_EVENT event); + int update_voice_key_support_mode(); virtual int on_initialize(pid_t pid) override; virtual int on_deinitialize(pid_t pid) override; diff --git a/src/service_main.cpp b/src/service_main.cpp index 424b653..699e0db 100644 --- a/src/service_main.cpp +++ b/src/service_main.cpp @@ -74,7 +74,7 @@ bool CServiceMain::is_current_preprocessing_assistant(const char* appid) return ret; } -int CServiceMain::mas_client_get_audio_format(pid_t pid, int* rate, int* channel, int* audio_type) +int CServiceMain::client_get_audio_format(pid_t pid, int* rate, int* channel, int* audio_type) { MAS_LOGD("[Enter] pid(%d)", pid); @@ -87,7 +87,7 @@ int CServiceMain::mas_client_get_audio_format(pid_t pid, int* rate, int* channel } #define MAX_LOCAL_VARIABLE_STRING_LEN 256 -int CServiceMain::mas_client_get_audio_source_type(pid_t pid, char** type) +int CServiceMain::client_get_audio_source_type(pid_t pid, char** type) { MAS_LOGD("[Enter] pid(%d)", pid); @@ -106,7 +106,7 @@ int CServiceMain::mas_client_get_audio_source_type(pid_t pid, char** type) return ret; } -int CServiceMain::mas_client_send_preprocessing_information(pid_t pid) +int CServiceMain::client_send_preprocessing_information(pid_t pid) { int ret = -1; MAS_LOGD("[Enter] pid(%d)", pid); @@ -121,7 +121,7 @@ int CServiceMain::mas_client_send_preprocessing_information(pid_t pid) return ret; } -int CServiceMain::mas_client_send_voice_key_status_change(pid_t pid, ma_voice_key_status_e status) +int CServiceMain::client_send_voice_key_status_change(pid_t pid, ma_voice_key_status_e status) { int ret = -1; MAS_LOGD("[Enter] pid(%d)", pid); @@ -135,7 +135,7 @@ int CServiceMain::mas_client_send_voice_key_status_change(pid_t pid, ma_voice_ke return ret; } -int CServiceMain::mas_client_send_asr_result(pid_t pid, int event, const char* asr_result) +int CServiceMain::client_send_asr_result(pid_t pid, int event, const char* asr_result) { MAS_LOGD("[Enter] pid(%d), event(%d), asr_result(%s)", pid, event, asr_result); int ret = mServiceIpc.masc_ui_dbus_send_asr_result(pid, event, asr_result); @@ -148,7 +148,7 @@ int CServiceMain::mas_client_send_asr_result(pid_t pid, int event, const char* a return ret; } -int CServiceMain::mas_client_send_result(pid_t pid, const char* display_text, +int CServiceMain::client_send_result(pid_t pid, const char* display_text, const char* utterance_text, const char* result_json) { MAS_LOGD("[Enter] pid(%d), display_text(%s), utterance_text(%s), result_json(%s)", pid, display_text, utterance_text, result_json); @@ -167,7 +167,7 @@ int CServiceMain::mas_client_send_result(pid_t pid, const char* display_text, return ret; } -int CServiceMain::mas_client_send_recognition_result(pid_t pid, int result) +int CServiceMain::client_send_recognition_result(pid_t pid, int result) { MAS_LOGD("[Enter] pid(%d), result(%d)", pid, result); int ret = mServiceIpc.masc_ui_dbus_send_recognition_result(pid, result); @@ -185,13 +185,13 @@ int CServiceMain::mas_client_send_recognition_result(pid_t pid, int result) return ret; } -int CServiceMain::mas_client_start_streaming_audio_data(pid_t pid, int type) +int CServiceMain::client_start_streaming_audio_data(pid_t pid, int type) { int ret = -1; switch(type) { case MA_AUDIO_STREAMING_DATA_TYPE_CURRENT_UTTERANCE: ret = mServicePlugin.start_streaming_utterance_data(); - mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_UTTERANCE_STREAMING_STARTED); + process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_UTTERANCE_STREAMING_STARTED); break; case MA_AUDIO_STREAMING_DATA_TYPE_PREVIOUS_UTTERANCE: ret = mServicePlugin.start_streaming_previous_utterance_data(); @@ -199,13 +199,13 @@ int CServiceMain::mas_client_start_streaming_audio_data(pid_t pid, int type) break; case MA_AUDIO_STREAMING_DATA_TYPE_FOLLOW_UP_SPEECH: ret = mServicePlugin.start_streaming_follow_up_data(); - mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_FOLLOW_UP_STREAMING_STARTED); + process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_FOLLOW_UP_STREAMING_STARTED); break; } return ret; } -int CServiceMain::mas_client_stop_streaming_audio_data(pid_t pid, int type) +int CServiceMain::client_stop_streaming_audio_data(pid_t pid, int type) { int ret = -1; switch(type) { @@ -222,7 +222,7 @@ int CServiceMain::mas_client_stop_streaming_audio_data(pid_t pid, int type) return ret; } -int CServiceMain::mas_client_update_voice_feedback_state(pid_t pid, int state) +int CServiceMain::client_update_voice_feedback_state(pid_t pid, int state) { std::string pid_appid; boost::optional appid_by_pid = mApplicationManager.get_appid_by_pid(pid); @@ -233,7 +233,7 @@ int CServiceMain::mas_client_update_voice_feedback_state(pid_t pid, int state) return 0; } -int CServiceMain::mas_client_set_assistant_specific_command(pid_t pid, const char *command) +int CServiceMain::client_set_assistant_specific_command(pid_t pid, const char *command) { std::string pid_appid; boost::optional appid_by_pid = mApplicationManager.get_appid_by_pid(pid); @@ -244,7 +244,7 @@ int CServiceMain::mas_client_set_assistant_specific_command(pid_t pid, const cha return 0; } -int CServiceMain::mas_client_set_background_volume(pid_t pid, double ratio) +int CServiceMain::client_set_background_volume(pid_t pid, double ratio) { std::string pid_appid; boost::optional appid_by_pid = mApplicationManager.get_appid_by_pid(pid); @@ -255,7 +255,7 @@ int CServiceMain::mas_client_set_background_volume(pid_t pid, double ratio) return 0; } -int CServiceMain::mas_client_set_preprocessing_allow_mode(pid_t pid, ma_preprocessing_allow_mode_e mode, const char* appid) +int CServiceMain::client_set_preprocessing_allow_mode(pid_t pid, ma_preprocessing_allow_mode_e mode, const char* appid) { std::string pid_appid; boost::optional appid_by_pid = mApplicationManager.get_appid_by_pid(pid); @@ -277,12 +277,12 @@ int CServiceMain::mas_client_set_preprocessing_allow_mode(pid_t pid, ma_preproce } } - mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_PREPROCESSING_ALLOW_MODE_CHANGED); + process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_PREPROCESSING_ALLOW_MODE_CHANGED); return 0; } -int CServiceMain::mas_client_send_preprocessing_result(pid_t pid, bool result) +int CServiceMain::client_send_preprocessing_result(pid_t pid, bool result) { std::string pid_appid; boost::optional appid_by_pid = mApplicationManager.get_appid_by_pid(pid); @@ -298,10 +298,10 @@ int CServiceMain::mas_client_send_preprocessing_result(pid_t pid, bool result) if (result) { MAS_LOGD("Preprocessing succeeded, bring (%s) to foreground", pid_appid.c_str()); - mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_PREPROCESSING_SUCCEEDED); + process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_PREPROCESSING_SUCCEEDED); } else { MAS_LOGD("Preprocessing failed, bring (%s) to foreground", current_maclient_appid); - mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_PREPROCESSING_FAILED); + process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_PREPROCESSING_FAILED); } if (current_maclient_appid) { @@ -313,7 +313,7 @@ int CServiceMain::mas_client_send_preprocessing_result(pid_t pid, bool result) return 0; } -int CServiceMain::mas_client_set_wake_word_audio_require_flag(pid_t pid, bool require) +int CServiceMain::client_set_wake_word_audio_require_flag(pid_t pid, bool require) { std::string pid_appid; boost::optional appid_by_pid = mApplicationManager.get_appid_by_pid(pid); @@ -325,7 +325,7 @@ int CServiceMain::mas_client_set_wake_word_audio_require_flag(pid_t pid, bool re return 0; } -int CServiceMain::mas_client_set_assistant_language(pid_t pid, const char* language) +int CServiceMain::client_set_assistant_language(pid_t pid, const char* language) { std::string pid_appid; boost::optional appid_by_pid = mApplicationManager.get_appid_by_pid(pid); @@ -337,7 +337,7 @@ int CServiceMain::mas_client_set_assistant_language(pid_t pid, const char* langu return 0; } -int CServiceMain::mas_client_add_wake_word(pid_t pid, const char* wake_word, const char* language) +int CServiceMain::client_add_wake_word(pid_t pid, const char* wake_word, const char* language) { std::string pid_appid; boost::optional appid_by_pid = mApplicationManager.get_appid_by_pid(pid); @@ -366,7 +366,7 @@ int CServiceMain::mas_client_add_wake_word(pid_t pid, const char* wake_word, con return 0; } -int CServiceMain::mas_client_remove_wake_word(pid_t pid, const char* wake_word, const char* language) +int CServiceMain::client_remove_wake_word(pid_t pid, const char* wake_word, const char* language) { std::string pid_appid; boost::optional appid_by_pid = mApplicationManager.get_appid_by_pid(pid); @@ -392,21 +392,21 @@ int CServiceMain::mas_client_remove_wake_word(pid_t pid, const char* wake_word, return 0; } -int CServiceMain::mas_ui_client_initialize(pid_t pid) +int CServiceMain::ui_client_initialize(pid_t pid) { MAS_LOGD("[Enter] pid(%d)", pid); return 0; } -int CServiceMain::mas_ui_client_deinitialize(pid_t pid) +int CServiceMain::ui_client_deinitialize(pid_t pid) { MAS_LOGD("[Enter] pid(%d)", pid); return 0; } -int CServiceMain::mas_ui_client_change_assistant(const char* appid) +int CServiceMain::ui_client_change_assistant(const char* appid) { MAS_LOGD("[Enter]"); @@ -415,16 +415,16 @@ int CServiceMain::mas_ui_client_change_assistant(const char* appid) return -1; } - bool use_custom_ui = mas_get_client_custom_ui_option_by_appid(appid); + bool use_custom_ui = get_client_custom_ui_option_by_appid(appid); mServiceIpc.masc_ui_dbus_enable_common_ui(!use_custom_ui); - mas_set_current_client_by_appid(appid); - pid_t pid = mas_get_client_pid_by_appid(appid); + set_current_client_by_appid(appid); + pid_t pid = get_client_pid_by_appid(appid); if (pid != -1) { - mas_bring_client_to_foreground(appid); - mas_client_send_preprocessing_information(pid); + bring_client_to_foreground(appid); + client_send_preprocessing_information(pid); if (MA_VOICE_KEY_STATUS_PRESSED == mLastVoiceKeyStatus) { - mas_client_send_voice_key_status_change(pid, mLastVoiceKeyStatus); + client_send_voice_key_status_change(pid, mLastVoiceKeyStatus); } mServiceIpc.change_active_state(pid, MA_ACTIVE_STATE_ACTIVE); @@ -445,7 +445,7 @@ int CServiceMain::mas_ui_client_change_assistant(const char* appid) 0 < strlen(mClientInfo[loop].appid) && 0 < strlen(mClientInfo[loop].wakeup_word[0])) { if (strncmp(appid, mClientInfo[loop].appid, MAX_APPID_LEN) == 0) { - mas_launch_client_by_appid(mClientInfo[loop].appid, CLIENT_LAUNCH_MODE_ACTIVATION); + launch_client_by_appid(mClientInfo[loop].appid, CLIENT_LAUNCH_MODE_ACTIVATION); } } } @@ -454,7 +454,7 @@ int CServiceMain::mas_ui_client_change_assistant(const char* appid) return 0; } -static int mas_assistant_info_cb(ma_assistant_info_s* info, void* user_data) { +static int assistant_info_cb(ma_assistant_info_s* info, void* user_data) { int ret = -1; CServiceMain* service_main = static_cast(user_data); if (service_main) { @@ -464,7 +464,7 @@ static int mas_assistant_info_cb(ma_assistant_info_s* info, void* user_data) { } int CServiceMain::add_assistant_info(ma_assistant_info_s* info) { - MAS_LOGD("__mas_assistant_info_cb called"); + MAS_LOGD("__assistant_info_cb called"); if (NULL == info) { MAS_LOGE("info NULL, returning"); @@ -539,7 +539,7 @@ int CServiceMain::add_assistant_info(ma_assistant_info_s* info) { MAS_LOGD("Couldn't find an empty slot for storing assistant info"); } - MAS_LOGD("__mas_assistant_info_cb end"); + MAS_LOGD("__assistant_info_cb end"); return 0; } @@ -588,7 +588,7 @@ int CServiceMain::initialize_service_plugin(void) mCurrentPreprocessingClientInfo = -1; mWakeupClientAppId.clear(); - if (0 == mServiceConfig.get_assistant_info(mas_assistant_info_cb, this)) { + if (0 == mServiceConfig.get_assistant_info(assistant_info_cb, this)) { for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM; loop++) { int inner_loop; if (0 < strlen(mClientInfo[loop].appid)) { @@ -676,7 +676,7 @@ int CServiceMain::process_activated_setting() return 0; } -int CServiceMain::mas_get_current_client_pid() +int CServiceMain::get_current_client_pid() { int ret = -1; if (mCurrentClientInfo >= 0 && mCurrentClientInfo < MAX_MACLIENT_INFO_NUM) { @@ -688,7 +688,7 @@ int CServiceMain::mas_get_current_client_pid() return ret; } -pid_t CServiceMain::mas_get_current_preprocessing_client_pid() +pid_t CServiceMain::get_current_preprocessing_client_pid() { pid_t ret = -1; if (mCurrentPreprocessingClientInfo >= 0 && mCurrentPreprocessingClientInfo < MAX_MACLIENT_INFO_NUM) { @@ -700,7 +700,7 @@ pid_t CServiceMain::mas_get_current_preprocessing_client_pid() return ret; } -pid_t CServiceMain::mas_get_current_audio_processing_pid() +pid_t CServiceMain::get_current_audio_processing_pid() { pid_t ret = -1; if (mCurrentClientInfo >= 0 && mCurrentClientInfo < MAX_MACLIENT_INFO_NUM) { @@ -717,7 +717,7 @@ pid_t CServiceMain::mas_get_current_audio_processing_pid() return ret; } -pid_t CServiceMain::mas_get_client_pid_by_appid(const char *appid) +pid_t CServiceMain::get_client_pid_by_appid(const char *appid) { pid_t ret = -1; @@ -734,7 +734,7 @@ pid_t CServiceMain::mas_get_client_pid_by_appid(const char *appid) return ret; } -bool CServiceMain::mas_get_client_custom_ui_option_by_appid(const char *appid) +bool CServiceMain::get_client_custom_ui_option_by_appid(const char *appid) { bool ret = false; for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM; loop++) { @@ -749,13 +749,13 @@ bool CServiceMain::mas_get_client_custom_ui_option_by_appid(const char *appid) return ret; } -int CServiceMain::mas_get_client_pid_by_wakeup_word(const char *wakeup_word) +int CServiceMain::get_client_pid_by_wakeup_word(const char *wakeup_word) { - const char *appid = mas_get_client_appid_by_wakeup_word(wakeup_word); - return mas_get_client_pid_by_appid(appid); + const char *appid = get_client_appid_by_wakeup_word(wakeup_word); + return get_client_pid_by_appid(appid); } -const char* CServiceMain::mas_get_client_appid_by_wakeup_word(const char *wakeup_word) +const char* CServiceMain::get_client_appid_by_wakeup_word(const char *wakeup_word) { int loop; const char *appid = NULL; @@ -801,7 +801,7 @@ const char* CServiceMain::mas_get_client_appid_by_wakeup_word(const char *wakeup return appid; } -int CServiceMain::mas_set_current_client_by_wakeup_word(const char *wakeup_word) +int CServiceMain::set_current_client_by_wakeup_word(const char *wakeup_word) { int loop; int ret = -1; @@ -846,7 +846,7 @@ int CServiceMain::mas_set_current_client_by_wakeup_word(const char *wakeup_word) if (mCurrentClientInfo != prev_selection) { if (prev_selection >= 0 && prev_selection < MAX_MACLIENT_INFO_NUM) { - pid_t pid = mas_get_client_pid_by_appid(mClientInfo[prev_selection].appid); + pid_t pid = get_client_pid_by_appid(mClientInfo[prev_selection].appid); mServiceIpc.change_active_state(pid, MA_ACTIVE_STATE_INACTIVE); } } @@ -854,7 +854,7 @@ int CServiceMain::mas_set_current_client_by_wakeup_word(const char *wakeup_word) return ret; } -int CServiceMain::mas_set_current_client_by_appid(const char *appid) +int CServiceMain::set_current_client_by_appid(const char *appid) { int ret = -1; int prev_selection = mCurrentClientInfo; @@ -872,7 +872,7 @@ int CServiceMain::mas_set_current_client_by_appid(const char *appid) if (mCurrentClientInfo != prev_selection) { if (prev_selection >= 0 && prev_selection < MAX_MACLIENT_INFO_NUM) { - pid_t pid = mas_get_client_pid_by_appid(mClientInfo[prev_selection].appid); + pid_t pid = get_client_pid_by_appid(mClientInfo[prev_selection].appid); mServiceIpc.change_active_state(pid, MA_ACTIVE_STATE_INACTIVE); } } @@ -880,7 +880,7 @@ int CServiceMain::mas_set_current_client_by_appid(const char *appid) return ret; } -int CServiceMain::mas_launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE launch_mode) +int CServiceMain::launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE launch_mode) { int result = 0; @@ -917,7 +917,7 @@ int CServiceMain::mas_launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MO return result; } -int CServiceMain::mas_bring_client_to_foreground(const char* appid) +int CServiceMain::bring_client_to_foreground(const char* appid) { int ret = 0; @@ -933,13 +933,13 @@ int CServiceMain::mas_bring_client_to_foreground(const char* appid) return ret; } -int CServiceMain::mas_launch_client_by_wakeup_word(const char *wakeup_word) +int CServiceMain::launch_client_by_wakeup_word(const char *wakeup_word) { - const char *appid = mas_get_client_appid_by_wakeup_word(wakeup_word); - return mas_launch_client_by_appid(appid, CLIENT_LAUNCH_MODE_ACTIVATION); + const char *appid = get_client_appid_by_wakeup_word(wakeup_word); + return launch_client_by_appid(appid, CLIENT_LAUNCH_MODE_ACTIVATION); } -int CServiceMain::mas_prelaunch_default_assistant() +int CServiceMain::prelaunch_default_assistant() { /* CHECK NEEDED : should the code segment below and activation logic above be moved to wakeup manger? */ boost::optional prelaunch_mode = @@ -949,14 +949,14 @@ int CServiceMain::mas_prelaunch_default_assistant() if (0 == mServicePlugin.get_default_assistant(&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); + launch_client_by_appid(default_assistant, CLIENT_LAUNCH_MODE_PRELAUNCH); } } } return 0; } -int CServiceMain::mas_update_voice_key_support_mode() +int CServiceMain::update_voice_key_support_mode() { /* CHECK NEEDED : should the code segment below and activation logic above be moved to wakeup manger? */ bool successful = false; @@ -1002,7 +1002,7 @@ ma_preprocessing_allow_mode_e CServiceMain::get_preprocessing_allow_mode(const c /* This might need to be read from settings in the future, but using macro for now */ //#define BRING_PREPROCESSING_ASSISTANT_TO_FRONT -int CServiceMain::mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT event) +int CServiceMain::process_preprocessing_state_event(PREPROCESSING_STATE_EVENT event) { const char* current_maclient_appid = NULL; const char* preprocessing_allow_appid = NULL; @@ -1018,7 +1018,7 @@ int CServiceMain::mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVEN #ifndef BRING_PREPROCESSING_ASSISTANT_TO_FRONT /* If there is no need to bring preprocessing assistant to front, current_maclient should always be brought to front */ - mas_bring_client_to_foreground(current_maclient_appid); + bring_client_to_foreground(current_maclient_appid); #endif mCurrentPreprocessingState = PREPROCESSING_STATE_WAKEUP_PREPROCESS_DISABLED; if (check_preprocessing_assistant_exists()) { @@ -1032,7 +1032,7 @@ int CServiceMain::mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVEN #ifdef BRING_PREPROCESSING_ASSISTANT_TO_FRONT /* If preprocessing assistant does not exist, there is no way to enable preprocessing assistant, so bring current maclient to front right away */ - mas_bring_client_to_foreground(current_maclient_appid); + bring_client_to_foreground(current_maclient_appid); #endif } } @@ -1060,7 +1060,7 @@ int CServiceMain::mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVEN would have been brought to front already on wakeup event */ #ifdef BRING_PREPROCESSING_ASSISTANT_TO_FRONT if (check_preprocessing_assistant_exists()) { - mas_bring_client_to_foreground(current_maclient_appid); + bring_client_to_foreground(current_maclient_appid); } #endif mCurrentPreprocessingState = PREPROCESSING_STATE_NONE; @@ -1087,7 +1087,7 @@ int CServiceMain::mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVEN mPreferenceManager.get_bool(WAKEUP_SETTINGS_KEY_PREPROCESSING_ASSISTANT_APPID); if (preprocessing_assistant) { MAS_LOGD("preprocessing_assistant_appid : %s", (*preprocessing_assistant).c_str()); - mas_bring_client_to_foreground((*preprocessing_assistant).c_str()); + bring_client_to_foreground((*preprocessing_assistant).c_str()); } } #endif @@ -1099,7 +1099,7 @@ int CServiceMain::mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVEN #ifdef BRING_PREPROCESSING_ASSISTANT_TO_FRONT if (PREPROCESSING_STATE_EVENT_UTTERANCE_STREAMING_STARTED == mCurrentPreprocessingState || PREPROCESSING_STATE_EVENT_FOLLOW_UP_STREAMING_STARTED == mCurrentPreprocessingState) { - mas_bring_client_to_foreground(current_maclient_appid); + bring_client_to_foreground(current_maclient_appid); } #endif mCurrentPreprocessingState = PREPROCESSING_STATE_NONE; @@ -1109,7 +1109,7 @@ int CServiceMain::mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVEN return 0; } -int CServiceMain::mas_set_current_service_state(ma_service_state_e state) +int CServiceMain::set_current_service_state(ma_service_state_e state) { mCurrentServiceState = state; @@ -1129,7 +1129,7 @@ int CServiceMain::mas_set_current_service_state(ma_service_state_e state) return 0; } -ma_service_state_e CServiceMain::mas_get_current_service_state() +ma_service_state_e CServiceMain::get_current_service_state() { return mCurrentServiceState; } @@ -1331,15 +1331,15 @@ bool CServiceMain::app_create(void *data) process_activated_setting(); - mas_prelaunch_default_assistant(); - mas_update_voice_key_support_mode(); + prelaunch_default_assistant(); + update_voice_key_support_mode(); /* For the case of preprocessing assistant, it always have to be launched beforehand */ boost::optional preprocessing_assistant = mPreferenceManager.get_string(WAKEUP_SETTINGS_KEY_PREPROCESSING_ASSISTANT_APPID); if (preprocessing_assistant) { MAS_LOGD("prelaunching preprocessing_assistant_appid : %s", (*preprocessing_assistant).c_str()); - mas_launch_client_by_appid((*preprocessing_assistant).c_str(), CLIENT_LAUNCH_MODE_PRELAUNCH); + launch_client_by_appid((*preprocessing_assistant).c_str(), CLIENT_LAUNCH_MODE_PRELAUNCH); } if (!mPackageManagerHandle) { @@ -1406,9 +1406,9 @@ int CServiceMain::on_initialize(pid_t pid) { current_maclient_appid = mClientInfo[mCurrentClientInfo].appid; } - mas_client_send_preprocessing_information(pid); + client_send_preprocessing_information(pid); if (MA_VOICE_KEY_STATUS_PRESSED == mLastVoiceKeyStatus) { - mas_client_send_voice_key_status_change(pid, mLastVoiceKeyStatus); + client_send_voice_key_status_change(pid, mLastVoiceKeyStatus); } if (current_maclient_appid && 0 == pid_appid.compare(current_maclient_appid)) { MAS_LOGD("MA client with current maclient appid connected!"); @@ -1416,7 +1416,7 @@ int CServiceMain::on_initialize(pid_t pid) { if (0 == mWakeupClientAppId.compare(pid_appid)) { mWakeupClientAppId.clear(); mServiceIpc.change_active_state(pid, MA_ACTIVE_STATE_ACTIVE); - mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED); + process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED); } else { MAS_LOGE("[ERROR] mWakeupClientAppId and appid differ : %s %s", mWakeupClientAppId.c_str(), pid_appid.c_str()); @@ -1425,7 +1425,7 @@ int CServiceMain::on_initialize(pid_t pid) { MAS_LOGD("MA client connected, but its appid does not match with current maclient"); } - mServiceIpc.change_service_state(pid, mas_get_current_service_state()); + mServiceIpc.change_service_state(pid, get_current_service_state()); } else { MAS_LOGE("[ERROR] Fail to retrieve appid"); } @@ -1441,7 +1441,7 @@ int CServiceMain::on_deinitialize(pid_t pid) { int CServiceMain::on_get_audio_format(pid_t pid, int& rate, int& channel, int& audio_type) { int main_rate, main_channel, main_audio_type; - int ret = mas_client_get_audio_format(pid, + int ret = client_get_audio_format(pid, &main_rate, &main_channel, &main_audio_type); rate = main_rate; channel = main_channel; @@ -1451,7 +1451,7 @@ int CServiceMain::on_get_audio_format(pid_t pid, int& rate, int& channel, int& a int CServiceMain::on_get_audio_source_type(pid_t pid, std::string& type) { char *main_type = nullptr; - int ret = mas_client_get_audio_source_type(pid, &main_type); + int ret = client_get_audio_source_type(pid, &main_type); if (0 == ret && main_type) { type = std::string{main_type}; } @@ -1459,75 +1459,75 @@ int CServiceMain::on_get_audio_source_type(pid_t pid, std::string& type) { } int CServiceMain::on_send_asr_result(pid_t pid, int event, std::string asr_result) { - return mas_client_send_asr_result(pid, event, asr_result.c_str()); + return client_send_asr_result(pid, event, asr_result.c_str()); } int CServiceMain::on_send_result(pid_t pid, std::string display_text, std::string utterance_text, std::string result_json) { - return mas_client_send_result(pid, + return client_send_result(pid, display_text.c_str(), utterance_text.c_str(), result_json.c_str()); } int CServiceMain::on_send_recognition_result(pid_t pid, int result) { - return mas_client_send_recognition_result(pid, result); + return client_send_recognition_result(pid, result); } int CServiceMain::on_start_streaming_audio_data(pid_t pid, int type) { - return mas_client_start_streaming_audio_data(pid, type); + return client_start_streaming_audio_data(pid, type); } int CServiceMain::on_stop_streaming_audio_data(pid_t pid, int type) { - return mas_client_stop_streaming_audio_data(pid, type); + return client_stop_streaming_audio_data(pid, type); } int CServiceMain::on_update_voice_feedback_state(pid_t pid, int state) { - return mas_client_update_voice_feedback_state(pid, state); + return client_update_voice_feedback_state(pid, state); } int CServiceMain::on_send_assistant_specific_command(pid_t pid, std::string command) { - return mas_client_set_assistant_specific_command(pid, command.c_str()); + return client_set_assistant_specific_command(pid, command.c_str()); } int CServiceMain::on_set_background_volume(pid_t pid, double ratio) { - return mas_client_set_background_volume(pid, ratio); + return client_set_background_volume(pid, ratio); } int CServiceMain::on_set_preprocessing_allow_mode(pid_t pid, int mode, std::string app_id) { - return mas_client_set_preprocessing_allow_mode(pid, + return client_set_preprocessing_allow_mode(pid, static_cast(mode), app_id.c_str()); } int CServiceMain::on_send_preprocessing_result(pid_t pid, int result) { - return mas_client_send_preprocessing_result(pid, result); + return client_send_preprocessing_result(pid, result); } int CServiceMain::on_set_wake_word_audio_require_flag(pid_t pid, int require) { - return mas_client_set_wake_word_audio_require_flag(pid, require); + return client_set_wake_word_audio_require_flag(pid, require); } int CServiceMain::on_set_assistant_language(pid_t pid, std::string language) { - return mas_client_set_assistant_language(pid, language.c_str()); + return client_set_assistant_language(pid, language.c_str()); } int CServiceMain::on_add_wake_word(pid_t pid, std::string wake_word, std::string language) { - return mas_client_add_wake_word(pid, wake_word.c_str(), language.c_str()); + return client_add_wake_word(pid, wake_word.c_str(), language.c_str()); } int CServiceMain::on_remove_wake_word(pid_t pid, std::string wake_word, std::string language) { - return mas_client_remove_wake_word(pid, wake_word.c_str(), language.c_str()); + return client_remove_wake_word(pid, wake_word.c_str(), language.c_str()); } int CServiceMain::on_ui_initialize(pid_t pid) { - return mas_ui_client_initialize(pid); + return ui_client_initialize(pid); } int CServiceMain::on_ui_deinitialize(pid_t pid) { - return mas_ui_client_deinitialize(pid); + return ui_client_deinitialize(pid); } int CServiceMain::on_ui_change_assistant(std::string app_id) { - return mas_ui_client_change_assistant(app_id.c_str()); + return ui_client_change_assistant(app_id.c_str()); } diff --git a/src/service_plugin.cpp b/src/service_plugin.cpp index 339cf79..c8fa256 100644 --- a/src/service_plugin.cpp +++ b/src/service_plugin.cpp @@ -103,7 +103,7 @@ static Eina_Bool process_wakeup_event_by_appid_timer(void* data) service_main = plugin->get_service_main(); } if (service_ipc && service_main) { - bool use_custom_ui = service_main->mas_get_client_custom_ui_option_by_appid(appid); + bool use_custom_ui = service_main->get_client_custom_ui_option_by_appid(appid); bool ui_panel_enabled = false; if (param->plugin) ui_panel_enabled = param->plugin->is_ui_panel_enabled(); if (ui_panel_enabled) { @@ -111,15 +111,15 @@ static Eina_Bool process_wakeup_event_by_appid_timer(void* data) service_ipc->masc_ui_dbus_change_assistant(appid); } - service_main->mas_set_current_client_by_appid(appid); - if ((pid = service_main->mas_get_client_pid_by_appid(appid)) != -1) { - service_main->mas_client_send_preprocessing_information(pid); + service_main->set_current_client_by_appid(appid); + if ((pid = service_main->get_client_pid_by_appid(appid)) != -1) { + service_main->client_send_preprocessing_information(pid); service_ipc->change_active_state(pid, MA_ACTIVE_STATE_ACTIVE); - service_main->mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED); + service_main->process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED); } else { // Appropriate MA Client not available, trying to launch new one MAS_LOGD("MA Client with appid %s does not exist, launching client", appid); - service_main->mas_launch_client_by_appid(appid, CLIENT_LAUNCH_MODE_ACTIVATION); + service_main->launch_client_by_appid(appid, CLIENT_LAUNCH_MODE_ACTIVATION); } } @@ -149,7 +149,7 @@ static Eina_Bool process_wakeup_event_by_word_timer(void* data) param = nullptr; if (service_main) { - const char* appid = service_main->mas_get_client_appid_by_wakeup_word(wakeup_word); + const char* appid = service_main->get_client_appid_by_wakeup_word(wakeup_word); if (appid) { param = new(std::nothrow) AsyncParam; if (param) { @@ -324,7 +324,7 @@ void handle_speech_streaming_event_failure(void* data) if (plugin) service_main = plugin->get_service_main(); if (service_main) { - service_main->mas_client_send_recognition_result(0, MA_RECOGNITION_RESULT_EVENT_ERROR); + service_main->client_send_recognition_result(0, MA_RECOGNITION_RESULT_EVENT_ERROR); } delete param; @@ -353,11 +353,11 @@ static void __audio_streaming_cb(mas_speech_streaming_event_e event, void* buffe if (service_ipc && service_main) { /* First check if we have dedicated audio processing app for current client */ - pid_t pid = service_main->mas_get_current_audio_processing_pid(); + pid_t pid = service_main->get_current_audio_processing_pid(); /* If not, send audio data to the main client */ - if (-1 == pid) pid = service_main->mas_get_current_client_pid(); + if (-1 == pid) pid = service_main->get_current_client_pid(); - int preprocessing_pid = service_main->mas_get_current_preprocessing_client_pid(); + int preprocessing_pid = service_main->get_current_preprocessing_client_pid(); if (pid == -1) { MAS_LOGE("[ERROR] Fail to retrieve pid of current MA client"); } else { @@ -421,8 +421,8 @@ static void __setting_changed_cb(void *user_data) CServiceMain* service_main = plugin->get_service_main(); if (service_main) { - service_main->mas_prelaunch_default_assistant(); - service_main->mas_update_voice_key_support_mode(); + service_main->prelaunch_default_assistant(); + service_main->update_voice_key_support_mode(); } MAS_LOGD("[SUCCESS] __setting_changed_cb is called"); } @@ -437,7 +437,7 @@ static void __streaming_section_changed_cb(ma_audio_streaming_data_section_e sec CServiceIpcDbus *service_ipc = plugin->get_service_ipc(); CServiceMain* service_main = plugin->get_service_main(); if (service_ipc && service_main) { - pid_t pid = service_main->mas_get_current_client_pid(); + pid_t pid = service_main->get_current_client_pid(); int ret = service_ipc->send_streaming_section_changed(pid, (int)section); if (0 != ret) { MAS_LOGE("[ERROR] Fail to send streaming section changed information, ret(%d)", ret); @@ -455,7 +455,7 @@ static void __wakeup_engine_command_cb(mas_wakeup_engine_command_target_e target CServiceIpcDbus *service_ipc = plugin->get_service_ipc(); CServiceMain* service_main = plugin->get_service_main(); if (service_ipc && service_main) { - pid_t pid = service_main->mas_get_client_pid_by_appid(assistant_name); + pid_t pid = service_main->get_client_pid_by_appid(assistant_name); if (-1 != pid) { int ret = service_ipc->send_wakeup_engine_command(pid, command); if (0 != ret) { @@ -474,7 +474,7 @@ static void __wakeup_service_state_changed_cb(ma_service_state_e state, void* us CServiceMain* service_main = plugin->get_service_main(); if (service_main) { - service_main->mas_set_current_service_state(state); + service_main->set_current_service_state(state); } } @@ -488,7 +488,7 @@ static void __wakeup_service_voice_key_status_changed_cb(ma_voice_key_status_e s CServiceIpcDbus *service_ipc = plugin->get_service_ipc(); CServiceMain* service_main = plugin->get_service_main(); if (service_ipc && service_main) { - pid_t pid = service_main->mas_get_current_client_pid(); + pid_t pid = service_main->get_current_client_pid(); int ret = service_ipc->change_voice_key_status(pid, status); if (0 != ret) { MAS_LOGE("[ERROR] Fail to send voice key status changed information, ret(%d)", ret); diff --git a/tests/utc/service-main/test_service_main.cpp b/tests/utc/service-main/test_service_main.cpp index 6d8f175..807e52b 100644 --- a/tests/utc/service-main/test_service_main.cpp +++ b/tests/utc/service-main/test_service_main.cpp @@ -115,7 +115,7 @@ TEST_F(DefaultFixure, BringsDefaultAssistantToFrontOnAssistantActivatedPreproces ma_assistant_info_s info; info.app_id = assistant_appid.c_str(); service.add_assistant_info(&info); - service.mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED); + service.process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED); bool brought = false; if (application_manager.brought_to_foreground_appid) { -- 2.7.4 From 545c2e0af1c1216543189812dd434b65279dedb7 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Mon, 13 Apr 2020 22:01:27 +0900 Subject: [PATCH 04/16] Remove unnecessary virtual keyword for overriding functions Change-Id: I293a30f20b5c745f3b08c04cf03c39a7b2e3170f --- inc/application_manager_aul.h | 10 +++--- inc/service_main.h | 44 +++++++++++++------------- tests/utc/audio-manager/test_audio_manager.cpp | 4 +-- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/inc/application_manager_aul.h b/inc/application_manager_aul.h index 9e3bedb..ddf2f26 100644 --- a/inc/application_manager_aul.h +++ b/inc/application_manager_aul.h @@ -29,11 +29,11 @@ public: CApplicationManagerAul(); ~CApplicationManagerAul(); - virtual bool is_application_running(pid_t 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 get_appid_by_pid(pid_t pid) override; + bool is_application_running(pid_t pid) override; + bool is_application_running(const std::string& appid) override; + bool bring_app_to_foreground(const std::string& appid) override; + bool launch_app_async(const std::string& appid, bool background) override; + boost::optional get_appid_by_pid(pid_t pid) override; boost::optional get_pid_by_appid(const std::string& appid) override; }; diff --git a/inc/service_main.h b/inc/service_main.h index 64803ad..47e87c5 100644 --- a/inc/service_main.h +++ b/inc/service_main.h @@ -118,29 +118,29 @@ public: int process_preprocessing_state_event(PREPROCESSING_STATE_EVENT event); int update_voice_key_support_mode(); - virtual int on_initialize(pid_t pid) override; - virtual int on_deinitialize(pid_t pid) override; - virtual int on_get_audio_format(pid_t pid, int& rate, int& channel, int& audio_type) override; - virtual int on_get_audio_source_type(pid_t pid, std::string& type) override; - virtual int on_send_asr_result(pid_t pid, int event, std::string asr_result) override; - virtual int on_send_result(pid_t pid, std::string display_text, + int on_initialize(pid_t pid) override; + int on_deinitialize(pid_t pid) override; + int on_get_audio_format(pid_t pid, int& rate, int& channel, int& audio_type) override; + int on_get_audio_source_type(pid_t pid, std::string& type) override; + int on_send_asr_result(pid_t pid, int event, std::string asr_result) override; + int on_send_result(pid_t pid, std::string display_text, std::string utterance_text, std::string result_json) override; - virtual int on_send_recognition_result(pid_t pid, int result) override; - virtual int on_start_streaming_audio_data(pid_t pid, int type) override; - virtual int on_stop_streaming_audio_data(pid_t pid, int type) override; - virtual int on_update_voice_feedback_state(pid_t pid, int state) override; - virtual int on_send_assistant_specific_command(pid_t pid, std::string command) override; - virtual int on_set_background_volume(pid_t pid, double ratio) override; - virtual int on_set_preprocessing_allow_mode(pid_t pid, int mode, std::string app_id) override; - virtual int on_send_preprocessing_result(pid_t pid, int result) override; - virtual int on_set_wake_word_audio_require_flag(pid_t pid, int require) override; - virtual int on_set_assistant_language(pid_t pid, std::string language) override; - virtual int on_add_wake_word(pid_t pid, std::string wake_word, std::string language) override; - virtual int on_remove_wake_word(pid_t pid, std::string wake_word, std::string language) override; - - virtual int on_ui_initialize(pid_t pid) override; - virtual int on_ui_deinitialize(pid_t pid) override; - virtual int on_ui_change_assistant(std::string app_id) override; + int on_send_recognition_result(pid_t pid, int result) override; + int on_start_streaming_audio_data(pid_t pid, int type) override; + int on_stop_streaming_audio_data(pid_t pid, int type) override; + int on_update_voice_feedback_state(pid_t pid, int state) override; + int on_send_assistant_specific_command(pid_t pid, std::string command) override; + int on_set_background_volume(pid_t pid, double ratio) override; + int on_set_preprocessing_allow_mode(pid_t pid, int mode, std::string app_id) override; + int on_send_preprocessing_result(pid_t pid, int result) override; + int on_set_wake_word_audio_require_flag(pid_t pid, int require) override; + int on_set_assistant_language(pid_t pid, std::string language) override; + int on_add_wake_word(pid_t pid, std::string wake_word, std::string language) override; + int on_remove_wake_word(pid_t pid, std::string wake_word, std::string language) override; + + int on_ui_initialize(pid_t pid) override; + int on_ui_deinitialize(pid_t pid) override; + int on_ui_change_assistant(std::string app_id) override; bool app_create(void *data); void app_terminate(void *data); diff --git a/tests/utc/audio-manager/test_audio_manager.cpp b/tests/utc/audio-manager/test_audio_manager.cpp index a2eb666..72b78b4 100644 --- a/tests/utc/audio-manager/test_audio_manager.cpp +++ b/tests/utc/audio-manager/test_audio_manager.cpp @@ -24,11 +24,11 @@ class CAudioEventObserver : public multiassistant::wakeup::IAudioEventObserver { public: - virtual bool on_recording_audio_data(long time, void* data, int len) override + bool on_recording_audio_data(long time, void* data, int len) override { return true; } - virtual bool on_streaming_audio_data( + bool on_streaming_audio_data( mas_speech_streaming_event_e event, void* buffer, unsigned int len) override { std::string data = std::string{reinterpret_cast(buffer), len}; -- 2.7.4 From 47bb22a51719ac7389778dcfdb2f3428aa4b05c1 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Tue, 14 Apr 2020 13:00:33 +0900 Subject: [PATCH 05/16] Read audio_data_processing_appid info from configuration file Change-Id: I65037276acbbd0639c9e7f4f7a6b0c56f3133956 --- inc/service_config.h | 5 +++++ src/service_config.cpp | 6 ++++++ src/service_main.cpp | 11 +++++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/inc/service_config.h b/inc/service_config.h index 5604ed2..bbc7a40 100644 --- a/inc/service_config.h +++ b/inc/service_config.h @@ -23,6 +23,9 @@ #include "service_common.h" +#include +#include + #ifdef __cplusplus extern "C" { @@ -43,6 +46,7 @@ extern "C" #define MA_TAG_ASSISTANT_CUSTOM_UI "custom-ui" #define MA_TAG_ASSISTANT_VOICE_KEY_SUPPORT_MODE "voice-key-support-mode" #define MA_TAG_ASSISTANT_VOICE_KEY_TAP_DURATION "voice-key-tap-duration" +#define MA_TAG_ASSISTANT_AUDIO_DATA_PROCESSOR "audio-data-processing-appid" /************************************************************************************** *** Definitions for ETC @@ -85,6 +89,7 @@ typedef struct ma_assistant_info_s { bool custom_ui_option; VOICE_KEY_SUPPORT_MODE voice_key_support_mode; float voice_key_tap_duration; + boost::optional audio_data_processing_appid; } ma_assistant_info_s; typedef int (*service_config_assistant_info_cb)(ma_assistant_info_s* info, void* user_data); diff --git a/src/service_config.cpp b/src/service_config.cpp index a86b491..ec0076f 100644 --- a/src/service_config.cpp +++ b/src/service_config.cpp @@ -166,6 +166,12 @@ int CServiceConfig::parse_assistant_info(service_config_assistant_info_cb callba MAS_LOGD("Voice key tap duration : %s", key); xmlFree(key); } + } else if (cur->name && 0 == xmlStrcmp(cur->name, (const xmlChar*)MA_TAG_ASSISTANT_AUDIO_DATA_PROCESSOR)) { + key = xmlNodeGetContent(cur); + if (key) { + temp.audio_data_processing_appid = std::string{reinterpret_cast(key)}; + xmlFree(key); + } } cur = cur->next; diff --git a/src/service_main.cpp b/src/service_main.cpp index 699e0db..a617088 100644 --- a/src/service_main.cpp +++ b/src/service_main.cpp @@ -535,6 +535,9 @@ int CServiceMain::add_assistant_info(ma_assistant_info_s* info) { mClientInfo[index].voice_key_support_mode = info->voice_key_support_mode; MAS_LOGD("voice_key_tap_duration(%f)", info->voice_key_tap_duration); mClientInfo[index].voice_key_tap_duration = info->voice_key_tap_duration; + MAS_LOGD("audio_processing_appid(%s)", + (info->audio_data_processing_appid ? (info->audio_data_processing_appid)->c_str() : "[NONE]")); + mClientInfo[index].audio_processing_appid = info->audio_data_processing_appid; } else { MAS_LOGD("Couldn't find an empty slot for storing assistant info"); } @@ -707,10 +710,10 @@ pid_t CServiceMain::get_current_audio_processing_pid() boost::optional audio_processing_appid = mClientInfo[mCurrentClientInfo].audio_processing_appid; if (audio_processing_appid) { - boost::optional optional_pid_t; - optional_pid_t = mApplicationManager.get_pid_by_appid((*audio_processing_appid).c_str()); - if (optional_pid_t) { - ret = *optional_pid_t; + boost::optional audio_processing_pid; + audio_processing_pid = mApplicationManager.get_pid_by_appid((*audio_processing_appid).c_str()); + if (audio_processing_pid) { + ret = *audio_processing_pid; } } } -- 2.7.4 From 1c8606b56e612839a025c667b9420aac877ddef1 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Tue, 14 Apr 2020 13:57:28 +0900 Subject: [PATCH 06/16] Fix defects detected by static analysis tool Change-Id: Iae05d46900fa3d2a757c0ae914195f7d5855504d --- src/service_config.cpp | 2 +- src/service_ipc_dbus_dispatcher.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/service_config.cpp b/src/service_config.cpp index a86b491..223c27b 100644 --- a/src/service_config.cpp +++ b/src/service_config.cpp @@ -333,7 +333,7 @@ int CServiceConfig::load_custom_wake_words(const char* app_id, *language_end = '\0'; if (0 == strlen(word_start)) break; strncpy(wakeup_word_storage[index], word_start, MAX_WAKEUP_WORD_LEN - 1); - strncpy(wakeup_language_storage[index], language_start, MAX_WAKEUP_WORD_LEN - 1); + strncpy(wakeup_language_storage[index], language_start, MAX_SUPPORTED_LANGUAGE_LEN - 1); word_start = word_end + 1; language_start = language_end + 1; LOGD("Added custom wakeup word : (%s) (%s)", diff --git a/src/service_ipc_dbus_dispatcher.cpp b/src/service_ipc_dbus_dispatcher.cpp index 26e7ac1..e6e74a3 100644 --- a/src/service_ipc_dbus_dispatcher.cpp +++ b/src/service_ipc_dbus_dispatcher.cpp @@ -821,6 +821,7 @@ int CServiceIpcDbusDispatcher::on_remove_wake_word(DBusConnection* conn, DBusMes { if (nullptr == mIpcObserver) { MAS_LOGE("mIpcObserver variable is NULL"); + return -1; } DBusError err; @@ -1025,4 +1026,4 @@ int CServiceIpcDbusDispatcher::on_ui_change_assistant(DBusConnection* conn, DBus MAS_LOGD(" "); return ret; -} \ No newline at end of file +} -- 2.7.4 From 4c58d5a3f651b2fc83bb68b4a15d1fdeaf1090e5 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Tue, 14 Apr 2020 14:25:36 +0900 Subject: [PATCH 07/16] Fix defects detected by static analysis tool Change-Id: I56d36dd519a26f3f04de789a1bd27532549fef6a --- inc/service_main.h | 10 +-- src/service_config.cpp | 2 +- src/service_ipc_dbus_dispatcher.cpp | 126 ++++++++++++++++++++++++------------ src/service_plugin.cpp | 10 ++- 4 files changed, 98 insertions(+), 50 deletions(-) diff --git a/inc/service_main.h b/inc/service_main.h index a6e0c00..94ee073 100644 --- a/inc/service_main.h +++ b/inc/service_main.h @@ -165,17 +165,17 @@ private: std::string mCurrentLanguage{"en_US"}; typedef struct { - bool used; + bool used{false}; char appid[MAX_APPID_LEN]; char wakeup_word[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN]; char wakeup_language[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN]; char wakeup_engine[MAX_APPID_LEN]; char supported_language[MAX_SUPPORTED_LANGUAGES_NUM][MAX_SUPPORTED_LANGUAGE_LEN]; - bool custom_ui_option; - VOICE_KEY_SUPPORT_MODE voice_key_support_mode; - float voice_key_tap_duration; + bool custom_ui_option{false}; + VOICE_KEY_SUPPORT_MODE voice_key_support_mode{VOICE_KEY_SUPPORT_MODE_PUSH_TO_TALK}; + float voice_key_tap_duration{0.0f}; - ma_preprocessing_allow_mode_e preprocessing_allow_mode; + ma_preprocessing_allow_mode_e preprocessing_allow_mode{MA_PREPROCESSING_ALLOW_NONE}; char preprocessing_allow_appid[MAX_APPID_LEN]; } ma_client_info; diff --git a/src/service_config.cpp b/src/service_config.cpp index 223c27b..c3288f3 100644 --- a/src/service_config.cpp +++ b/src/service_config.cpp @@ -272,7 +272,7 @@ int CServiceConfig::remove_custom_wake_word(const char* wake_word, const char* l wakeup_word_storage[shift][MAX_WAKEUP_WORD_LEN - 1] = '\0'; strncpy(wakeup_language_storage[shift], wakeup_language_storage[shift + 1], MAX_SUPPORTED_LANGUAGE_LEN); - wakeup_word_storage[shift][MAX_SUPPORTED_LANGUAGE_LEN - 1] = '\0'; + wakeup_language_storage[shift][MAX_SUPPORTED_LANGUAGE_LEN - 1] = '\0'; } memset(wakeup_word_storage[MAX_WAKEUP_WORDS_NUM - 1], 0x00, sizeof(char) * MAX_WAKEUP_WORD_LEN); diff --git a/src/service_ipc_dbus_dispatcher.cpp b/src/service_ipc_dbus_dispatcher.cpp index e6e74a3..183140b 100644 --- a/src/service_ipc_dbus_dispatcher.cpp +++ b/src/service_ipc_dbus_dispatcher.cpp @@ -57,9 +57,11 @@ int CServiceIpcDbusDispatcher::on_initialize(DBusConnection* conn, DBusMessage* int pid = -1; int ret = 0; - dbus_message_get_args(msg, &err, + if (FALSE == dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID)) { + MAS_LOGE("[ERROR] Failed retrieving arguments"); + } MAS_LOGD("[DEBUG] MAS INITIALIZE"); @@ -113,9 +115,11 @@ int CServiceIpcDbusDispatcher::on_deinitialize(DBusConnection* conn, DBusMessage int pid = -1; int ret = 0; - dbus_message_get_args(msg, &err, + if (FALSE == dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID)) { + MAS_LOGE("[ERROR] Failed retrieving arguments"); + } MAS_LOGD("[DEBUG] MAS DEINITIALIZE"); @@ -170,9 +174,11 @@ int CServiceIpcDbusDispatcher::on_get_audio_format(DBusConnection* conn, DBusMes int rate, channel, audio_type; int ret; - dbus_message_get_args(msg, &err, + if (FALSE == dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID)) { + MAS_LOGE("[ERROR] Failed retrieving arguments"); + } MAS_LOGD("[DEBUG] MAS GET AUDIO FORMAT"); @@ -229,9 +235,11 @@ int CServiceIpcDbusDispatcher::on_get_audio_source_type(DBusConnection* conn, DB std::string type; int ret; - dbus_message_get_args(msg, &err, + if (FALSE == dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID)) { + MAS_LOGE("[ERROR] Failed retrieving arguments"); + } MAS_LOGD("[DEBUG] MAS GET AUDIO SOURCE TYPE"); @@ -296,11 +304,13 @@ int CServiceIpcDbusDispatcher::on_send_asr_result(DBusConnection* conn, DBusMess char *asr_result; int ret = 0; - dbus_message_get_args(msg, &err, + if (FALSE == dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &event, DBUS_TYPE_STRING, &asr_result, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID)) { + MAS_LOGE("[ERROR] Failed retrieving arguments"); + } MAS_LOGD("[DEBUG] MAS SEND ASR RESULT"); @@ -360,12 +370,14 @@ int CServiceIpcDbusDispatcher::on_send_result(DBusConnection* conn, DBusMessage* char* result_json; int ret = 0; - dbus_message_get_args(msg, &err, + if (FALSE == dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_STRING, &display_text, DBUS_TYPE_STRING, &utterance_text, DBUS_TYPE_STRING, &result_json, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID)) { + MAS_LOGE("[ERROR] Failed retrieving arguments"); + } MAS_LOGD("[DEBUG] MAS SEND RESULT"); @@ -425,10 +437,12 @@ int CServiceIpcDbusDispatcher::on_send_recognition_result(DBusConnection* conn, int result; int ret = 0; - dbus_message_get_args(msg, &err, + if (FALSE == dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID)) { + MAS_LOGE("[ERROR] Failed retrieving arguments"); + } MAS_LOGD("[DEBUG] MAS SEND RECOGNITION RESULT"); @@ -461,10 +475,12 @@ int CServiceIpcDbusDispatcher::on_start_streaming_audio_data(DBusConnection* con int type; int ret = 0; - dbus_message_get_args(msg, &err, + if (FALSE == dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &type, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID)) { + MAS_LOGE("[ERROR] Failed retrieving arguments"); + } MAS_LOGD("[DEBUG] MAS SEND START STREAMING"); @@ -497,10 +513,12 @@ int CServiceIpcDbusDispatcher::on_stop_streaming_audio_data(DBusConnection* conn int type; int ret = 0; - dbus_message_get_args(msg, &err, + if (FALSE == dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &type, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID)) { + MAS_LOGE("[ERROR] Failed retrieving arguments"); + } MAS_LOGD("[DEBUG] MAS SEND STOP STREAMING"); @@ -533,10 +551,12 @@ int CServiceIpcDbusDispatcher::on_update_voice_feedback_state(DBusConnection* co int state; int ret = 0; - dbus_message_get_args(msg, &err, + if (FALSE == dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &state, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID)) { + MAS_LOGE("[ERROR] Failed retrieving arguments"); + } MAS_LOGD("[DEBUG] MAS SEND UPDATE VOICE FEEDBACK"); @@ -569,10 +589,12 @@ int CServiceIpcDbusDispatcher::on_send_assistant_specific_command(DBusConnection int ret = 0; char* command; - dbus_message_get_args(msg, &err, + if (FALSE == dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_STRING, &command, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID)) { + MAS_LOGE("[ERROR] Failed retrieving arguments"); + } MAS_LOGD("[DEBUG] MAS SEND ASSISTANT SPECIFIC COMMAND"); @@ -606,10 +628,12 @@ int CServiceIpcDbusDispatcher::on_set_background_volume(DBusConnection* conn, DB int ret = 0; double ratio; - dbus_message_get_args(msg, &err, + if (FALSE == dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_DOUBLE, &ratio, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID)) { + MAS_LOGE("[ERROR] Failed retrieving arguments"); + } MAS_LOGD("[DEBUG] MAS SET BACKGROUND VOLUME"); @@ -643,11 +667,13 @@ int CServiceIpcDbusDispatcher::on_set_preprocessing_allow_mode(DBusConnection* c int mode; char* app_id; - dbus_message_get_args(msg, &err, + if (FALSE == dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &mode, DBUS_TYPE_STRING, &app_id, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID)) { + MAS_LOGE("[ERROR] Failed retrieving arguments"); + } MAS_LOGD("[DEBUG] MAS SET PREPROCESSING ALLOW MODE"); @@ -682,10 +708,12 @@ int CServiceIpcDbusDispatcher::on_send_preprocessing_result(DBusConnection* conn int ret = 0; int result; - dbus_message_get_args(msg, &err, + if (FALSE == dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID)) { + MAS_LOGE("[ERROR] Failed retrieving arguments"); + } MAS_LOGD("[DEBUG] MAS SEND PREPROCESSING RESULT"); @@ -718,10 +746,12 @@ int CServiceIpcDbusDispatcher::on_set_wake_word_audio_require_flag(DBusConnectio int ret = 0; int require; - dbus_message_get_args(msg, &err, + if (FALSE == dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &require, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID)) { + MAS_LOGE("[ERROR] Failed retrieving arguments"); + } MAS_LOGD("[DEBUG] MAS SET WAKE WORD AUDIO REQUIRE FLAG"); @@ -754,10 +784,12 @@ int CServiceIpcDbusDispatcher::on_set_assistant_language(DBusConnection* conn, D int ret = 0; char* language; - dbus_message_get_args(msg, &err, + if (FALSE == dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_STRING, &language, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID)) { + MAS_LOGE("[ERROR] Failed retrieving arguments"); + } MAS_LOGD("[DEBUG] MAS SET ASSISTANT LANGUAGE"); @@ -792,11 +824,13 @@ int CServiceIpcDbusDispatcher::on_add_wake_word(DBusConnection* conn, DBusMessag char* wake_word; char* language; - dbus_message_get_args(msg, &err, + if (FALSE == dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_STRING, &wake_word, DBUS_TYPE_STRING, &language, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID)) { + MAS_LOGE("[ERROR] Failed retrieving arguments"); + } MAS_LOGD("[DEBUG] MAS ADD WAKE WORD"); @@ -832,11 +866,13 @@ int CServiceIpcDbusDispatcher::on_remove_wake_word(DBusConnection* conn, DBusMes char* wake_word; char* language; - dbus_message_get_args(msg, &err, + if (FALSE == dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_STRING, &wake_word, DBUS_TYPE_STRING, &language, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID)) { + MAS_LOGE("[ERROR] Failed retrieving arguments"); + } MAS_LOGD("[DEBUG] MAS REMOVE WAKE WORD"); @@ -870,9 +906,11 @@ int CServiceIpcDbusDispatcher::on_ui_initialize(DBusConnection* conn, DBusMessag int pid = -1; int ret = 0; - dbus_message_get_args(msg, &err, + if (FALSE == dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID)) { + MAS_LOGE("[ERROR] Failed retrieving arguments"); + } MAS_LOGD("[DEBUG] MAS UI INITIALIZE"); @@ -926,9 +964,11 @@ int CServiceIpcDbusDispatcher::on_ui_deinitialize(DBusConnection* conn, DBusMess int pid = -1; int ret = 0; - dbus_message_get_args(msg, &err, + if (FALSE == dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID)) { + MAS_LOGE("[ERROR] Failed retrieving arguments"); + } MAS_LOGD("[DEBUG] MAS UI DEINITIALIZE"); @@ -982,9 +1022,11 @@ int CServiceIpcDbusDispatcher::on_ui_change_assistant(DBusConnection* conn, DBus char *app_id; int ret = 0; - dbus_message_get_args(msg, &err, + if (FALSE == dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &app_id, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID)) { + MAS_LOGE("[ERROR] Failed retrieving arguments"); + } MAS_LOGD("[DEBUG] MAS UI CHANGE ASSISTANT : %s", (app_id ? app_id : "NULL")); diff --git a/src/service_plugin.cpp b/src/service_plugin.cpp index f12323e..eb02cf4 100644 --- a/src/service_plugin.cpp +++ b/src/service_plugin.cpp @@ -501,9 +501,15 @@ int CServicePlugin::initialize(void) snprintf(filepath, 512, "%s/%s", default_engine_path, MA_DEFAULT_WAKEUP_MANAGER_FILENAME); char *error; - mPluginHandle = NULL; + mPluginHandle = nullptr; mPluginHandle = dlopen(filepath, RTLD_LAZY); - if (NULL != (error = dlerror())) { + if (nullptr != (error = dlerror())) { + MAS_LOGE("[ERROR] Fail to dlopen(%s), error(%s)", filepath, error); + if (mPluginHandle) dlclose(mPluginHandle); + mPluginHandle = nullptr; + return -1; //MAS_ERROR_OPERATION_FAILED; + } + if (nullptr == mPluginHandle) { MAS_LOGE("[ERROR] Fail to dlopen(%s), error(%s)", filepath, error); return -1; //MAS_ERROR_OPERATION_FAILED; } -- 2.7.4 From 8a52439631006f3512f50bb26edd566514ecf0ca Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Tue, 21 Apr 2020 17:54:56 +0900 Subject: [PATCH 09/16] Change license directory Change-Id: I0abb0724f1ec9b28a62c0e6cf62ce0ed2ca123b3 Signed-off-by: Jihoon Kim --- CMakeLists.txt | 1 - packaging/org.tizen.multi-assistant-service.spec | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bd511e..bc07553 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,7 +79,6 @@ SET(SRCS ) ADD_EXECUTABLE(${BINNAME} ${SRCS}) -INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE.Flora DESTINATION /usr/share/license/) INSTALL(FILES ${CMAKE_SOURCE_DIR}/${PKGNAME}.xml DESTINATION /usr/share/packages) INSTALL(TARGETS ${BINNAME} DESTINATION ${BINDIR}) diff --git a/packaging/org.tizen.multi-assistant-service.spec b/packaging/org.tizen.multi-assistant-service.spec index 63bca4f..a6b98e2 100644 --- a/packaging/org.tizen.multi-assistant-service.spec +++ b/packaging/org.tizen.multi-assistant-service.spec @@ -72,8 +72,6 @@ make %{?jobs:-j%jobs} %install rm -rf %{buildroot} -mkdir -p %{buildroot}%{TZ_SYS_RO_SHARE}/license -cp LICENSE.Flora %{buildroot}%{TZ_SYS_RO_SHARE}/license/%{name} %make_install @@ -98,7 +96,6 @@ exit 0 %files %manifest %{name}.manifest %defattr(-,root,root,-) -/usr/share/license/* /usr/share/packages/org.tizen.multi-assistant-service.xml %{TZ_SYS_RO_SHARE}/multiassistant/libma-wakeup-manager.so %{TZ_SYS_RO_SHARE}/multiassistant/libma-dependency-default.so @@ -106,3 +103,4 @@ exit 0 %{_appdir}/bin/* #%defattr(-,app,app,-) #%{_appbindir}/org.tizen.multi-assistant-service +%license LICENSE.Flora -- 2.7.4 From ac786ddad1e810fbc17cb0a540c3a44f87f089f9 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Tue, 21 Apr 2020 18:37:10 +0900 Subject: [PATCH 10/16] Bump version to 0.2.31 Change-Id: I9950af024b4aaa2580c0e83903a0b3ac3a570662 --- org.tizen.multi-assistant-service.xml | 2 +- packaging/org.tizen.multi-assistant-service.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/org.tizen.multi-assistant-service.xml b/org.tizen.multi-assistant-service.xml index 0476cfd..418edad 100644 --- a/org.tizen.multi-assistant-service.xml +++ b/org.tizen.multi-assistant-service.xml @@ -1,5 +1,5 @@ - + Won Nam Jang Sooyeon Kim diff --git a/packaging/org.tizen.multi-assistant-service.spec b/packaging/org.tizen.multi-assistant-service.spec index 63bca4f..2d5cc56 100644 --- a/packaging/org.tizen.multi-assistant-service.spec +++ b/packaging/org.tizen.multi-assistant-service.spec @@ -1,6 +1,6 @@ Name: org.tizen.multi-assistant-service Summary: Multi assistant service -Version: 0.2.30 +Version: 0.2.31 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Flora-1.1 -- 2.7.4 From b6dc500982c7c622b42e3bf7d50003102d4c79b3 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Thu, 23 Apr 2020 14:31:41 +0900 Subject: [PATCH 11/16] Bump version to 0.2.31 Change-Id: Ibcad830b4803e93185d1265c14a3cae19bfd238c --- org.tizen.multi-assistant-service.xml | 2 +- packaging/org.tizen.multi-assistant-service.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/org.tizen.multi-assistant-service.xml b/org.tizen.multi-assistant-service.xml index 0476cfd..418edad 100644 --- a/org.tizen.multi-assistant-service.xml +++ b/org.tizen.multi-assistant-service.xml @@ -1,5 +1,5 @@ - + Won Nam Jang Sooyeon Kim diff --git a/packaging/org.tizen.multi-assistant-service.spec b/packaging/org.tizen.multi-assistant-service.spec index ad13329..6ce5be6 100644 --- a/packaging/org.tizen.multi-assistant-service.spec +++ b/packaging/org.tizen.multi-assistant-service.spec @@ -1,6 +1,6 @@ Name: org.tizen.multi-assistant-service Summary: Multi assistant service -Version: 0.2.30 +Version: 0.2.31 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Flora-1.1 -- 2.7.4 From bd3abae518be6854e29e450ee9362a393538c800 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Tue, 21 Apr 2020 18:37:02 +0900 Subject: [PATCH 12/16] Remove unnecessary extern C declaration Change-Id: I08407fe374f046ffccafa043cefe924868dd898d --- inc/application_manager.h | 8 -------- inc/application_manager_aul.h | 8 -------- inc/client_manager.h | 8 -------- inc/preference_manager.h | 8 -------- inc/preference_manager_vconf.h | 8 -------- inc/service_config.h | 9 --------- inc/service_ipc_dbus.h | 8 -------- inc/service_ipc_dbus_dispatcher.h | 9 --------- inc/service_main.h | 8 -------- inc/service_plugin.h | 8 -------- inc/service_plugin_interface.h | 8 -------- plugins/wakeup-manager/inc/wakeup_manager_main.h | 9 --------- 12 files changed, 99 deletions(-) diff --git a/inc/application_manager.h b/inc/application_manager.h index 05bdcca..07802b3 100644 --- a/inc/application_manager.h +++ b/inc/application_manager.h @@ -21,10 +21,6 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif - class IApplicationManager { public: virtual bool is_application_running(pid_t pid) = 0; @@ -35,8 +31,4 @@ public: virtual boost::optional get_pid_by_appid(const std::string& appid) = 0; }; -#ifdef __cplusplus -} -#endif - #endif /* __APPLICATION_MANAGER_H__ */ diff --git a/inc/application_manager_aul.h b/inc/application_manager_aul.h index ddf2f26..c07836c 100644 --- a/inc/application_manager_aul.h +++ b/inc/application_manager_aul.h @@ -20,10 +20,6 @@ #include "application_manager.h" -#ifdef __cplusplus -extern "C" { -#endif - class CApplicationManagerAul : public IApplicationManager { public: CApplicationManagerAul(); @@ -37,8 +33,4 @@ public: boost::optional get_pid_by_appid(const std::string& appid) override; }; -#ifdef __cplusplus -} -#endif - #endif /* __APPLICATION_MANAGER_AUL_H__ */ diff --git a/inc/client_manager.h b/inc/client_manager.h index 0ecad4e..94712a1 100644 --- a/inc/client_manager.h +++ b/inc/client_manager.h @@ -23,10 +23,6 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif - typedef struct { pid_t pid; std::string appid; @@ -60,8 +56,4 @@ private: GSList* mClientList{nullptr}; }; -#ifdef __cplusplus -} -#endif - #endif /* __CLIENT_MANAGER_H__ */ diff --git a/inc/preference_manager.h b/inc/preference_manager.h index 79d3734..7da3d7a 100644 --- a/inc/preference_manager.h +++ b/inc/preference_manager.h @@ -21,10 +21,6 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif - typedef void (*preference_changed_cb)(std::string key, void* user_data); class IPreferenceManager { @@ -39,8 +35,4 @@ public: const std::string& key, preference_changed_cb callback) = 0; }; -#ifdef __cplusplus -} -#endif - #endif /* __PREFERENCE_MANAGER_H__ */ diff --git a/inc/preference_manager_vconf.h b/inc/preference_manager_vconf.h index 7af61cb..02d7e94 100644 --- a/inc/preference_manager_vconf.h +++ b/inc/preference_manager_vconf.h @@ -24,10 +24,6 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif - typedef std::tuple CallbackEntry; class CPreferenceManagerVconf : public IPreferenceManager { @@ -52,8 +48,4 @@ private: std::map> mCallbackEntries; }; -#ifdef __cplusplus -} -#endif - #endif /* __PREFERENCE_MANAGER_VCONF_H__ */ diff --git a/inc/service_config.h b/inc/service_config.h index bbc7a40..6ce7607 100644 --- a/inc/service_config.h +++ b/inc/service_config.h @@ -26,11 +26,6 @@ #include #include -#ifdef __cplusplus -extern "C" -{ -#endif - /************************************************************************************** *** Definitions for xml file *************************************************************************************/ @@ -124,10 +119,6 @@ private: const char *path, void* user_data); }; -#ifdef __cplusplus -} -#endif - /** * @} */ diff --git a/inc/service_ipc_dbus.h b/inc/service_ipc_dbus.h index abe1990..1089091 100644 --- a/inc/service_ipc_dbus.h +++ b/inc/service_ipc_dbus.h @@ -17,10 +17,6 @@ #ifndef __SERVICE_IPC_DBUS_H__ #define __SERVICE_IPC_DBUS_H__ -#ifdef __cplusplus -extern "C" { -#endif - #include #include @@ -85,8 +81,4 @@ private: IApplicationManager* mApplicationManager{nullptr}; }; -#ifdef __cplusplus -} -#endif - #endif /* __SERVICE_IPC_DBUS_H__ */ diff --git a/inc/service_ipc_dbus_dispatcher.h b/inc/service_ipc_dbus_dispatcher.h index 9a88a99..9d2250b 100644 --- a/inc/service_ipc_dbus_dispatcher.h +++ b/inc/service_ipc_dbus_dispatcher.h @@ -21,10 +21,6 @@ #include -#ifdef __cplusplus -extern "C" { -#endif - class CServiceMain; class IServiceIpcObserver { @@ -87,9 +83,4 @@ private: IServiceIpcObserver *mIpcObserver{nullptr}; }; -#ifdef __cplusplus -} -#endif - - #endif /* __SERVICE_IPC_DBUS_DISPATCHER_H__ */ diff --git a/inc/service_main.h b/inc/service_main.h index 047ee50..414a3b9 100644 --- a/inc/service_main.h +++ b/inc/service_main.h @@ -34,10 +34,6 @@ #include "application_manager.h" #include "preference_manager.h" -#ifdef __cplusplus -extern "C" { -#endif - typedef enum { CLIENT_LAUNCH_MODE_ACTIVATION, CLIENT_LAUNCH_MODE_PRELAUNCH, @@ -204,8 +200,4 @@ private: IPreferenceManager& mPreferenceManager; }; -#ifdef __cplusplus -} -#endif - #endif /* __SERVICE_MAIN_H__ */ diff --git a/inc/service_plugin.h b/inc/service_plugin.h index 35a5e12..a3ed804 100644 --- a/inc/service_plugin.h +++ b/inc/service_plugin.h @@ -24,10 +24,6 @@ #include "service_ipc_dbus.h" #include "service_plugin_interface.h" -#ifdef __cplusplus -extern "C" { -#endif - class CServiceMain; class CServicePlugin { @@ -102,8 +98,4 @@ private: CServiceMain* mServiceMain{nullptr}; }; -#ifdef __cplusplus -} -#endif - #endif /* __SERVICE_PLUGIN_H__ */ diff --git a/inc/service_plugin_interface.h b/inc/service_plugin_interface.h index 669d1c4..944a967 100644 --- a/inc/service_plugin_interface.h +++ b/inc/service_plugin_interface.h @@ -20,10 +20,6 @@ #include -#ifdef __cplusplus -extern "C" { -#endif - typedef struct { int plugin_version; bool ui_panel_enabled; @@ -160,8 +156,4 @@ typedef struct { wakeup_manager_set_voice_key_status_changed_callback set_voice_key_status_changed_callback; } wakeup_manager_interface; -#ifdef __cplusplus -} -#endif - #endif /* __SERVICE_PLUGIN_INTERFACE_H__ */ diff --git a/plugins/wakeup-manager/inc/wakeup_manager_main.h b/plugins/wakeup-manager/inc/wakeup_manager_main.h index 0a654c8..d0b8b30 100644 --- a/plugins/wakeup-manager/inc/wakeup_manager_main.h +++ b/plugins/wakeup-manager/inc/wakeup_manager_main.h @@ -4,11 +4,6 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif - - #ifdef LOG_TAG #undef LOG_TAG #endif @@ -39,8 +34,4 @@ extern "C" { #define MWR_SLOGW(fmt, args...) MWR_SECURE_LOG_(DLOG_WARN, LOG_TAG, fmt, ##args) #define MWR_SLOGE(fmt, args...) MWR_SECURE_LOG_(DLOG_ERROR, LOG_TAG, fmt, ##args) -#ifdef __cplusplus -} -#endif - #endif /* __MUTLI_WAKEUP_MAIN_H__ */ -- 2.7.4 From 1a68751db49f33f084ef3c7d04ac662aed24785e Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Wed, 6 May 2020 09:22:21 +0900 Subject: [PATCH 13/16] Fix defects detected by static analysis tool Change-Id: Ica75005bc4f2e43c1d02f6744cd6594adbaafe9c --- plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp b/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp index b2395e5..6e30433 100644 --- a/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp +++ b/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp @@ -744,6 +744,7 @@ int wakeup_manager_wakeup_assistant(const mas_wakeup_event_info* wakeup_info) if (nullptr == g_wakeup_manager) return -1; CWakeupPolicy* policy = g_wakeup_manager->get_wakeup_policy(); if (policy) policy->select_candidate(*wakeup_info); + return 0; } void CWakeupEventObserver::on_wakeup(mas_wakeup_event_info wakeup_info) -- 2.7.4 From 32c8acce0dccfbf1e5a1bf2667c42635b1edd584 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Wed, 20 May 2020 18:15:38 +0900 Subject: [PATCH 14/16] Add logs for checking initialization process Change-Id: I9647f91f1d8caf5215d1cde0849c538c80b3b2d6 --- src/main.cpp | 3 +++ src/service_main.cpp | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index c7e4dae..33129a9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,11 +27,13 @@ CServiceMain g_service_main{g_application_manager_aul, g_preference_manager_vcon static bool service_app_create(void *data) { + LOGI(""); return g_service_main.app_create(data); } static void service_app_terminate(void *data) { + LOGI(""); return g_service_main.app_terminate(data); } @@ -64,6 +66,7 @@ static void service_app_low_memory(app_event_info_h event_info, void *user_data) int main(int argc, char* argv[]) { + LOGI("Main function starts"); char ad[50] = {0, }; service_app_lifecycle_callback_s event_callback; app_event_handler_h handlers[5] = {NULL, }; diff --git a/src/service_main.cpp b/src/service_main.cpp index a617088..966c336 100644 --- a/src/service_main.cpp +++ b/src/service_main.cpp @@ -1312,7 +1312,7 @@ static void _package_manager_event_cb(const char *type, const char *package, pac bool CServiceMain::app_create(void *data) { // Todo: add your code here. - MAS_LOGD("[Enter] Service app create"); + MAS_LOGI("[Enter] Service app create"); g_service_main = this; @@ -1359,6 +1359,7 @@ bool CServiceMain::app_create(void *data) } } + MAS_LOGI("[END]"); return true; } -- 2.7.4 From 534d5769bfa1346f76a3041eda3fd6f3d8bcebcc Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Mon, 25 May 2020 21:49:30 +0900 Subject: [PATCH 15/16] Add NULL check when prelaunching default assistant Change-Id: Id8d6fa2323000101f4edd8ce33ab99d1bb8cae29 --- src/service_main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/service_main.cpp b/src/service_main.cpp index 966c336..4dda21b 100644 --- a/src/service_main.cpp +++ b/src/service_main.cpp @@ -950,7 +950,8 @@ int CServiceMain::prelaunch_default_assistant() if (prelaunch_mode && *prelaunch_mode) { const char *default_assistant = NULL; if (0 == mServicePlugin.get_default_assistant(&default_assistant)) { - if (!(mApplicationManager.is_application_running(default_assistant))) { + if (default_assistant && + !(mApplicationManager.is_application_running(default_assistant))) { MAS_LOGD("prelaunching default_assistant_appid : %s", default_assistant); launch_client_by_appid(default_assistant, CLIENT_LAUNCH_MODE_PRELAUNCH); } -- 2.7.4 From 6b0de0db125800e4958f95b863452b1a0e914389 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Mon, 25 May 2020 21:50:03 +0900 Subject: [PATCH 16/16] Bump version to 0.2.32 Change-Id: I6ffb0f3d69404b37a450e6c51d0cad1351acb73d --- org.tizen.multi-assistant-service.xml | 2 +- packaging/org.tizen.multi-assistant-service.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/org.tizen.multi-assistant-service.xml b/org.tizen.multi-assistant-service.xml index 418edad..7c451d8 100644 --- a/org.tizen.multi-assistant-service.xml +++ b/org.tizen.multi-assistant-service.xml @@ -1,5 +1,5 @@ - + Won Nam Jang Sooyeon Kim diff --git a/packaging/org.tizen.multi-assistant-service.spec b/packaging/org.tizen.multi-assistant-service.spec index 89704e5..68165fa 100644 --- a/packaging/org.tizen.multi-assistant-service.spec +++ b/packaging/org.tizen.multi-assistant-service.spec @@ -1,6 +1,6 @@ Name: org.tizen.multi-assistant-service Summary: Multi assistant service -Version: 0.2.31 +Version: 0.2.32 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Flora-1.1 -- 2.7.4