diff options
-rw-r--r-- | inc/client_info.h | 2 | ||||
-rw-r--r-- | inc/service_common.h | 1 | ||||
-rw-r--r-- | inc/service_config.h | 7 | ||||
-rw-r--r-- | inc/service_plugin.h | 2 | ||||
-rw-r--r-- | inc/service_plugin_interface.h | 6 | ||||
-rw-r--r-- | plugins/wakeup-manager/inc/wakeup_manager.h | 2 | ||||
-rw-r--r-- | plugins/wakeup-manager/inc/wakeup_manager_wrapper.h | 2 | ||||
-rw-r--r-- | plugins/wakeup-manager/src/wakeup_engine_manager.cpp | 9 | ||||
-rw-r--r-- | plugins/wakeup-manager/src/wakeup_manager.cpp | 4 | ||||
-rw-r--r-- | plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp | 4 | ||||
-rw-r--r-- | src/package_update_monitor.cpp | 8 | ||||
-rw-r--r-- | src/service_config.cpp | 42 | ||||
-rw-r--r-- | src/service_main.cpp | 34 | ||||
-rw-r--r-- | src/service_plugin.cpp | 12 |
14 files changed, 92 insertions, 43 deletions
diff --git a/inc/client_info.h b/inc/client_info.h index d2de5a8..fd6da21 100644 --- a/inc/client_info.h +++ b/inc/client_info.h @@ -30,7 +30,7 @@ typedef struct { 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 wakeup_engine[MAX_WAKEUP_ENGINES_NUM][MAX_APPID_LEN]; char supported_language[MAX_SUPPORTED_LANGUAGES_NUM][MAX_SUPPORTED_LANGUAGE_LEN]; bool custom_ui_option{false}; VOICE_KEY_SUPPORT_MODE voice_key_support_mode{VOICE_KEY_SUPPORT_MODE_PUSH_TO_TALK}; diff --git a/inc/service_common.h b/inc/service_common.h index 3da1e46..f650625 100644 --- a/inc/service_common.h +++ b/inc/service_common.h @@ -124,6 +124,7 @@ typedef void (*wakeup_service_voice_key_status_changed_cb)(ma_voice_key_status_e #define MAX_WAKEUP_WORD_LEN 32 #define MAX_SUPPORTED_LANGUAGES_NUM 255 #define MAX_SUPPORTED_LANGUAGE_LEN 16 +#define MAX_WAKEUP_ENGINES_NUM 4 #define MAX_APPID_LEN 255 diff --git a/inc/service_config.h b/inc/service_config.h index 6ce7607..ace3a2a 100644 --- a/inc/service_config.h +++ b/inc/service_config.h @@ -37,6 +37,7 @@ #define MA_TAG_ASSISTANT_LANGUAGE "language" #define MA_TAG_ASSISTANT_WAKEUP_WORD_SET "wakeup-words" #define MA_TAG_ASSISTANT_WAKEUP_WORD "wakeup-word" +#define MA_TAG_ASSISTANT_WAKEUP_ENGINE_SET "wakeup-engines" #define MA_TAG_ASSISTANT_WAKEUP_ENGINE_APPID "wakeup-engine-appid" #define MA_TAG_ASSISTANT_CUSTOM_UI "custom-ui" #define MA_TAG_ASSISTANT_VOICE_KEY_SUPPORT_MODE "voice-key-support-mode" @@ -65,7 +66,8 @@ typedef struct ma_assistant_info_s { cnt_wakeup{0}, supported_lang{0x00, }, cnt_lang{0}, - wakeup_engine{nullptr}, + wakeup_engine{nullptr, }, + cnt_wakeup_engine{0}, custom_ui_option{false}, /* TODO: Define these two default values somewhere else */ voice_key_support_mode{VOICE_KEY_SUPPORT_MODE_PUSH_TO_TALK}, @@ -80,7 +82,8 @@ typedef struct ma_assistant_info_s { int cnt_wakeup; const char* supported_lang[MAX_SUPPORTED_LANGUAGES_NUM]; int cnt_lang; - const char* wakeup_engine; + const char* wakeup_engine[MAX_WAKEUP_ENGINES_NUM]; + int cnt_wakeup_engine; bool custom_ui_option; VOICE_KEY_SUPPORT_MODE voice_key_support_mode; float voice_key_tap_duration; diff --git a/inc/service_plugin.h b/inc/service_plugin.h index a3ed804..112a9cb 100644 --- a/inc/service_plugin.h +++ b/inc/service_plugin.h @@ -38,7 +38,7 @@ public: int add_assistant_wakeup_word(const char* appid, const char* wakeup_word, const char* language); int remove_assistant_wakeup_word(const char* appid, const char* wakeup_word, const char* language); int add_assistant_language(const char* appid, const char* language); - int set_assistant_wakeup_engine(const char* appid, const char* engine); + int add_assistant_wakeup_engine(const char* appid, const char* engine); int set_default_assistant(const char* appid); int get_default_assistant(const char** appid); int activate(void); diff --git a/inc/service_plugin_interface.h b/inc/service_plugin_interface.h index 944a967..1cd8d35 100644 --- a/inc/service_plugin_interface.h +++ b/inc/service_plugin_interface.h @@ -41,8 +41,8 @@ typedef int (*wakeup_manager_add_assistant_wakeup_word)(const char* appid, const typedef int (*wakeup_manager_remove_assistant_wakeup_word)(const char* appid, const char* wakeup_word, const char* language); #define MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_LANGUAGE "wakeup_manager_add_assistant_language" typedef int (*wakeup_manager_add_assistant_language)(const char* appid, const char* language); -#define MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_WAKEUP_ENGINE "wakeup_manager_set_assistant_wakeup_engine" -typedef int (*wakeup_manager_set_assistant_wakeup_engine)(const char* appid, const char* engine); +#define MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_WAKEUP_ENGINE "wakeup_manager_add_assistant_wakeup_engine" +typedef int (*wakeup_manager_add_assistant_wakeup_engine)(const char* appid, const char* engine); #define MA_WAKEUP_MANAGER_FUNC_SET_DEFAULT_ASSISTANT "wakeup_manager_set_default_assistant" typedef int (*wakeup_manager_set_default_assistant)(const char* appid); #define MA_WAKEUP_MANAGER_FUNC_GET_DEFAULT_ASSISTANT "wakeup_manager_get_default_assistant" @@ -119,7 +119,7 @@ typedef struct { wakeup_manager_add_assistant_wakeup_word add_assistant_wakeup_word; wakeup_manager_remove_assistant_wakeup_word remove_assistant_wakeup_word; wakeup_manager_add_assistant_language add_assistant_language; - wakeup_manager_set_assistant_wakeup_engine set_assistant_wakeup_engine; + wakeup_manager_add_assistant_wakeup_engine add_assistant_wakeup_engine; wakeup_manager_set_default_assistant set_default_assistant; wakeup_manager_get_default_assistant get_default_assistant; wakeup_manager_set_language set_language; diff --git a/plugins/wakeup-manager/inc/wakeup_manager.h b/plugins/wakeup-manager/inc/wakeup_manager.h index dc2cbad..657c3ec 100644 --- a/plugins/wakeup-manager/inc/wakeup_manager.h +++ b/plugins/wakeup-manager/inc/wakeup_manager.h @@ -90,7 +90,7 @@ public: bool add_assistant_language(string appid, string language); bool add_assistant_wakeup_word(string appid, string wakeup_word, string language); bool remove_assistant_wakeup_word(string appid, string wakeup_word, string language); - bool set_assistant_wakeup_engine(string appid, string engine); + bool add_assistant_wakeup_engine(string appid, string engine); bool set_assistant_language(string appid, string language); bool set_assistant_enabled(string appid, bool enabled); diff --git a/plugins/wakeup-manager/inc/wakeup_manager_wrapper.h b/plugins/wakeup-manager/inc/wakeup_manager_wrapper.h index 45ac567..3ee305f 100644 --- a/plugins/wakeup-manager/inc/wakeup_manager_wrapper.h +++ b/plugins/wakeup-manager/inc/wakeup_manager_wrapper.h @@ -77,7 +77,7 @@ EXPORT_API int wakeup_manager_remove_assistant_wakeup_word(const char* appid, co EXPORT_API int wakeup_manager_add_assistant_language(const char* appid, const char* language); -EXPORT_API int wakeup_manager_set_assistant_wakeup_engine(const char* appid, const char *engine); +EXPORT_API int wakeup_manager_add_assistant_wakeup_engine(const char* appid, const char *engine); EXPORT_API int wakeup_manager_set_default_assistant(const char* appid); diff --git a/plugins/wakeup-manager/src/wakeup_engine_manager.cpp b/plugins/wakeup-manager/src/wakeup_engine_manager.cpp index 56c06ca..b458553 100644 --- a/plugins/wakeup-manager/src/wakeup_engine_manager.cpp +++ b/plugins/wakeup-manager/src/wakeup_engine_manager.cpp @@ -224,6 +224,7 @@ void CWakeupEngineManager::set_assistant_activated(string appid, bool activated) /* If the appid is in the assistant list */ if (info.assistant_list.end() != iter) { + MWR_LOGI("%s has %s", info.engine_name.c_str(), appid.c_str()); bool previously_activated = info.activated; if (activated) { info.activated_assistants.insert(appid); @@ -250,6 +251,8 @@ void CWakeupEngineManager::set_assistant_activated(string appid, bool activated) /* Activated status changed, need to update audio_data_require_status too */ on_audio_data_require_status(info.engine_name, info.audio_data_require_status); } + } else { + MWR_LOGI("%s does not have %s", info.engine_name.c_str(), appid.c_str()); } } } @@ -558,9 +561,15 @@ void CWakeupEngineManager::engine_add_target_assistant(string engine_name, strin if (mEngineInfo.end() != new_iter) { new_iter->assistant_list.push_back(appid); } + for (const auto assistant : new_iter->assistant_list) { + MWR_LOGI("Assistant List : %s %s", assistant.c_str(), new_iter->engine_name.c_str()); + } } else { /* If the engine already exists, simply add the appid to the assistant list */ iter->assistant_list.push_back(appid); + for (const auto assistant : iter->assistant_list) { + MWR_LOGI("Assistant List : %s %s", assistant.c_str(), iter->engine_name.c_str()); + } } } diff --git a/plugins/wakeup-manager/src/wakeup_manager.cpp b/plugins/wakeup-manager/src/wakeup_manager.cpp index 5399c78..7f856ea 100644 --- a/plugins/wakeup-manager/src/wakeup_manager.cpp +++ b/plugins/wakeup-manager/src/wakeup_manager.cpp @@ -266,9 +266,9 @@ bool CWakeupManager::remove_assistant_wakeup_word(string appid, string wakeup_wo return true; } -bool CWakeupManager::set_assistant_wakeup_engine(string appid, string engine) +bool CWakeupManager::add_assistant_wakeup_engine(string appid, string engine) { - MWR_LOGI("[ENTER]"); + MWR_LOGI("[ENTER] %s %s", appid.c_str(), engine.c_str()); mWakeupEngineManager.engine_add_target_assistant(engine, appid); diff --git a/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp b/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp index d88dd34..9dd7ef2 100644 --- a/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp +++ b/plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp @@ -224,7 +224,7 @@ int wakeup_manager_add_assistant_language(const char* appid, const char* languag return 0; } -int wakeup_manager_set_assistant_wakeup_engine(const char* appid, const char* engine) +int wakeup_manager_add_assistant_wakeup_engine(const char* appid, const char* engine) { MWR_LOGI("[ENTER]"); @@ -235,7 +235,7 @@ int wakeup_manager_set_assistant_wakeup_engine(const char* appid, const char* en if (nullptr == g_wakeup_manager) return -1; MWR_LOGD("[DEBUG] appid(%s), wakeup engine(%s)", appid, engine); - g_wakeup_manager->set_assistant_wakeup_engine(string{appid}, string{engine}); + g_wakeup_manager->add_assistant_wakeup_engine(string{appid}, string{engine}); MWR_LOGD("[END]"); return 0; diff --git a/src/package_update_monitor.cpp b/src/package_update_monitor.cpp index 1a57bd8..db2d16e 100644 --- a/src/package_update_monitor.cpp +++ b/src/package_update_monitor.cpp @@ -73,9 +73,11 @@ static bool is_wakeup_engine(const pkgmgrinfo_appinfo_h handle, CPackageUpdateMo if (PMINFO_R_OK == ret && NULL != appid) { for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM;loop++) { if (clientInfo.getItems()[loop].used) { - LOGD("comparing appid : %s %s", clientInfo.getItems()[loop].wakeup_engine, appid); - if (0 == strncmp(clientInfo.getItems()[loop].wakeup_engine, appid, MAX_APPID_LEN)) { - is_wakeup_engine = true; + for (int inner_loop; inner_loop < MAX_WAKEUP_ENGINES_NUM;inner_loop++) { + LOGD("comparing appid : %s %s", clientInfo.getItems()[loop].wakeup_engine[inner_loop], appid); + if (0 == strncmp(clientInfo.getItems()[loop].wakeup_engine[inner_loop], appid, MAX_APPID_LEN)) { + is_wakeup_engine = true; + } } } } diff --git a/src/service_config.cpp b/src/service_config.cpp index cdf1687..d797480 100644 --- a/src/service_config.cpp +++ b/src/service_config.cpp @@ -128,12 +128,38 @@ int CServiceConfig::parse_assistant_info(service_config_assistant_info_cb callba MAS_LOGD("Icon Path : %s", key); xmlFree(key); } + /* For supporting previous version of schema - START */ } else if (cur->name && 0 == xmlStrcmp(cur->name, (const xmlChar*)MA_TAG_ASSISTANT_WAKEUP_ENGINE_APPID)) { - key = xmlNodeGetContent(cur); - if (key) { - temp.wakeup_engine = strdup((const char*)key); - MAS_LOGD("Wakeup Engine : %s", key); - xmlFree(key); + if (temp.cnt_wakeup_engine == 0) { + key = xmlNodeGetContent(cur); + if (key) { + temp.wakeup_engine[0] = strdup((const char*)key); + MAS_LOGD("Wakeup Engine : %s", key); + xmlFree(key); + } + temp.cnt_wakeup_engine = 1; + } else { + MAS_LOGE("wakeup engine appid with cnt_wakeup_engine (%d) found", temp.cnt_wakeup_engine); + } + /* For supporting previous version of schema - END */ + } else if (cur->name && 0 == xmlStrcmp(cur->name, (const xmlChar *)MA_TAG_ASSISTANT_WAKEUP_ENGINE_SET)) { + xmlNodePtr child_node = cur->xmlChildrenNode; + while (child_node != NULL) { + if (child_node->name && 0 == xmlStrcmp(child_node->name, (const xmlChar*)MA_TAG_ASSISTANT_WAKEUP_ENGINE_APPID)) { + key = xmlNodeGetContent(child_node); + if (key) { + temp.wakeup_engine[temp.cnt_wakeup_engine] = strdup((const char*)key); + MAS_LOGD("Wakeup Engine : %s", key); + xmlFree(key); + } + temp.cnt_wakeup_engine++; + if (temp.cnt_wakeup_engine >= MAX_WAKEUP_ENGINES_NUM) { + MAS_LOGE("cnt_wakeup_engine exceeds : %d", MAX_WAKEUP_ENGINES_NUM); + temp.cnt_wakeup_engine = MAX_WAKEUP_ENGINES_NUM - 1; + } + } + + child_node = child_node->next; } } else if (cur->name && 0 == xmlStrcmp(cur->name, (const xmlChar*)MA_TAG_ASSISTANT_CUSTOM_UI)) { key = xmlNodeGetContent(cur); @@ -200,8 +226,10 @@ int CServiceConfig::parse_assistant_info(service_config_assistant_info_cb callba free((void*)(temp.supported_lang[loop])); } } - if (temp.wakeup_engine) { - free((void*)temp.wakeup_engine); + for (loop = 0; loop < temp.cnt_wakeup_engine; loop++) { + if (temp.wakeup_engine[loop]) { + free((void*)(temp.wakeup_engine[loop])); + } } xmlFreeDoc(doc); diff --git a/src/service_main.cpp b/src/service_main.cpp index b37b422..8d0d1d2 100644 --- a/src/service_main.cpp +++ b/src/service_main.cpp @@ -602,13 +602,15 @@ int CServiceMain::add_assistant_info(ma_assistant_info_s* info) { } } - MAS_LOGD("wakeup_engine(%s)", info->wakeup_engine); - if (info->wakeup_engine) { - strncpy(items[index].wakeup_engine, info->wakeup_engine, MAX_APPID_LEN); - items[index].wakeup_engine[MAX_APPID_LEN - 1] = '\0'; - } else { - items[index].wakeup_engine[0] = '\0'; - MAS_LOGW("Wakeup engine information not provided for : %s", info->app_id); + for (loop = 0;loop < MAX_WAKEUP_ENGINES_NUM;loop++) { + if (loop < info->cnt_wakeup_engine && info->wakeup_engine[loop]) { + MAS_LOGD("wakeup_engine(%s)", info->wakeup_engine[loop]); + strncpy(items[index].wakeup_engine[loop], info->wakeup_engine[loop], MAX_APPID_LEN); + items[index].wakeup_engine[loop][MAX_APPID_LEN - 1] = '\0'; + } else { + items[index].wakeup_engine[loop][0] = '\0'; + MAS_LOGW("Wakeup engine information not provided for : %s", info->app_id); + } } items[index].custom_ui_option = info->custom_ui_option; @@ -682,10 +684,12 @@ int CServiceMain::initialize_service_plugin(void) if (0 < strlen(items[loop].appid)) { mServiceConfig.load_custom_wake_words(items[loop].appid, items[loop].wakeup_word, items[loop].wakeup_language); - if (0 < strlen(items[loop].wakeup_engine)) { - mServicePlugin.set_assistant_wakeup_engine( - items[loop].appid, - items[loop].wakeup_engine); + for (inner_loop = 0; inner_loop < MAX_WAKEUP_ENGINES_NUM; inner_loop++) { + if (0 < strlen(items[loop].wakeup_engine[inner_loop])) { + mServicePlugin.add_assistant_wakeup_engine( + items[loop].appid, + items[loop].wakeup_engine[inner_loop]); + } } for (inner_loop = 0; inner_loop < MAX_WAKEUP_WORDS_NUM; inner_loop++) { if (0 < strlen(items[loop].wakeup_word[inner_loop])) { @@ -1244,9 +1248,11 @@ bool CServiceMain::is_valid_wakeup_engine(const char* appid) for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM;loop++) { ClientInfoItems *items = mClientInfo.getItems(); if (items[loop].used) { - LOGD("comparing appid : %s %s", items[loop].wakeup_engine, appid); - if (0 == strncmp(items[loop].wakeup_engine, appid, MAX_APPID_LEN)) { - return true; + for (int inner_loop; inner_loop < MAX_WAKEUP_ENGINES_NUM;inner_loop++) { + LOGD("comparing appid : %s %s", items[loop].wakeup_engine[inner_loop], appid); + if (0 == strncmp(items[loop].wakeup_engine[inner_loop], appid, MAX_APPID_LEN)) { + return true; + } } } } diff --git a/src/service_plugin.cpp b/src/service_plugin.cpp index 6f820c6..7c96d40 100644 --- a/src/service_plugin.cpp +++ b/src/service_plugin.cpp @@ -560,9 +560,9 @@ int CServicePlugin::initialize(void) mWakeupManagerInterface.add_assistant_language = (wakeup_manager_add_assistant_language)dlsym(mPluginHandle, MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_LANGUAGE); - mWakeupManagerInterface.set_assistant_wakeup_engine = - (wakeup_manager_set_assistant_wakeup_engine)dlsym(mPluginHandle, - MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_WAKEUP_ENGINE); + mWakeupManagerInterface.add_assistant_wakeup_engine = + (wakeup_manager_add_assistant_wakeup_engine)dlsym(mPluginHandle, + MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_WAKEUP_ENGINE); mWakeupManagerInterface.set_default_assistant = (wakeup_manager_set_default_assistant)dlsym(mPluginHandle, MA_WAKEUP_MANAGER_FUNC_SET_DEFAULT_ASSISTANT); @@ -824,13 +824,13 @@ int CServicePlugin::add_assistant_language(const char* appid, const char* langua return ret; } -int CServicePlugin::set_assistant_wakeup_engine(const char* appid, const char* engine) +int CServicePlugin::add_assistant_wakeup_engine(const char* appid, const char* engine) { int ret = -1; if (NULL != mPluginHandle) { - wakeup_manager_set_assistant_wakeup_engine func = mWakeupManagerInterface.set_assistant_wakeup_engine; + wakeup_manager_add_assistant_wakeup_engine func = mWakeupManagerInterface.add_assistant_wakeup_engine; if (NULL == func) { - MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_SET_ASSISTANT_WAKEUP_ENGINE); + MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_ADD_ASSISTANT_WAKEUP_ENGINE); } else { ret = func(appid, engine); if (0 != ret) { |