From e25f66ccc1de6a5158d0774ee4ff6d1c8936df54 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Wed, 10 Nov 2021 23:59:06 +0900 Subject: [PATCH 01/16] Add audio data transmission mileage in thread safe way Change-Id: I6de9199e4c70ec3f04682a52add02a2164e2eb5c --- src/service_ipc_dbus.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/service_ipc_dbus.cpp b/src/service_ipc_dbus.cpp index a832279..d9038a5 100644 --- a/src/service_ipc_dbus.cpp +++ b/src/service_ipc_dbus.cpp @@ -20,12 +20,13 @@ #include #include +#include #include "service_common.h" #include "service_main.h" #include "service_ipc_dbus.h" -size_t gAudioDataMileage{0}; +std::atomic_size_t gAudioDataMileage{0}; int CServiceIpcDbus::reconnect() { @@ -269,6 +270,7 @@ int CServiceIpcDbus::send_streaming_audio_data(pid_t pid, int event, void* data, MAS_LOGE("Buffer overflow : %zu %zu", new_size, total_size); return -1; } + gAudioDataMileage.fetch_add(data_size); const long long minimum_flush_interval = 20; static long long last_flush_time = get_current_milliseconds_after_epoch(); @@ -278,7 +280,7 @@ int CServiceIpcDbus::send_streaming_audio_data(pid_t pid, int event, void* data, if (0 == header.streaming_data_serial % 50 || MAS_SPEECH_STREAMING_EVENT_CONTINUE != event) { last_serial_waiting_for_flush = header.streaming_data_serial; MAS_LOGE("queueing streaming data, serial : %d %d %zu", - last_serial_waiting_for_flush, event, gAudioDataMileage); + last_serial_waiting_for_flush, event, gAudioDataMileage.load()); } if (pending_buffer_size + total_size > STREAMING_BUFFER_SIZE || MAS_SPEECH_STREAMING_EVENT_FINISH == event || @@ -308,13 +310,13 @@ int CServiceIpcDbus::send_streaming_audio_data(pid_t pid, int event, void* data, if (-1 != last_serial_waiting_for_flush) { MAS_LOGE("flushing streaming data, serial : %d %zu", - last_serial_waiting_for_flush, gAudioDataMileage); + last_serial_waiting_for_flush, gAudioDataMileage.load()); last_serial_waiting_for_flush = -1; } } if (MAS_SPEECH_STREAMING_EVENT_FINISH == event) { - MAS_LOGE("Sending FINISH event : %zu", gAudioDataMileage); + MAS_LOGE("Sending FINISH event : %zu", gAudioDataMileage.load()); bundle *b = bundle_create(); if (b) { bundle_add_byte(b, "content", buffer, total_size); @@ -1158,7 +1160,7 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle } else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_START_STREAMING_AUDIO_DATA)) { /* Reset mileage data for logging */ - gAudioDataMileage = 0; + gAudioDataMileage.store(0); dispatcher->on_start_streaming_audio_data(mConnectionListener, msg); } else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_STOP_STREAMING_AUDIO_DATA)) { -- 2.7.4 From d15c470485ca39d5178b3dc2f8fca53f5f2dca77 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Wed, 17 Nov 2021 14:48:44 +0900 Subject: [PATCH 02/16] Fix build error in 64bit profile Change-Id: Iaf71b5f63c361b1942fc9b418720b9fa47aa354d --- src/service_ipc_dbus.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/service_ipc_dbus.cpp b/src/service_ipc_dbus.cpp index d9038a5..04ba438 100644 --- a/src/service_ipc_dbus.cpp +++ b/src/service_ipc_dbus.cpp @@ -1084,8 +1084,9 @@ static void print_duration(int num_messages, std::chrono::time_point threshold) { - MAS_LOGE("DBus messages processed : %d, %lld", num_messages, + long long int count = static_cast( std::chrono::duration_cast(interval).count()); + MAS_LOGE("DBus messages processed : %d, %lld", num_messages, count); } } -- 2.7.4 From ed03355afa30399bc57655965401ee868325d415 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Fri, 10 Dec 2021 15:49:57 +0900 Subject: [PATCH 03/16] Handle default assistant change event in UTTERANCE state Previously, if default assistant gets changed in UTTERANCE state, the state doesn't get reset. Modified to generate recognition result ERROR event in this case. Change-Id: Ie9a58cdf8220d5f4d92ac19e79394b7e5145470c --- plugins/wakeup-manager/src/wakeup_manager.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/wakeup-manager/src/wakeup_manager.cpp b/plugins/wakeup-manager/src/wakeup_manager.cpp index 31eb2b9..00035cd 100644 --- a/plugins/wakeup-manager/src/wakeup_manager.cpp +++ b/plugins/wakeup-manager/src/wakeup_manager.cpp @@ -312,6 +312,13 @@ bool CWakeupManager::set_default_assistant(string appid) { MWR_LOGE("[ENTER] %s", appid.c_str()); + if (mWakeupManagerState == WAKEUP_MANAGER_STATE_UTTERANCE || + mWakeupManagerState == WAKEUP_MANAGER_STATE_PROCESSING) { + if (mCurrentDefaultAssistant.compare(appid) != 0) { + update_recognition_result(mCurrentDefaultAssistant, MA_RECOGNITION_RESULT_EVENT_ERROR); + } + } + /* Check if previous default assistant has to be deactivated */ bool activated = true; if (false == mAssistantSupportsCurrentLanguage[mCurrentDefaultAssistant]) { -- 2.7.4 From 845d86b1106987415a190f3ebd17177ea0167b0d Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Fri, 10 Dec 2021 16:10:27 +0900 Subject: [PATCH 04/16] Bump version to 0.3.27 Change-Id: I2dad772ca17773518574818eafb4a96d3b7dd54e --- 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 1a2bee4..81636e0 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 61bffe2..3343c70 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.3.26 +Version: 0.3.27 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Flora-1.1 -- 2.7.4 From af535efef86666ebf9bab2428ed0a267a3e7aaf5 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Fri, 26 Nov 2021 12:27:16 +0900 Subject: [PATCH 05/16] Print memory usage Change-Id: I95f908f82e9d8a33b24a8710be109d99bfa6c976 --- .../wakeup-manager/src/wakeup_audio_manager.cpp | 56 ++++++++++++++++++---- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/plugins/wakeup-manager/src/wakeup_audio_manager.cpp b/plugins/wakeup-manager/src/wakeup_audio_manager.cpp index 81ec9fa..b05fcc8 100644 --- a/plugins/wakeup-manager/src/wakeup_audio_manager.cpp +++ b/plugins/wakeup-manager/src/wakeup_audio_manager.cpp @@ -1,8 +1,13 @@ +#define _GNU_SOURCE + #include "wakeup_audio_manager.h" #include "wakeup_manager_main.h" #include "dependency_resolver.h" #include "heap_tracer.h" +#include +#include + #include #include @@ -358,24 +363,57 @@ void CAudioManager::add_audio_data(mas_speech_data& data, long long time) { long long delta = mAudioRecordingDurationMilliseconds; - notify_audio_data_recording(time, data.buffer, data.len); - - mas_speech_data_with_time data_with_time; - data_with_time.data = data; - data_with_time.time = time; - + bool print_log = false; static unsigned int num = 0; const std::chrono::seconds interval(3); static auto last = std::chrono::steady_clock::now(); auto now = std::chrono::steady_clock::now(); + + struct rusage process_usage_before; + struct rusage thread_usage_before; + if (now - last > interval) { - MWR_LOGE("Feeding audio data : num(%d), now(%" PRId64 "), %d %zu", - num, now.time_since_epoch().count(), - mStreamingThreadActive.load(), mAudioData.size()); + print_log = true; last = now; + getrusage(RUSAGE_SELF, &process_usage_before); + getrusage(RUSAGE_THREAD, &thread_usage_before); } num++; + notify_audio_data_recording(time, data.buffer, data.len); + + if (print_log) { + struct rusage process_usage_after; + struct rusage thread_usage_after; + + getrusage(RUSAGE_SELF, &process_usage_after); + getrusage(RUSAGE_THREAD, &thread_usage_after); + + MWR_LOGE("Feeding audio data : num(%d), now(%" PRId64 "), %d %zu ([%ld,%ld,%ld,%ld] -> [%ld,%ld,%ld,%ld]) ([%ld,%ld,%ld,%ld] -> [%ld,%ld,%ld,%ld])", + num, now.time_since_epoch().count(), + mStreamingThreadActive.load(), mAudioData.size(), + process_usage_before.ru_maxrss, + process_usage_before.ru_ixrss, + process_usage_before.ru_idrss, + process_usage_before.ru_isrss, + process_usage_after.ru_maxrss, + process_usage_after.ru_ixrss, + process_usage_after.ru_idrss, + process_usage_after.ru_isrss, + thread_usage_before.ru_maxrss, + thread_usage_before.ru_ixrss, + thread_usage_before.ru_idrss, + thread_usage_before.ru_isrss, + thread_usage_after.ru_maxrss, + thread_usage_after.ru_ixrss, + thread_usage_after.ru_idrss, + thread_usage_after.ru_isrss); + } + + mas_speech_data_with_time data_with_time; + data_with_time.data = data; + data_with_time.time = time; + lock_guard lock(mMutex); /* Pop items only when the streaming is not activated */ -- 2.7.4 From dc56f7c4ae5646a1a73b801147f9f1bc94f98ab5 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Fri, 18 Feb 2022 11:29:58 +0900 Subject: [PATCH 06/16] Change default streaming timeout value to 15 seconds Change-Id: Id5de962d01300918ef7032b1e365053eb5f27c0c --- plugins/wakeup-manager/inc/wakeup_settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/wakeup-manager/inc/wakeup_settings.h b/plugins/wakeup-manager/inc/wakeup_settings.h index 4e2caef..d69d71a 100644 --- a/plugins/wakeup-manager/inc/wakeup_settings.h +++ b/plugins/wakeup-manager/inc/wakeup_settings.h @@ -84,7 +84,7 @@ private: vector mEnabledAssistants; float mWakeupPolicyDelay{0.0}; vector mWakeupPolicyPriority; // No priority by default - float mStreamingDurationMax{10.0}; + float mStreamingDurationMax{15.0}; string mVoiceInputLanguage; }; -- 2.7.4 From 54a1ff16fbc8d4ae5c0fa6cedc7ffb45123e45f3 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Fri, 18 Feb 2022 11:34:15 +0900 Subject: [PATCH 07/16] Bump version to 0.3.28 Change-Id: I0769d4d1a80e5527c5c342dc7551ad0d5537e55b --- 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 81636e0..2ce203c 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 3343c70..f030c41 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.3.27 +Version: 0.3.28 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Flora-1.1 -- 2.7.4 From 3a28fff6215ac07f279a994e3c9000b6b63dd47a Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Wed, 13 Apr 2022 14:53:02 +0900 Subject: [PATCH 08/16] Ignore voice key press event during follow-up speech session Change-Id: Ia48da94500eb9e084fe17431e0b54fe43b9f89f7 --- plugins/wakeup-manager/src/wakeup_manager.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/wakeup-manager/src/wakeup_manager.cpp b/plugins/wakeup-manager/src/wakeup_manager.cpp index 00035cd..4d61d87 100644 --- a/plugins/wakeup-manager/src/wakeup_manager.cpp +++ b/plugins/wakeup-manager/src/wakeup_manager.cpp @@ -531,8 +531,12 @@ bool CWakeupManager::process_plugin_event(mas_plugin_event_e event, void* data, boost::optional next_voice_key_status; if (MAS_PLUGIN_EVENT_VOICE_KEY_PRESSED == event) { - if (VOICE_KEY_SUPPORT_MODE_NONE != mCurrentVoiceKeySupportMode) { - start_recording = true; + if (STREAMING_MODE::FOLLOW_UP == mStreamingMode) { + MWR_LOGE("Voice key pressed, but currently streaming follow_up audio"); + } else { + if (VOICE_KEY_SUPPORT_MODE_NONE != mCurrentVoiceKeySupportMode) { + start_recording = true; + } } next_voice_key_status = MA_VOICE_KEY_STATUS_PRESSED; } else if (MAS_PLUGIN_EVENT_VOICE_KEY_RELEASED_AFTER_PUSH == event) { -- 2.7.4 From 9784165c10f61fd5cd589427057909da683b1c1d Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Wed, 16 Mar 2022 13:41:20 +0900 Subject: [PATCH 09/16] Call stop_recording on stop streaming request in UTTERANCE mode Change-Id: Iea8789ee57a7cb6d64b1e8a47a5735f104e19155 --- plugins/wakeup-manager/src/wakeup_manager.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/plugins/wakeup-manager/src/wakeup_manager.cpp b/plugins/wakeup-manager/src/wakeup_manager.cpp index 4d61d87..fdc1c4e 100644 --- a/plugins/wakeup-manager/src/wakeup_manager.cpp +++ b/plugins/wakeup-manager/src/wakeup_manager.cpp @@ -651,14 +651,18 @@ static Eina_Bool streaming_duration_expired(void *data) audio_manager->stop_streaming_follow_up_data(); audio_manager->stop_recording(true); audio_manager->clear_audio_data(); - audio_manager->set_recording_session(RECORDING_SESSION_WAKE_WORD); - audio_manager->start_recording(true); break; } wakeup_manager->set_streaming_mode(STREAMING_MODE::NONE); if (WAKEUP_MANAGER_STATE_UTTERANCE == wakeup_manager->get_manager_state()) { + audio_manager->stop_recording(true); + audio_manager->set_recording_session(RECORDING_SESSION_WAKE_WORD); + if (engine_manager->get_audio_data_required()) { + /* Restart recorder thread using appropriate recording device */ + audio_manager->start_recording(true); + } wakeup_manager->change_manager_state(WAKEUP_MANAGER_STATE_PROCESSING); } @@ -705,7 +709,12 @@ bool CWakeupManager::stop_streaming_utterance_data() } if (WAKEUP_MANAGER_STATE_UTTERANCE == mWakeupManagerState) { change_manager_state(WAKEUP_MANAGER_STATE_PROCESSING); + mAudioManager.stop_recording(true); mAudioManager.set_recording_session(RECORDING_SESSION_WAKE_WORD); + if (mWakeupEngineManager.get_audio_data_required()) { + /* Restart recorder thread using appropriate recording device */ + mAudioManager.start_recording(true); + } } mStreamingMode = STREAMING_MODE::NONE; @@ -753,14 +762,17 @@ bool CWakeupManager::stop_streaming_follow_up_data() if (WAKEUP_MANAGER_STATE_UTTERANCE == mWakeupManagerState) { change_manager_state(WAKEUP_MANAGER_STATE_PROCESSING); + mAudioManager.stop_recording(true); + mAudioManager.set_recording_session(RECORDING_SESSION_WAKE_WORD); + if (mWakeupEngineManager.get_audio_data_required()) { + /* Restart recorder thread using appropriate recording device */ + mAudioManager.start_recording(true); + } } mStreamingMode = STREAMING_MODE::NONE; - mAudioManager.stop_recording(true); mAudioManager.clear_audio_data(); - mAudioManager.set_recording_session(RECORDING_SESSION_WAKE_WORD); - mAudioManager.start_recording(true); MWR_LOGD("[END]"); return true; @@ -1018,10 +1030,6 @@ bool CWakeupManager::CEngineEventObserver::on_streaming_audio_data( for (const auto& observer : observers) { observer->on_streaming_audio_data(event, buffer, len); } - if (MAS_SPEECH_STREAMING_EVENT_FINISH == event) { - mWakeupManager->set_streaming_mode(STREAMING_MODE::NONE); - mWakeupManager->stop_streaming_duration_timer(); - } return true; } -- 2.7.4 From fac49440b2c6d2f77308c0116a74c04ef58145c1 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Fri, 8 Apr 2022 12:03:58 +0900 Subject: [PATCH 10/16] Add metadata profile for providing metadata information Change-Id: I51a2c31f29c032d68ea7830d7e348b29bd0e6457 --- packaging/metadata-profile.xml | 101 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 packaging/metadata-profile.xml diff --git a/packaging/metadata-profile.xml b/packaging/metadata-profile.xml new file mode 100644 index 0000000..783ec1b --- /dev/null +++ b/packaging/metadata-profile.xml @@ -0,0 +1,101 @@ + + + + + N + 1.0 + + The multi-assistant-service will use this name to identify the multi-assistant client. + + + It does not work if there is no value. + + + + + + + + N + 1.0 + + The multi-assistant-service will not use multi-assistant clients if the current language is not in this language support list. + + + It does not work if there is no value. + + + + + + + + N + 1.0 + + The multi-assistant-service will use this name to identify the multi-assistant client. + + + It does not work if there is no value. + + + + + + + + N + 1.0 + + This icon path will be displayed on the multi-assistant-panel. If the system does not use multi-assistant-panel, this value has no effect. + + + If multi-assistant-panel is used and no icon path value is specified, then an empty icon will be displayed instead. + + + + + + + + N + 1.0 + + The wakeup engine with given appid is allowed to notify wakeup event to this multi-assistant client. + + + No wake word detection will be provided if there is no value. + + + + + + + + N + 1.0 + + If the multi-assistant client wants to support Push-to-Talk ,Tap-to-Talk or both, it should be specified as "push_to_talk", "tap_to_talk", "all" respectively. + + + If no value is specified, the default value is considered as "push_to_talk" + + + + + + + + N + 1.0 + + If there exists an external audio data processing app, the audio data will be transmitted directly to it. + + + No direct audio data transmission will be provided if there is no value. + + + + + + -- 2.7.4 From 8054a9d103a8ff5eb8cd7b054b2b933739c06a83 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Fri, 8 Apr 2022 12:04:32 +0900 Subject: [PATCH 11/16] Bump version to 0.3.29 Change-Id: I697921c3ed2f1169c640d9bd0ae2a7e0ea869fb9 --- 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 2ce203c..53daa86 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 f030c41..3a54b43 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.3.28 +Version: 0.3.29 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Flora-1.1 -- 2.7.4 From 0b9f8c6bf3f202ea81ba2484bb83326de3e5c7ed Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Mon, 9 May 2022 20:45:12 +0900 Subject: [PATCH 12/16] Validate sender information for every request from client Change-Id: I3d3b51e8b70dec4f8a25eb2827c5f647f6cca273 --- inc/client_manager.h | 6 ++- inc/service_ipc_dbus_dispatcher.h | 36 +++++++------- inc/service_main.h | 36 +++++++------- src/client_manager.cpp | 29 +++++++++++- src/service_ipc_dbus_dispatcher.cpp | 62 ++++++++++++++++++------- src/service_main.cpp | 93 ++++++++++++++++++++++++++++--------- 6 files changed, 185 insertions(+), 77 deletions(-) diff --git a/inc/client_manager.h b/inc/client_manager.h index 94712a1..0f98b34 100644 --- a/inc/client_manager.h +++ b/inc/client_manager.h @@ -26,6 +26,7 @@ typedef struct { pid_t pid; std::string appid; + std::string sender_info; } ma_client_s; class CClientManager { @@ -34,7 +35,7 @@ public: virtual ~CClientManager() {} int set_application_manager(IApplicationManager* manager); - int create_client(pid_t pid, std::string appid); + int create_client(pid_t pid, std::string appid, std::string sender_info); int destroy_client_by_pid(pid_t pid); int destroy_client_by_appid(std::string appid); @@ -43,8 +44,11 @@ public: pid_t find_client_pid_by_appid(std::string appid); std::string find_client_appid_by_pid(pid_t pid); + std::string find_sender_info_by_pid(pid_t pid); bool check_client_validity_by_appid(std::string appid); + + bool check_sender_info_by_pid(pid_t pid, std::string sender_info); private: ma_client_s* find_client_by_appid(std::string appid); ma_client_s* find_client_by_pid(pid_t pid); diff --git a/inc/service_ipc_dbus_dispatcher.h b/inc/service_ipc_dbus_dispatcher.h index 9d2250b..c7f3104 100644 --- a/inc/service_ipc_dbus_dispatcher.h +++ b/inc/service_ipc_dbus_dispatcher.h @@ -25,25 +25,25 @@ class CServiceMain; class IServiceIpcObserver { public: - 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_initialize(pid_t pid, std::string sender_info) = 0; + virtual int on_deinitialize(pid_t pid, std::string sender_info) = 0; + virtual int on_get_audio_format(pid_t pid, int& rate, int& channel, int& audio_type, std::string sender_info) = 0; + virtual int on_get_audio_source_type(pid_t pid, std::string& type, std::string sender_info) = 0; + virtual int on_send_asr_result(pid_t pid, int event, std::string asr_result, std::string sender_info) = 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(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; + std::string display_text, std::string utterance_text, std::string result_json, std::string sender_info) = 0; + virtual int on_send_recognition_result(pid_t pid, int result, std::string sender_info) = 0; + virtual int on_start_streaming_audio_data(pid_t pid, int type, std::string sender_info) = 0; + virtual int on_stop_streaming_audio_data(pid_t pid, int type, std::string sender_info) = 0; + virtual int on_update_voice_feedback_state(pid_t pid, int state, std::string sender_info) = 0; + virtual int on_send_assistant_specific_command(pid_t pid, std::string command, std::string sender_info) = 0; + virtual int on_set_background_volume(pid_t pid, double ratio, std::string sender_info) = 0; + virtual int on_set_preprocessing_allow_mode(pid_t pid, int mode, std::string app_id, std::string sender_info) = 0; + virtual int on_send_preprocessing_result(pid_t pid, int result, std::string sender_info) = 0; + virtual int on_set_wake_word_audio_require_flag(pid_t pid, int require, std::string sender_info) = 0; + virtual int on_set_assistant_language(pid_t pid, std::string language, std::string sender_info) = 0; + virtual int on_add_wake_word(pid_t pid, std::string wake_word, std::string language, std::string sender_info) = 0; + virtual int on_remove_wake_word(pid_t pid, std::string wake_word, std::string language, std::string sender_info) = 0; virtual int on_ui_initialize(pid_t pid) = 0; virtual int on_ui_deinitialize(pid_t pid) = 0; diff --git a/inc/service_main.h b/inc/service_main.h index 168b59f..c3fc791 100644 --- a/inc/service_main.h +++ b/inc/service_main.h @@ -123,25 +123,25 @@ public: int process_preprocessing_state_event(PREPROCESSING_STATE_EVENT event); int update_voice_key_support_mode(); - 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_initialize(pid_t pid, std::string sender_info) override; + int on_deinitialize(pid_t pid, std::string sender_info) override; + int on_get_audio_format(pid_t pid, int& rate, int& channel, int& audio_type, std::string sender_info) override; + int on_get_audio_source_type(pid_t pid, std::string& type, std::string sender_info) override; + int on_send_asr_result(pid_t pid, int event, std::string asr_result, std::string sender_info) override; int on_send_result(pid_t pid, std::string display_text, - std::string utterance_text, std::string result_json) 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; + std::string utterance_text, std::string result_json, std::string sender_info) override; + int on_send_recognition_result(pid_t pid, int result, std::string sender_info) override; + int on_start_streaming_audio_data(pid_t pid, int type, std::string sender_info) override; + int on_stop_streaming_audio_data(pid_t pid, int type, std::string sender_info) override; + int on_update_voice_feedback_state(pid_t pid, int state, std::string sender_info) override; + int on_send_assistant_specific_command(pid_t pid, std::string command, std::string sender_info) override; + int on_set_background_volume(pid_t pid, double ratio, std::string sender_info) override; + int on_set_preprocessing_allow_mode(pid_t pid, int mode, std::string app_id, std::string sender_info) override; + int on_send_preprocessing_result(pid_t pid, int result, std::string sender_info) override; + int on_set_wake_word_audio_require_flag(pid_t pid, int require, std::string sender_info) override; + int on_set_assistant_language(pid_t pid, std::string language, std::string sender_info) override; + int on_add_wake_word(pid_t pid, std::string wake_word, std::string language, std::string sender_info) override; + int on_remove_wake_word(pid_t pid, std::string wake_word, std::string language, std::string sender_info) override; int on_ui_initialize(pid_t pid) override; int on_ui_deinitialize(pid_t pid) override; diff --git a/src/client_manager.cpp b/src/client_manager.cpp index 2fd5b61..0225eb1 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(pid_t pid, std::string appid) +int CClientManager::create_client(pid_t pid, std::string appid, std::string sender_info) { ma_client_s* data = NULL; @@ -37,6 +37,7 @@ int CClientManager::create_client(pid_t pid, std::string appid) if (data) { data->pid = pid; data->appid = appid; + data->sender_info = sender_info; mClientList = g_slist_append(mClientList, data); MAS_LOGI("Create client : %s %d", appid.c_str(), pid); } else { @@ -188,9 +189,35 @@ std::string CClientManager::find_client_appid_by_pid(pid_t pid) return appid; } +std::string CClientManager::find_sender_info_by_pid(pid_t pid) +{ + std::string ret; + ma_client_s* client = find_client_by_pid(pid); + if (client) { + ret = client->sender_info; + } + return ret; +} + bool CClientManager::check_client_validity_by_appid(std::string appid) { pid_t pid = find_client_pid_by_appid(appid); if (0 < pid) return true; return false; } + +bool CClientManager::check_sender_info_by_pid(pid_t pid, std::string sender_info) +{ + bool ret = false; + ma_client_s* client = find_client_by_pid(pid); + if (client) { + if (client->sender_info.compare(sender_info) == 0) { + ret = true; + } + } + if (!ret) { + MAS_LOGE("SENDER INFO does not match : [%s] [%s]", + client->sender_info.c_str(), sender_info.c_str()); + } + return ret; +} diff --git a/src/service_ipc_dbus_dispatcher.cpp b/src/service_ipc_dbus_dispatcher.cpp index 674c9e1..b2552af 100644 --- a/src/service_ipc_dbus_dispatcher.cpp +++ b/src/service_ipc_dbus_dispatcher.cpp @@ -63,6 +63,7 @@ int CServiceIpcDbusDispatcher::on_initialize(DBusConnection* conn, DBusMessage* MAS_LOGE("[ERROR] Failed retrieving arguments"); } + MAS_LOGD("[DEBUG] MAS INITIALIZE"); if (dbus_error_is_set(&err)) { @@ -71,7 +72,8 @@ int CServiceIpcDbusDispatcher::on_initialize(DBusConnection* conn, DBusMessage* ret = -1; //MAS_ERROR_OPERATION_FAILED; } else { MAS_LOGD("[IN] mas initialize : pid(%d)", pid); - ret = mIpcObserver->on_initialize(pid); + const char *sender = dbus_message_get_sender(msg); + ret = mIpcObserver->on_initialize(pid, (sender ? sender : "")); } DBusMessage* reply; @@ -129,7 +131,8 @@ int CServiceIpcDbusDispatcher::on_deinitialize(DBusConnection* conn, DBusMessage ret = -1; //MAS_ERROR_OPERATION_FAILED; } else { MAS_LOGD("[IN] mas deinitialize : pid(%d)", pid); - ret = mIpcObserver->on_deinitialize(pid); + const char *sender = dbus_message_get_sender(msg); + ret = mIpcObserver->on_deinitialize(pid, (sender ? sender : "")); } DBusMessage* reply; @@ -188,7 +191,8 @@ int CServiceIpcDbusDispatcher::on_get_audio_format(DBusConnection* conn, DBusMes ret = -1; //MAS_ERROR_OPERATION_FAILED; } else { MAS_LOGD("[IN] mas get audio format"); - ret = mIpcObserver->on_get_audio_format(pid, rate, channel, audio_type); + const char *sender = dbus_message_get_sender(msg); + ret = mIpcObserver->on_get_audio_format(pid, rate, channel, audio_type, (sender ? sender : "")); } DBusMessage* reply; @@ -249,7 +253,8 @@ int CServiceIpcDbusDispatcher::on_get_audio_source_type(DBusConnection* conn, DB ret = -1; //MAS_ERROR_OPERATION_FAILED; } else { MAS_LOGD("[IN] mas get audio source type"); - ret = mIpcObserver->on_get_audio_source_type(pid, type); + const char *sender = dbus_message_get_sender(msg); + ret = mIpcObserver->on_get_audio_source_type(pid, type, (sender ? sender : "")); } DBusMessage* reply; @@ -320,8 +325,10 @@ int CServiceIpcDbusDispatcher::on_send_asr_result(DBusConnection* conn, DBusMess ret = -1; //MAS_ERROR_OPERATION_FAILED; } else { MAS_LOGI("[IN] mas send asr result : pid(%d), event(%d), asr_result(%s)", pid, event, asr_result); + const char *sender = dbus_message_get_sender(msg); ret = mIpcObserver->on_send_asr_result(pid, event, - asr_result ? std::string{asr_result} : std::string{}); + asr_result ? std::string{asr_result} : std::string{}, + (sender ? sender : "")); } DBusMessage* reply; @@ -387,10 +394,12 @@ int CServiceIpcDbusDispatcher::on_send_result(DBusConnection* conn, DBusMessage* ret = -1; //MAS_ERROR_OPERATION_FAILED; } else { MAS_LOGI("[IN] mas send result : pid(%d), display_text(%s), utterance_text(%s), result_json(%s)", pid, display_text, utterance_text, result_json); + const char *sender = dbus_message_get_sender(msg); ret = mIpcObserver->on_send_result(pid, display_text ? std::string{display_text} : std::string{}, utterance_text ? std::string{utterance_text} : std::string{}, - result_json ? std::string{result_json} : std::string{}); + result_json ? std::string{result_json} : std::string{}, + (sender ? sender : "")); } DBusMessage* reply; @@ -452,7 +461,8 @@ int CServiceIpcDbusDispatcher::on_send_recognition_result(DBusConnection* conn, ret = -1; //MAS_ERROR_OPERATION_FAILED; } else { MAS_LOGI("[IN] mas send recognition result : pid(%d), result(%d)", pid, result); - ret = mIpcObserver->on_send_recognition_result(pid, result); + const char *sender = dbus_message_get_sender(msg); + ret = mIpcObserver->on_send_recognition_result(pid, result, (sender ? sender : "")); } MAS_LOGD("<<<<<"); @@ -490,7 +500,8 @@ int CServiceIpcDbusDispatcher::on_start_streaming_audio_data(DBusConnection* con ret = -1; //MAS_ERROR_OPERATION_FAILED; } else { MAS_LOGI("[IN] mas send start streaming : pid(%d), type(%d)", pid, type); - ret = mIpcObserver->on_start_streaming_audio_data(pid, type); + const char *sender = dbus_message_get_sender(msg); + ret = mIpcObserver->on_start_streaming_audio_data(pid, type, (sender ? sender : "")); } MAS_LOGD("<<<<<"); @@ -528,7 +539,8 @@ int CServiceIpcDbusDispatcher::on_stop_streaming_audio_data(DBusConnection* conn ret = -1; //MAS_ERROR_OPERATION_FAILED; } else { MAS_LOGI("[IN] mas stop streaming : pid(%d), type(%d)", pid, type); - ret = mIpcObserver->on_stop_streaming_audio_data(pid, type); + const char *sender = dbus_message_get_sender(msg); + ret = mIpcObserver->on_stop_streaming_audio_data(pid, type, (sender ? sender : "")); } MAS_LOGD("<<<<<"); @@ -566,7 +578,8 @@ int CServiceIpcDbusDispatcher::on_update_voice_feedback_state(DBusConnection* co ret = -1; //MAS_ERROR_OPERATION_FAILED; } else { MAS_LOGI("[IN] mas update voice feedback : pid(%d), state(%d)", pid, state); - ret = mIpcObserver->on_update_voice_feedback_state(pid, state); + const char *sender = dbus_message_get_sender(msg); + ret = mIpcObserver->on_update_voice_feedback_state(pid, state, (sender ? sender : "")); } MAS_LOGD("<<<<<"); @@ -604,8 +617,10 @@ int CServiceIpcDbusDispatcher::on_send_assistant_specific_command(DBusConnection ret = -1; //MAS_ERROR_OPERATION_FAILED; } else { MAS_LOGI("[IN] mas send assistant specific command : pid(%d), command(%s)", pid, command); + const char *sender = dbus_message_get_sender(msg); ret = mIpcObserver->on_send_assistant_specific_command(pid, - command ? std::string{command} : std::string{}); + command ? std::string{command} : std::string{}, + (sender ? sender : "")); } MAS_LOGD("<<<<<"); @@ -643,7 +658,8 @@ int CServiceIpcDbusDispatcher::on_set_background_volume(DBusConnection* conn, DB ret = -1; //MAS_ERROR_OPERATION_FAILED; } else { MAS_LOGI("[IN] mas set background volume : pid(%d), ratio(%f)", pid, ratio); - ret = mIpcObserver->on_set_background_volume(pid, ratio); + const char *sender = dbus_message_get_sender(msg); + ret = mIpcObserver->on_set_background_volume(pid, ratio, (sender ? sender : "")); } MAS_LOGD("<<<<<"); @@ -683,9 +699,11 @@ int CServiceIpcDbusDispatcher::on_set_preprocessing_allow_mode(DBusConnection* c ret = -1; //MAS_ERROR_OPERATION_FAILED; } else { MAS_LOGI("[IN] mas set preprocessing allow mode : pid(%d), mode(%d), app_id(%s)", pid, mode, app_id); + const char *sender = dbus_message_get_sender(msg); ret = mIpcObserver->on_set_preprocessing_allow_mode(pid, static_cast(mode), - app_id ? std::string{app_id} : std::string{}); + app_id ? std::string{app_id} : std::string{}, + (sender ? sender : "")); } MAS_LOGD("<<<<<"); @@ -723,7 +741,8 @@ int CServiceIpcDbusDispatcher::on_send_preprocessing_result(DBusConnection* conn ret = -1; //MAS_ERROR_OPERATION_FAILED; } else { MAS_LOGI("[IN] mas send preprocessing result : pid(%d), result(%d)", pid, result); - ret = mIpcObserver->on_send_preprocessing_result(pid, result); + const char *sender = dbus_message_get_sender(msg); + ret = mIpcObserver->on_send_preprocessing_result(pid, result, (sender ? sender : "")); } MAS_LOGD("<<<<<"); @@ -761,7 +780,8 @@ int CServiceIpcDbusDispatcher::on_set_wake_word_audio_require_flag(DBusConnectio ret = -1; //MAS_ERROR_OPERATION_FAILED; } else { MAS_LOGI("[IN] mas set wake word audio require flag : pid(%d), require(%d)", pid, require); - ret = mIpcObserver->on_set_wake_word_audio_require_flag(pid, require); + const char *sender = dbus_message_get_sender(msg); + ret = mIpcObserver->on_set_wake_word_audio_require_flag(pid, require, (sender ? sender : "")); } MAS_LOGD("<<<<<"); @@ -799,8 +819,10 @@ int CServiceIpcDbusDispatcher::on_set_assistant_language(DBusConnection* conn, D ret = -1; //MAS_ERROR_OPERATION_FAILED; } else { MAS_LOGI("[IN] mas set assistant language : pid(%d), language(%s)", pid, language); + const char *sender = dbus_message_get_sender(msg); ret = mIpcObserver->on_set_assistant_language(pid, - language ? std::string{language} : std::string{}); + language ? std::string{language} : std::string{}, + (sender ? sender : "")); } MAS_LOGD("<<<<<"); @@ -840,9 +862,11 @@ int CServiceIpcDbusDispatcher::on_add_wake_word(DBusConnection* conn, DBusMessag ret = -1; //MAS_ERROR_OPERATION_FAILED; } else { MAS_LOGI("[IN] mas add wake word : pid(%d), wake_word(%s) language(%s)", pid, wake_word, language); + const char *sender = dbus_message_get_sender(msg); ret = mIpcObserver->on_add_wake_word(pid, wake_word ? std::string{wake_word} : std::string{}, - language ? std::string{language} : std::string{}); + language ? std::string{language} : std::string{}, + (sender ? sender : "")); } MAS_LOGD("<<<<<"); @@ -882,9 +906,11 @@ int CServiceIpcDbusDispatcher::on_remove_wake_word(DBusConnection* conn, DBusMes ret = -1; //MAS_ERROR_OPERATION_FAILED; } else { MAS_LOGI("[IN] mas remove wake word : pid(%d), wake_word(%s) language(%s)", pid, wake_word, language); + const char *sender = dbus_message_get_sender(msg); ret = mIpcObserver->on_remove_wake_word(pid, wake_word ? std::string{wake_word} : std::string{}, - language ? std::string{language} : std::string{}); + language ? std::string{language} : std::string{}, + (sender ? sender : "")); } MAS_LOGD("<<<<<"); diff --git a/src/service_main.cpp b/src/service_main.cpp index e3482e6..635f895 100644 --- a/src/service_main.cpp +++ b/src/service_main.cpp @@ -867,7 +867,7 @@ pid_t CServiceMain::get_client_pid_by_appid(const char *appid) if (-1 != ret && !mApplicationManager.is_application_running(appid)) { MAS_LOGE("The PID for %s was %d, but it seems to be terminated", appid, ret); - on_deinitialize(ret); + on_deinitialize(ret, mClientManager.find_sender_info_by_pid(ret)); ret = -1; } @@ -1389,14 +1389,14 @@ void CServiceMain::app_terminate(void *data) return; } -int CServiceMain::on_initialize(pid_t pid) { +int CServiceMain::on_initialize(pid_t pid, std::string sender_info) { MAS_LOGD("[Enter] pid(%d)", pid); std::string pid_appid; boost::optional appid_by_pid = mApplicationManager.get_appid_by_pid(pid); if (appid_by_pid) { pid_appid = *appid_by_pid; - MAS_LOGD("appid for pid %d is : %s", pid, pid_appid.c_str()); + MAS_LOGD("appid for pid %d is : %s (%s)", pid, pid_appid.c_str(), sender_info.c_str()); /* Remove existing client that has same appid, if there's any */ mClientManager.destroy_client_by_appid(pid_appid.c_str()); @@ -1404,7 +1404,7 @@ int CServiceMain::on_initialize(pid_t pid) { /* And remove a client that has same pid also */ mClientManager.destroy_client_by_pid(pid); - mClientManager.create_client(pid, pid_appid.c_str()); + mClientManager.create_client(pid, pid_appid, sender_info); const char *current_maclient_appid = NULL; if (mCurrentClientInfo >= 0 && mCurrentClientInfo < MAX_MACLIENT_INFO_NUM) { @@ -1439,8 +1439,11 @@ int CServiceMain::on_initialize(pid_t pid) { return 0; } -int CServiceMain::on_deinitialize(pid_t pid) { +int CServiceMain::on_deinitialize(pid_t pid, std::string sender_info) { MAS_LOGD("[Enter] pid(%d)", pid); + if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) { + return -1; + } if (mLastDuckingRequester == pid) { MAS_LOGE("Last ducking requester has disconnected, resetting background volume"); std::string pid_appid = mClientManager.find_client_appid_by_pid( pid); @@ -1453,7 +1456,10 @@ int CServiceMain::on_deinitialize(pid_t pid) { return 0; } -int CServiceMain::on_get_audio_format(pid_t pid, int& rate, int& channel, int& audio_type) { +int CServiceMain::on_get_audio_format(pid_t pid, int& rate, int& channel, int& audio_type, std::string sender_info) { + if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) { + return -1; + } int main_rate, main_channel, main_audio_type; int ret = client_get_audio_format(pid, &main_rate, &main_channel, &main_audio_type); @@ -1463,7 +1469,10 @@ int CServiceMain::on_get_audio_format(pid_t pid, int& rate, int& channel, int& a return ret; } -int CServiceMain::on_get_audio_source_type(pid_t pid, std::string& type) { +int CServiceMain::on_get_audio_source_type(pid_t pid, std::string& type, std::string sender_info) { + if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) { + return -1; + } char *main_type = nullptr; int ret = client_get_audio_source_type(pid, &main_type); if (0 == ret && main_type) { @@ -1472,62 +1481,104 @@ int CServiceMain::on_get_audio_source_type(pid_t pid, std::string& type) { return ret; } -int CServiceMain::on_send_asr_result(pid_t pid, int event, std::string asr_result) { +int CServiceMain::on_send_asr_result(pid_t pid, int event, std::string asr_result, std::string sender_info) { + if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) { + return -1; + } 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) { + std::string utterance_text, std::string result_json, std::string sender_info) { + if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) { + return -1; + } 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) { +int CServiceMain::on_send_recognition_result(pid_t pid, int result, std::string sender_info) { + if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) { + return -1; + } return client_send_recognition_result(pid, result); } -int CServiceMain::on_start_streaming_audio_data(pid_t pid, int type) { +int CServiceMain::on_start_streaming_audio_data(pid_t pid, int type, std::string sender_info) { + if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) { + return -1; + } return client_start_streaming_audio_data(pid, type); } -int CServiceMain::on_stop_streaming_audio_data(pid_t pid, int type) { +int CServiceMain::on_stop_streaming_audio_data(pid_t pid, int type, std::string sender_info) { + if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) { + return -1; + } return client_stop_streaming_audio_data(pid, type); } -int CServiceMain::on_update_voice_feedback_state(pid_t pid, int state) { +int CServiceMain::on_update_voice_feedback_state(pid_t pid, int state, std::string sender_info) { + if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) { + return -1; + } return client_update_voice_feedback_state(pid, state); } -int CServiceMain::on_send_assistant_specific_command(pid_t pid, std::string command) { +int CServiceMain::on_send_assistant_specific_command(pid_t pid, std::string command, std::string sender_info) { + if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) { + return -1; + } return client_set_assistant_specific_command(pid, command.c_str()); } -int CServiceMain::on_set_background_volume(pid_t pid, double ratio) { +int CServiceMain::on_set_background_volume(pid_t pid, double ratio, std::string sender_info) { + if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) { + return -1; + } return client_set_background_volume(pid, ratio); } -int CServiceMain::on_set_preprocessing_allow_mode(pid_t pid, int mode, std::string app_id) { +int CServiceMain::on_set_preprocessing_allow_mode(pid_t pid, int mode, std::string app_id, std::string sender_info) { + if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) { + return -1; + } 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) { +int CServiceMain::on_send_preprocessing_result(pid_t pid, int result, std::string sender_info) { + if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) { + return -1; + } return client_send_preprocessing_result(pid, result); } -int CServiceMain::on_set_wake_word_audio_require_flag(pid_t pid, int require) { +int CServiceMain::on_set_wake_word_audio_require_flag(pid_t pid, int require, std::string sender_info) { + if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) { + return -1; + } return client_set_wake_word_audio_require_flag(pid, require); } -int CServiceMain::on_set_assistant_language(pid_t pid, std::string language) { +int CServiceMain::on_set_assistant_language(pid_t pid, std::string language, std::string sender_info) { + if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) { + return -1; + } 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) { +int CServiceMain::on_add_wake_word(pid_t pid, std::string wake_word, std::string language, std::string sender_info) { + if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) { + return -1; + } 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) { +int CServiceMain::on_remove_wake_word(pid_t pid, std::string wake_word, std::string language, std::string sender_info) { + if (!mClientManager.check_sender_info_by_pid(pid, sender_info)) { + return -1; + } return client_remove_wake_word(pid, wake_word.c_str(), language.c_str()); } -- 2.7.4 From dd55f42f422edb076d69a3f5ea765ff0dea5c929 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Tue, 10 May 2022 10:48:49 +0900 Subject: [PATCH 13/16] Fix defects detected by static analysis tool Change-Id: I34bf30e5c04dc391d185b8f3a8042ebf0530531a --- src/client_manager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/client_manager.cpp b/src/client_manager.cpp index 0225eb1..e380782 100644 --- a/src/client_manager.cpp +++ b/src/client_manager.cpp @@ -217,7 +217,8 @@ bool CClientManager::check_sender_info_by_pid(pid_t pid, std::string sender_info } if (!ret) { MAS_LOGE("SENDER INFO does not match : [%s] [%s]", - client->sender_info.c_str(), sender_info.c_str()); + (client ? client->sender_info.c_str() : ""), + sender_info.c_str()); } return ret; } -- 2.7.4 From 9360284117c423ae3320b8c4fffa0a8711e4f3ec Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Tue, 10 May 2022 10:48:56 +0900 Subject: [PATCH 14/16] Bump version to 0.3.30 Change-Id: I47826ad2f0aa95d062c40d89cc7f0ce3bbd4b526 --- 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 53daa86..b75da9c 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 3a54b43..35e0ef7 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.3.29 +Version: 0.3.30 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Flora-1.1 -- 2.7.4 From a1ef19dcc795cb3c969cee6399226f90080701bd Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Tue, 10 May 2022 14:59:05 +0900 Subject: [PATCH 15/16] Update default assistant appid on wakeup event Change-Id: I04e3059320e4a9f8e6d4c8902219297d47239a97 --- plugins/wakeup-manager/inc/wakeup_settings.h | 2 ++ plugins/wakeup-manager/src/wakeup_manager.cpp | 7 ++++++- plugins/wakeup-manager/src/wakeup_settings.cpp | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/plugins/wakeup-manager/inc/wakeup_settings.h b/plugins/wakeup-manager/inc/wakeup_settings.h index d69d71a..64b8b25 100644 --- a/plugins/wakeup-manager/inc/wakeup_settings.h +++ b/plugins/wakeup-manager/inc/wakeup_settings.h @@ -66,6 +66,8 @@ public: const vector& get_observers(); string get_default_assistant_appid(); + void set_default_assistant_appid(std::string appid); + bool get_ui_panel_enabled(); float get_conversation_timeout(); bool get_multiple_mode(); diff --git a/plugins/wakeup-manager/src/wakeup_manager.cpp b/plugins/wakeup-manager/src/wakeup_manager.cpp index fdc1c4e..90580cc 100644 --- a/plugins/wakeup-manager/src/wakeup_manager.cpp +++ b/plugins/wakeup-manager/src/wakeup_manager.cpp @@ -1073,7 +1073,12 @@ void CWakeupManager::CPolicyEventObserver::on_wakeup(mas_wakeup_event_info wakeu CAudioManager *audio_manager = mWakeupManager->get_audio_manager(); CWakeupEngineManager *engine_manager = mWakeupManager->get_engine_manager(); - if (nullptr == audio_manager || nullptr == engine_manager) return; + CWakeupSettings* settings = mWakeupManager->get_wakeup_settings(); + if (nullptr == audio_manager || nullptr == engine_manager || nullptr == settings) return; + + if (wakeup_info.wakeup_appid && strlen(wakeup_info.wakeup_appid) > 0) { + settings->set_default_assistant_appid(wakeup_info.wakeup_appid); + } mWakeupManager->stop_streaming_utterance_data(); mWakeupManager->stop_streaming_previous_utterance_data(); diff --git a/plugins/wakeup-manager/src/wakeup_settings.cpp b/plugins/wakeup-manager/src/wakeup_settings.cpp index c7c1142..4022002 100644 --- a/plugins/wakeup-manager/src/wakeup_settings.cpp +++ b/plugins/wakeup-manager/src/wakeup_settings.cpp @@ -274,6 +274,13 @@ string CWakeupSettings::get_default_assistant_appid() return mDefaultAssistantAppid; } +void CWakeupSettings::set_default_assistant_appid(std::string appid) +{ + int ret = vconf_set_str(WAKEUP_SETTINGS_KEY_DEFAULT_ASSISTANT_APPID, appid.c_str()); + MWR_LOGD("default_assistant_appid : %s, %d", appid.c_str(), ret); + mDefaultAssistantAppid = appid; +} + bool CWakeupSettings::get_ui_panel_enabled() { return mUiPanelEnabled; -- 2.7.4 From cda6547154b46ab1d1abd66e610fcbf3277ece65 Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Thu, 19 May 2022 16:14:03 +0900 Subject: [PATCH 16/16] Separate config setter and value change handler Change-Id: Ia659b1cc4a56eca2a4293493c6ce5c3e21b0e565 --- plugins/wakeup-manager/inc/wakeup_manager.h | 1 + .../wakeup-manager/src/wakeup_engine_manager.cpp | 28 +++++-- plugins/wakeup-manager/src/wakeup_manager.cpp | 37 ++++++--- .../wakeup-manager/src/wakeup_manager_wrapper.cpp | 97 ++++++++++++++++++++++ plugins/wakeup-manager/src/wakeup_settings.cpp | 8 +- src/client_manager.cpp | 6 +- src/service_main.cpp | 12 ++- 7 files changed, 165 insertions(+), 24 deletions(-) diff --git a/plugins/wakeup-manager/inc/wakeup_manager.h b/plugins/wakeup-manager/inc/wakeup_manager.h index 21f8ccd..b348b2e 100644 --- a/plugins/wakeup-manager/inc/wakeup_manager.h +++ b/plugins/wakeup-manager/inc/wakeup_manager.h @@ -97,6 +97,7 @@ public: bool set_assistant_enabled(string appid, bool enabled); bool get_assistant_enabled(string appid); bool set_default_assistant(string appid); + bool process_default_assistant_changed(string appid); string get_default_assistant(); bool update_voice_feedback_state(string appid, bool state); diff --git a/plugins/wakeup-manager/src/wakeup_engine_manager.cpp b/plugins/wakeup-manager/src/wakeup_engine_manager.cpp index 307ff3c..5fb0b0c 100644 --- a/plugins/wakeup-manager/src/wakeup_engine_manager.cpp +++ b/plugins/wakeup-manager/src/wakeup_engine_manager.cpp @@ -246,6 +246,7 @@ void CWakeupEngineManager::set_assistant_activated(string appid, bool activated) if (info.activated) { try { info.interface.activate(); + MWR_LOGW("Activating wakeup engine : %s", info.engine_name.c_str()); } catch (const std::exception& e) { MWR_LOGE("[ERROR] wakeup engine %s threw exception : %s", info.engine_name.c_str(), e.what()); @@ -253,6 +254,7 @@ void CWakeupEngineManager::set_assistant_activated(string appid, bool activated) } else { try { info.interface.deactivate(); + MWR_LOGW("Deactivating wakeup engine : %s", info.engine_name.c_str()); } catch (const std::exception& e) { MWR_LOGE("[ERROR] wakeup engine %s threw exception : %s", info.engine_name.c_str(), e.what()); @@ -394,20 +396,20 @@ void CWakeupEngineManager::streaming_speech_data_thread_func() if (0 != ret) { /* empty queue */ - MWR_LOGD("[DEBUG] No feedback data. Waiting mode : %d", ret); + MWR_LOGD("[DEBUG] No feedback data. Waiting mode : %d %d", ret, cnt); /* waiting */ while (!(mStopStreamingThread.load())) { burst_count = 0; this_thread::sleep_for(chrono::milliseconds(10)); if (index < interface->get_utterance_data_count()) { - MWR_LOGD("[INFO] Resume thread"); + MWR_LOGD("[INFO] Resume thread, %d", cnt); break; } mStreamingHistory.last_count_fetched.store(get_current_milliseconds_after_epoch()); if (g_speech_pcm_wait_count < cnt) { unsigned char final_buffer[2] = {'\0', }; - MWR_LOGE("[ERROR] Wrong request, there's no pcm data"); + MWR_LOGE("[ERROR] Wrong request, there's no pcm data : %d", cnt); #ifdef BUF_SAVE_MODE if (g_pFile) { fwrite(final_buffer, 1, sizeof(final_buffer), g_pFile); @@ -654,12 +656,20 @@ void CWakeupEngineManager::engine_set_assistant_specific_command(string appid, s void CWakeupEngineManager::engine_feed_audio_data(long time, void* data, int len) { + bool print = false; + const std::chrono::seconds interval(3); + static auto last = std::chrono::steady_clock::now(); + auto now = std::chrono::steady_clock::now(); + if (now - last > interval) { + print = true; + last = now; + } for (const auto& info : mEngineInfo) { + bool filtered_out = false; if (info.activated && info.audio_data_require_status && info.interface.feed_audio_data) { try { - bool filtered_out = false; /* After a wakeup event, wakeup engines other than the selected one does not need to receive audio data. */ if (WAKEUP_MANAGER_STATE_UTTERANCE == mWakeupManagerState) { @@ -669,8 +679,8 @@ void CWakeupEngineManager::engine_feed_audio_data(long time, void* data, int len } if (!filtered_out) { int ret = info.interface.feed_audio_data(time, data, len); - if (0 != ret) { - LOGE("[ERROR] Fail to feed speech data, ret(%d) : %s", ret, info.engine_name.c_str()); + if (ret != 0 || print) { + LOGE("Feed speech data, ret(%d) : %s", ret, info.engine_name.c_str()); } } } catch (const std::exception& e) { @@ -678,6 +688,12 @@ void CWakeupEngineManager::engine_feed_audio_data(long time, void* data, int len info.engine_name.c_str(), e.what()); } } + if (print) { + MWR_LOGE("Feeding audio data to %s : %d %d %p %d", + info.engine_name.c_str(), + info.activated, info.audio_data_require_status, + info.interface.feed_audio_data, filtered_out); + } } } diff --git a/plugins/wakeup-manager/src/wakeup_manager.cpp b/plugins/wakeup-manager/src/wakeup_manager.cpp index 90580cc..7b631af 100644 --- a/plugins/wakeup-manager/src/wakeup_manager.cpp +++ b/plugins/wakeup-manager/src/wakeup_manager.cpp @@ -299,7 +299,7 @@ bool CWakeupManager::set_assistant_enabled(string appid, bool enabled) if (false == mAssistantSupportsCurrentLanguage[appid]) { activated = false; } - if (0 == appid.compare(mCurrentDefaultAssistant)) { + if (0 == appid.compare(mWakeupSettings.get_default_assistant_appid())) { activated = true; } mWakeupEngineManager.set_assistant_activated(appid, activated); @@ -310,13 +310,27 @@ bool CWakeupManager::set_assistant_enabled(string appid, bool enabled) bool CWakeupManager::set_default_assistant(string appid) { - MWR_LOGE("[ENTER] %s", appid.c_str()); + MWR_LOGE("[ENTER] %s %s", appid.c_str(), mCurrentDefaultAssistant.c_str()); + + process_default_assistant_changed(appid); + + mWakeupSettings.set_default_assistant_appid(appid); + + return true; +} + +bool CWakeupManager::process_default_assistant_changed(string appid) +{ + MWR_LOGE("[ENTER] %s %s", appid.c_str(), mCurrentDefaultAssistant.c_str()); + + if (mCurrentDefaultAssistant.compare(appid) == 0) { + MWR_LOGE("Default assistant appid not changed, ignoring..."); + return false; + } if (mWakeupManagerState == WAKEUP_MANAGER_STATE_UTTERANCE || mWakeupManagerState == WAKEUP_MANAGER_STATE_PROCESSING) { - if (mCurrentDefaultAssistant.compare(appid) != 0) { - update_recognition_result(mCurrentDefaultAssistant, MA_RECOGNITION_RESULT_EVENT_ERROR); - } + update_recognition_result(mCurrentDefaultAssistant, MA_RECOGNITION_RESULT_EVENT_ERROR); } /* Check if previous default assistant has to be deactivated */ @@ -331,6 +345,7 @@ bool CWakeupManager::set_default_assistant(string appid) /* New default assistant has to be activated no matter what */ mWakeupEngineManager.set_assistant_activated(appid, true); + mCurrentDefaultAssistant = appid; MWR_LOGD("[END]"); @@ -339,7 +354,7 @@ bool CWakeupManager::set_default_assistant(string appid) string CWakeupManager::get_default_assistant() { - return mCurrentDefaultAssistant; + return mWakeupSettings.get_default_assistant_appid(); } bool CWakeupManager::get_assistant_enabled(string appid) @@ -378,7 +393,7 @@ bool CWakeupManager::set_language(string language) if (false == mAssistantEnabled[info.appid]) { disable = true; } - if (0 == info.appid.compare(mCurrentDefaultAssistant)) { + if (0 == info.appid.compare(mWakeupSettings.get_default_assistant_appid())) { /* Default Assistant should be activated no matter what */ disable = false; } @@ -575,7 +590,8 @@ bool CWakeupManager::process_plugin_event(mas_plugin_event_e event, void* data, wakeup_info.wakeup_end_time = get_current_milliseconds_after_epoch(); wakeup_info.wakeup_engine = WAKEUP_ENGINE_VOICE_KEY; - wakeup_info.wakeup_appid = mCurrentDefaultAssistant.c_str(); + std::string default_assistant_appid = mWakeupSettings.get_default_assistant_appid(); + wakeup_info.wakeup_appid = default_assistant_appid.c_str(); MWR_LOGD("wakeup_appid : %s", wakeup_info.wakeup_appid); set_last_wakeup_event_info(wakeup_info); @@ -879,6 +895,7 @@ bool CWakeupManager::unset_voice_key_tap_duration() bool CWakeupManager::set_voice_key_support_mode(VOICE_KEY_SUPPORT_MODE mode) { + MWR_LOGI("Voice key support mode : %d", mode); mCurrentVoiceKeySupportMode = mode; return true; } @@ -1077,7 +1094,7 @@ void CWakeupManager::CPolicyEventObserver::on_wakeup(mas_wakeup_event_info wakeu if (nullptr == audio_manager || nullptr == engine_manager || nullptr == settings) return; if (wakeup_info.wakeup_appid && strlen(wakeup_info.wakeup_appid) > 0) { - settings->set_default_assistant_appid(wakeup_info.wakeup_appid); + mWakeupManager->set_default_assistant(wakeup_info.wakeup_appid); } mWakeupManager->stop_streaming_utterance_data(); @@ -1157,7 +1174,7 @@ bool CWakeupManager::CSettingsEventObserver::on_default_assistant_appid_changed( const char* appid) { if (nullptr == mWakeupManager || nullptr == appid) return false; - mWakeupManager->set_default_assistant(std::string(appid)); + mWakeupManager->process_default_assistant_changed(std::string(appid)); vector observers = mWakeupManager->get_setting_observers(); for (const auto& observer : observers) { observer->on_value_changed(); diff --git a/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp b/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp index eb22125..00c258f 100644 --- a/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp +++ b/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp @@ -19,6 +19,25 @@ #include +#if 0 +#define BUF_SAVE_MODE +#endif +#if 0 +#define BUF_LOAD_MODE +#endif + +#ifdef BUF_SAVE_MODE +static char g_temp_file_name[128] = {'\0', }; + +static FILE* g_pFile = NULL; + +static int g_count = 1; +#endif + +#ifdef BUF_LOAD_MODE +static FILE* g_pFile = NULL; +#endif + using namespace multiassistant::wakeup; static wakeup_service_wakeup_event_cb g_wakeup_event_cb; @@ -75,6 +94,30 @@ static std::unique_ptr g_wakeup_event_observer; static std::unique_ptr g_setting_value_observer; static std::unique_ptr g_wakeup_manager; +int wakeup_manager_feed_audio_data(mas_speech_streaming_event_e event, void* buffer, int len); + +#ifdef BUF_LOAD_MODE +static Eina_Bool file_read_feed(void *data) +{ + if (g_pFile == NULL) { + g_pFile = fopen("/tmp/ma_feed_file", "rb"); + if (g_pFile == NULL) return EINA_FALSE; + } + + if (feof(g_pFile)) { + fclose(g_pFile); + return EINA_FALSE; + } + + const size_t BUFFER_SIZE = 4096; + unsigned char buffer[BUFFER_SIZE]; + size_t len = fread(buffer, sizeof(unsigned char), BUFFER_SIZE, g_pFile); + wakeup_manager_feed_audio_data(MAS_SPEECH_STREAMING_EVENT_CONTINUE, buffer, len); + + return EINA_TRUE; +} +#endif + int wakeup_manager_initialize(void) { MWR_LOGI("[ENTER]"); @@ -127,6 +170,45 @@ int wakeup_manager_initialize(void) g_wakeup_manager->initialize(); MWR_LOGD("[END]"); + +#ifdef BUF_SAVE_MODE + if (g_pFile) { + fclose(g_pFile); + g_pFile = NULL; + } else { + MWR_LOGD("[Recorder Info] File not found!"); + } + + while (1) { + snprintf(g_temp_file_name, sizeof(g_temp_file_name), "/tmp/wakeup_manager_%d_%d", getpid(), g_count); + int ret = access(g_temp_file_name, 0); + + if (0 == ret) { + MWR_LOGD("[Recorder ERROR] File is already exist"); + if (0 == remove(g_temp_file_name)) { + MWR_LOGD("[Recorder] Remove file"); + break; + } else { + g_count++; + } + } else { + break; + } + } + + MWR_LOGD("[Recorder] Temp file name=[%s]", g_temp_file_name); + + /* open test file */ + g_pFile = fopen(g_temp_file_name, "wb+x"); + if (!g_pFile) { + MWR_LOGD("[Recorder ERROR] File not found!"); + } + g_count++; +#endif + +#ifdef BUF_LOAD_MODE + Ecore_Timer* timer = ecore_timer_add(0.01f, file_read_feed, NULL); +#endif return 0; } @@ -134,6 +216,14 @@ int wakeup_manager_deinitialize(void) { MWR_LOGI("[ENTER]"); +#ifdef BUF_SAVE_MODE + if (g_pFile) { + MWR_LOGE("[Recorder SUCCESS] File Close"); + fclose(g_pFile); + g_pFile = NULL; + } +#endif + if (nullptr == g_wakeup_manager) return -1; try { @@ -744,6 +834,13 @@ int wakeup_manager_feed_audio_data(mas_speech_streaming_event_e event, void* buf { if (nullptr == g_wakeup_manager) return -1; +#ifdef BUF_SAVE_MODE + static int num = 0; + const int MAXIMUM_NUM = 1000; + if (g_pFile && num++ < MAXIMUM_NUM) + fwrite(buffer, 1, len, g_pFile); +#endif + g_wakeup_manager->feed_audio_data(event, buffer, len); return 0; diff --git a/plugins/wakeup-manager/src/wakeup_settings.cpp b/plugins/wakeup-manager/src/wakeup_settings.cpp index 4022002..329d4c3 100644 --- a/plugins/wakeup-manager/src/wakeup_settings.cpp +++ b/plugins/wakeup-manager/src/wakeup_settings.cpp @@ -263,10 +263,10 @@ string CWakeupSettings::get_default_assistant_appid() { char *vconf_str; vconf_str = vconf_get_str(WAKEUP_SETTINGS_KEY_DEFAULT_ASSISTANT_APPID); - MWR_LOGD("default_assistant_appid : %s", vconf_str); + MWR_LOGD("vconf default_assistant_appid : %s", vconf_str); if (vconf_str) { mDefaultAssistantAppid = vconf_str; - MWR_LOGD("default_assistant_appid : %s", mDefaultAssistantAppid.c_str()); + MWR_LOGD("member default_assistant_appid : %s", mDefaultAssistantAppid.c_str()); free(vconf_str); vconf_str = nullptr; } @@ -276,6 +276,10 @@ string CWakeupSettings::get_default_assistant_appid() void CWakeupSettings::set_default_assistant_appid(std::string appid) { + if (appid.compare(get_default_assistant_appid()) == 0) { + MWR_LOGE("Default assistant appid not changed, ignoring..."); + return; + } int ret = vconf_set_str(WAKEUP_SETTINGS_KEY_DEFAULT_ASSISTANT_APPID, appid.c_str()); MWR_LOGD("default_assistant_appid : %s, %d", appid.c_str(), ret); mDefaultAssistantAppid = appid; diff --git a/src/client_manager.cpp b/src/client_manager.cpp index e380782..458c384 100644 --- a/src/client_manager.cpp +++ b/src/client_manager.cpp @@ -76,7 +76,6 @@ int CClientManager::destroy_client_by_appid(std::string appid) ma_client_s* CClientManager::find_client_by_appid(std::string appid) { - MAS_LOGD("Looking for client with appid : %s", appid.c_str()); ma_client_s *data = NULL; int count = g_slist_length(mClientList); @@ -87,13 +86,12 @@ ma_client_s* CClientManager::find_client_by_appid(std::string appid) if (NULL != data) { if (0 == appid.compare(data->appid)) { - MAS_LOGD("Found client : %s %d", data->appid.c_str(), data->pid); return data; } } } - MAS_LOGE("[ERROR] client Not found"); + MAS_LOGE("[ERROR] client Not found : %s", appid.c_str()); return NULL; } @@ -142,7 +140,6 @@ pid_t CClientManager::find_client_pid_by_index(unsigned int index) pid_t CClientManager::find_client_pid_by_appid(std::string appid) { - MAS_LOGD("Checking PID of appid : %s", appid.c_str()); pid_t pid = -1; if (nullptr == mApplicationManager) { @@ -152,7 +149,6 @@ pid_t CClientManager::find_client_pid_by_appid(std::string appid) ma_client_s* client = find_client_by_appid(appid); if (client) { - MAS_LOGD("Found client : %s %d", client->appid.c_str(), client->pid); bool running = mApplicationManager->is_application_running(client->pid); if (false == running) { MAS_LOGE("The PID for %s was %d, but it seems to be terminated", diff --git a/src/service_main.cpp b/src/service_main.cpp index 635f895..96cba78 100644 --- a/src/service_main.cpp +++ b/src/service_main.cpp @@ -945,6 +945,8 @@ const char* CServiceMain::get_client_appid_by_wakeup_word(const char *wakeup_wor int CServiceMain::set_current_client_by_wakeup_word(const char *wakeup_word) { + LOGI("[ENTER] %s", wakeup_word); + int loop; int ret = -1; int prev_selection = mCurrentClientInfo; @@ -1006,6 +1008,8 @@ int CServiceMain::set_current_client_by_wakeup_word(const char *wakeup_word) int CServiceMain::set_current_client_by_appid(const char *appid) { + LOGI("[ENTER] %s", appid); + int ret = -1; int prev_selection = mCurrentClientInfo; @@ -1039,6 +1043,7 @@ int CServiceMain::set_current_client_by_appid(const char *appid) int CServiceMain::launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE launch_mode) { + LOGI("[ENTER] %s", appid); int result = 0; if (NULL == appid || 0 == strlen(appid)) { @@ -1069,7 +1074,7 @@ int CServiceMain::launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE l } } } - MAS_LOGD("mWakeupClientAppId : %s, %d", mWakeupClientAppId.c_str(), found); + MAS_LOGE("mWakeupClientAppId : %s, %d", mWakeupClientAppId.c_str(), found); } return result; @@ -1077,6 +1082,7 @@ int CServiceMain::launch_client_by_appid(const char *appid, CLIENT_LAUNCH_MODE l int CServiceMain::bring_client_to_foreground(const char* appid) { + LOGI("[ENTER]"); int ret = 0; if (NULL == appid || 0 == strlen(appid)) { @@ -1099,6 +1105,7 @@ int CServiceMain::launch_client_by_wakeup_word(const char *wakeup_word) int CServiceMain::prelaunch_default_assistant() { + LOGI("[ENTER]"); /* CHECK NEEDED : should the code segment below and activation logic above be moved to wakeup manger? */ boost::optional prelaunch_mode = mPreferenceManager.get_bool(WAKEUP_SETTINGS_KEY_PRELAUNCH_MODE); @@ -1117,6 +1124,7 @@ int CServiceMain::prelaunch_default_assistant() int CServiceMain::update_voice_key_support_mode() { + LOGI("[ENTER]"); /* CHECK NEEDED : should the code segment below and activation logic above be moved to wakeup manger? */ bool successful = false; const char *default_assistant = NULL; @@ -1124,6 +1132,7 @@ int CServiceMain::update_voice_key_support_mode() for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM; loop++) { ClientInfoItems *items = mClientInfo.getItems(); if (items[loop].used) { + LOGI("APPID : %s", items[loop].appid); if (default_assistant && strncmp(default_assistant, items[loop].appid, MAX_APPID_LEN) == 0) { float duration = items[loop].voice_key_tap_duration; @@ -1141,6 +1150,7 @@ int CServiceMain::update_voice_key_support_mode() } if (!successful) { + LOGE("VOICE KEY SUPPORT MODE update not successful!!!"); mServicePlugin.unset_voice_key_tap_duration(); mServicePlugin.set_voice_key_support_mode(VOICE_KEY_SUPPORT_MODE_NONE); } -- 2.7.4