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};
#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
#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"
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},
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;
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);
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"
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;
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);
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);
/* 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);
/* 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());
}
}
}
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());
+ }
}
}
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);
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]");
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;
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;
+ }
}
}
}
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);
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);
}
}
- 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;
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])) {
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;
+ }
}
}
}
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);
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) {