From: Ji-hoon Lee Date: Mon, 6 Sep 2021 12:00:04 +0000 (+0900) Subject: Make string members of wakeup event struct to be deep copied X-Git-Tag: accepted/tizen/6.5/unified/20211028.121805~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F21%2F263621%2F2;p=platform%2Fcore%2Fuifw%2Fmulti-assistant-service.git Make string members of wakeup event struct to be deep copied This fixes the problem found when running the previously added test. [ RUN ] DefaultFixture.WakeupEventInfoPreservedForStringLiterals [ OK ] DefaultFixture.WakeupEventInfoPreservedForStringLiterals (2 ms) [ RUN ] DefaultFixture.WakeupEventInfoPreservedForDynamicallyAllocatedStrings [ OK ] DefaultFixture.WakeupEventInfoPreservedForDynamicallyAllocatedStrings (0 ms) [----------] 2 tests from DefaultFixture (2 ms total) Change-Id: I24fecd9a78767beda7fafce67f69fae6d53ebf1d --- diff --git a/plugins/wakeup-manager/inc/wakeup_policy_default.h b/plugins/wakeup-manager/inc/wakeup_policy_default.h index 914c539..c0c6efa 100644 --- a/plugins/wakeup-manager/inc/wakeup_policy_default.h +++ b/plugins/wakeup-manager/inc/wakeup_policy_default.h @@ -29,6 +29,18 @@ namespace multiassistant namespace wakeup { +typedef struct { + std::string wakeup_appid; + std::string wakeup_word; + std::string wakeup_language; + std::string wakeup_voice_id; + std::string wakeup_engine; + + std::string extra_data_description; + mas_wakeup_event_info info; +} mas_wakeup_event_info_wrapper; + + using namespace std; class CWakeupPolicyDefault : public CWakeupPolicy @@ -60,7 +72,7 @@ private: float mDelaySeconds{0.0f}; vector mPriorityInfos; - vector mWakeupInfos; + vector mWakeupInfos; Ecore_Timer *mTimer{nullptr}; }; diff --git a/plugins/wakeup-manager/src/wakeup_policy_default.cpp b/plugins/wakeup-manager/src/wakeup_policy_default.cpp index 1199b26..ef1bab5 100644 --- a/plugins/wakeup-manager/src/wakeup_policy_default.cpp +++ b/plugins/wakeup-manager/src/wakeup_policy_default.cpp @@ -75,7 +75,18 @@ static Eina_Bool timer_func(void *data) void CWakeupPolicyDefault::wakeup_candidate(mas_wakeup_event_info wakeup_info) { MWR_LOGI("[ENTER]"); - mWakeupInfos.push_back(wakeup_info); + mas_wakeup_event_info_wrapper wrapper; + if (wakeup_info.wakeup_appid) wrapper.wakeup_appid = wakeup_info.wakeup_appid; + if (wakeup_info.wakeup_word) wrapper.wakeup_word = wakeup_info.wakeup_word; + if (wakeup_info.wakeup_language) wrapper.wakeup_language = wakeup_info.wakeup_language; + if (wakeup_info.wakeup_voice_id) wrapper.wakeup_voice_id = wakeup_info.wakeup_voice_id; + if (wakeup_info.wakeup_engine) wrapper.wakeup_engine = wakeup_info.wakeup_engine; + if (wakeup_info.extra_data_description) wrapper.extra_data_description = wakeup_info.extra_data_description; + + wrapper.info = wakeup_info; + + LOGI("wake word : %s", wakeup_info.wakeup_word); + mWakeupInfos.push_back(wrapper); if (nullptr == mTimer) { ecore_main_loop_thread_safe_call_async([](void* data) { CWakeupPolicyDefault* policy = static_cast(data); @@ -98,7 +109,8 @@ void CWakeupPolicyDefault::timer_expired() MWR_LOGD("[ENTER]"); if (0 == mWakeupInfos.size()) return; - mas_wakeup_event_info selected = mWakeupInfos.front(); + mas_wakeup_event_info_wrapper selected = mWakeupInfos.front(); + LOGD("wake word : %s", selected.wakeup_word.c_str()); int selected_priority = -1; for (const auto &wakeup : mWakeupInfos) { for (const auto &info : mPriorityInfos) { @@ -112,7 +124,14 @@ void CWakeupPolicyDefault::timer_expired() } } } - if (mImpl) mImpl->wakeup(selected); + selected.info.wakeup_appid = selected.wakeup_appid.c_str(); + selected.info.wakeup_word = selected.wakeup_word.c_str(); + selected.info.wakeup_language = selected.wakeup_language.c_str(); + selected.info.wakeup_voice_id = selected.wakeup_voice_id.c_str(); + selected.info.wakeup_engine = selected.wakeup_engine.c_str(); + selected.info.extra_data_description = selected.extra_data_description.c_str(); + + if (mImpl) mImpl->wakeup(selected.info); mWakeupInfos.clear(); if (mTimer) {