void CWakeupEventObserver::on_wakeup(wakeup_event_info info)
{
- g_wakeup_event_cb(info, g_wakeup_event_user_data);
+ if (NULL != g_wakeup_event_cb) {
+ g_wakeup_event_cb(info, g_wakeup_event_user_data);
+ }
}
void wakeup_policy_initialize(void)
g_voice_key_pressed = true;
/* (Re)Start recorder thread using bt hid */
g_audio_manager.start_recording();
- for (int loop = 0;loop < g_engine_count;loop++) {
- /* Need to find the default assistant, for now assuming 0 is the one */
- if(loop == 0) {
- wakeup_event_info event;
- event.wakeup_word = "hi bixby";
- event.wakeup_appid = g_wakeup_engine_info[loop].assistant_list.at(0).c_str();
- g_wakeup_event_cb(event, g_wakeup_event_user_data);
- }
+
+ /* Wakeup default assistant */
+ /* TODO: apply conversation timeout for selecting assistant here */
+ wakeup_event_info event;
+ event.wakeup_word = nullptr;
+ event.wakeup_appid = g_wakeup_settings.default_assistant_appid.c_str();
+ if (NULL != g_wakeup_event_cb) {
+ g_wakeup_event_cb(event, g_wakeup_event_user_data);
}
}
} else if (event == MA_PLUGIN_EVENT_VOICE_KEY_RELEASED) {
app_control_destroy (app_control);
if (APP_CONTROL_ERROR_NONE == ret) {
- g_wakeup_maclient_appid = appid;
- MAS_LOGD("g_wakeup_maclient_appid : %s", appid);
+ bool found = false;
+ for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM; loop++) {
+ if (g_maclient_info[loop].used &&
+ 0 < strlen(g_maclient_info[loop].appid)) {
+ if (strncmp(appid, g_maclient_info[loop].appid, MAX_APPID_LEN) == 0) {
+ g_wakeup_maclient_appid = g_maclient_info[loop].appid;
+ found = true;
+ }
+ }
+ }
+ MAS_LOGD("g_wakeup_maclient_appid : %s, %d", g_wakeup_maclient_appid, found);
}
return ret;
}
#endif /* -TEST_CODE */
-Eina_Bool __launch_assistant_by_wakeup_word(void *data)
+Eina_Bool __launch_assistant_by_wakeup_appid_timer(char* appid)
{
MAS_LOGD("[ENTER]");
int pid = -1;
- char *wakeup_word = (char*)data;
- if (!wakeup_word) return EINA_FALSE;
+ if (!appid) return ECORE_CALLBACK_CANCEL;
- mas_set_current_client_by_wakeup_word(wakeup_word);
- masc_ui_dbus_change_assistant(mas_get_client_appid_by_wakeup_word(wakeup_word));
- if ((pid = mas_get_client_pid_by_wakeup_word(wakeup_word)) != -1) {
+ mas_set_current_client_by_appid(appid);
+ masc_ui_dbus_change_assistant(appid);
+ if ((pid = mas_get_client_pid_by_appid(appid)) != -1) {
masc_dbus_active_state_change(pid, MA_ACTIVE_STATE_ACTIVE);
/* Bring MA client to foreground - is there a better way instead of launching? */
- mas_launch_client_by_wakeup_word(wakeup_word);
- /*
- MAS_LOGD("MA Client with wakeup word %s exists, requesting speech data", (wakeup_word ? wakeup_word : "NULL"));
- int ret = -1;
- if (NULL != g_handle) {
- wakeup_manager_start_streaming_utterance_data func =
- _wakeup_manager_interface.start_streaming_utterance_data;
- if (NULL == func) {
- MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_START_STREAMING_UTTERANCE_DATA);
- } else {
- ret = func();
- if (0 != ret) {
- MAS_LOGE("[ERROR] Fail to request speech data(%d)", ret);
- }
- }
- } else {
- MAS_LOGE("[ERROR] g_handle is not valid");
- }
- */
+ mas_launch_client_by_appid(appid);
} else {
// Appropriate MA Client not available, trying to launch new one
- MAS_LOGD("MA Client with wakeup word %s does not exist, launching client", (wakeup_word ? wakeup_word : "NULL"));
- mas_launch_client_by_wakeup_word(wakeup_word);
+ MAS_LOGD("MA Client with appid %s does not exist, launching client", appid);
+ mas_launch_client_by_appid(appid);
}
+ if (appid) free(appid);
+
+ MAS_LOGD("END");
+ return ECORE_CALLBACK_CANCEL;
+}
+
+Eina_Bool __launch_assistant_by_wakeup_word_timer(char* wakeup_word)
+{
+ MAS_LOGD("[ENTER]");
+
+ if (!wakeup_word) return EINA_FALSE;
+
+ const char* appid = mas_get_client_appid_by_wakeup_word(wakeup_word);
+ __launch_assistant_by_wakeup_appid_timer(strdup(appid));
+
if (wakeup_word) free(wakeup_word);
MAS_LOGD("END");
- return EINA_FALSE;
+ return ECORE_CALLBACK_CANCEL;
}
static void __wakeup_event_cb(wakeup_event_info event, void* user_data)
ecore_thread_main_loop_end();
}
#endif /* - TEST_CODE */
- if (event.wakeup_word) {
+ if (event.wakeup_appid) {
+ ecore_thread_main_loop_begin();
+ ecore_timer_add(0.0f, __launch_assistant_by_wakeup_appid_timer, (void*)strdup(event.wakeup_appid));
+ ecore_thread_main_loop_end();
+ } else if (event.wakeup_word) {
ecore_thread_main_loop_begin();
- ecore_timer_add(0.0f, __launch_assistant_by_wakeup_word, (void*)strdup(event.wakeup_word));
+ ecore_timer_add(0.0f, __launch_assistant_by_wakeup_word_timer, (void*)strdup(event.wakeup_word));
ecore_thread_main_loop_end();
}