if (g_wakeup_maclient_appid && strncmp(g_wakeup_maclient_appid, appid, MAX_APPID_LEN) == 0) {
g_wakeup_maclient_appid = NULL;
mas_client_activate(pid);
- mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ACTIVE_ASSISTANT_LAUNCHED);
+ mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED);
} else {
MAS_LOGE("[ERROR] g_wakeup_maclient_appid and appid differ : %s %s",
(g_wakeup_maclient_appid ? g_wakeup_maclient_appid : "NULL"), appid);
if (result) {
MAS_LOGD("Preprocessing succeeded, bring (%s) to foreground", pid_appid);
- mas_bring_client_to_foreground(pid_appid);
mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_PREPROCESSING_SUCCEEDED);
} else {
MAS_LOGD("Preprocessing failed, bring (%s) to foreground", current_maclient_appid);
- mas_bring_client_to_foreground(current_maclient_appid);
mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_PREPROCESSING_FAILED);
}
return MA_PREPROCESSING_ALLOW_NONE;
}
+/* This might need to be read from settings in the future, but using macro for now */
+//#define BRING_PREPROCESSING_ASSISTANT_TO_FRONT
+
int mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT event)
{
const char* current_maclient_appid = NULL;
ma_preprocessing_allow_mode_e mode = get_preprocessing_allow_mode(current_maclient_appid);
switch (event) {
- case PREPROCESSING_STATE_EVENT_WAKEUP:
- case PREPROCESSING_STATE_EVENT_ACTIVE_ASSISTANT_LAUNCHED:
+ case PREPROCESSING_STATE_EVENT_ASSISTANT_ACTIVATED:
{
- if (!check_preprocessing_assistant_exists()) {
- mas_bring_client_to_foreground(current_maclient_appid);
- }
+#ifndef BRING_PREPROCESSING_ASSISTANT_TO_FRONT
+ /* If there is no need to bring preprocessing assistant to front,
+ current_maclient should always be brought to front */
+ mas_bring_client_to_foreground(current_maclient_appid);
+#endif
g_current_preprocessing_state = PREPROCESSING_STATE_WAKEUP_PREPROCESS_DISABLED;
- if (MA_PREPROCESSING_ALLOW_UTTERANCE == mode ||
- MA_PREPROCESSING_ALLOW_ALL == mode) {
- if (is_current_preprocessing_assistant(preprocessing_allow_appid)) {
- g_current_preprocessing_state = PREPROCESSING_STATE_WAKEUP_PREPROCESS_ENABLED;
+ if (check_preprocessing_assistant_exists()) {
+ if (MA_PREPROCESSING_ALLOW_UTTERANCE == mode ||
+ MA_PREPROCESSING_ALLOW_ALL == mode) {
+ if (is_current_preprocessing_assistant(preprocessing_allow_appid)) {
+ g_current_preprocessing_state = PREPROCESSING_STATE_WAKEUP_PREPROCESS_ENABLED;
+ }
}
+ } else {
+#ifdef BRING_PREPROCESSING_ASSISTANT_TO_FRONT
+ /* If preprocessing assistant does not exist, there is no way to enable
+ preprocessing assistant, so bring current maclient to front right away */
+ mas_bring_client_to_foreground(current_maclient_appid);
+#endif
}
}
break;
case PREPROCESSING_STATE_EVENT_PREPROCESSING_ALLOW_MODE_CHANGED:
{
g_current_preprocessing_state = PREPROCESSING_STATE_WAKEUP_PREPROCESS_DISABLED;
- if (MA_PREPROCESSING_ALLOW_UTTERANCE == mode ||
- MA_PREPROCESSING_ALLOW_ALL == mode) {
- if (is_current_preprocessing_assistant(preprocessing_allow_appid)) {
- g_current_preprocessing_state = PREPROCESSING_STATE_WAKEUP_PREPROCESS_ENABLED;
+ /* Enable preprocessing mode only if the preprocessing assistant exists */
+ if (check_preprocessing_assistant_exists()) {
+ if (MA_PREPROCESSING_ALLOW_UTTERANCE == mode ||
+ MA_PREPROCESSING_ALLOW_ALL == mode) {
+ if (is_current_preprocessing_assistant(preprocessing_allow_appid)) {
+ g_current_preprocessing_state = PREPROCESSING_STATE_WAKEUP_PREPROCESS_ENABLED;
+ }
}
}
}
if (PREPROCESSING_STATE_WAKEUP_PREPROCESS_ENABLED == g_current_preprocessing_state) {
g_current_preprocessing_state = PREPROCESSING_STATE_PREPROCESSING_UTTERANCE;
} else if (PREPROCESSING_STATE_WAKEUP_PREPROCESS_DISABLED == g_current_preprocessing_state) {
- mas_bring_client_to_foreground(current_maclient_appid);
+ /* If preprocessing assistant does not exist, the current_maclient
+ would have been brought to front already on wakeup event */
+#ifdef BRING_PREPROCESSING_ASSISTANT_TO_FRONT
+ if (check_preprocessing_assistant_exists()) {
+ mas_bring_client_to_foreground(current_maclient_appid);
+ }
+#endif
g_current_preprocessing_state = PREPROCESSING_STATE_NONE;
}
}
break;
case PREPROCESSING_STATE_EVENT_FOLLOW_UP_STREAMING_STARTED:
{
- if (MA_PREPROCESSING_ALLOW_FOLLOW_UP == mode ||
- MA_PREPROCESSING_ALLOW_ALL == mode) {
- g_current_preprocessing_state = PREPROCESSING_STATE_PREPROCESSING_FOLLOW_UP;
+ g_current_preprocessing_state = PREPROCESSING_STATE_NONE;
+ if (check_preprocessing_assistant_exists()) {
+ if (MA_PREPROCESSING_ALLOW_FOLLOW_UP == mode ||
+ MA_PREPROCESSING_ALLOW_ALL == mode) {
+ g_current_preprocessing_state = PREPROCESSING_STATE_PREPROCESSING_FOLLOW_UP;
+ }
}
}
break;
case PREPROCESSING_STATE_EVENT_PREPROCESSING_SUCCEEDED:
{
+#ifdef BRING_PREPROCESSING_ASSISTANT_TO_FRONT
+ if (PREPROCESSING_STATE_EVENT_UTTERANCE_STREAMING_STARTED == g_current_preprocessing_state ||
+ PREPROCESSING_STATE_EVENT_FOLLOW_UP_STREAMING_STARTED == g_current_preprocessing_state) {
+ char* vconf_str = vconf_get_str(WAKEUP_SETTINGS_KEY_PREPROCESSING_ASSISTANT_APPID);
+ MAS_LOGD("preprocessing_assistant_appid : %s", vconf_str);
+ if (vconf_str) {
+ mas_bring_client_to_foreground(vconf_str);
+ free(vconf_str);
+ vconf_str = NULL;
+ }
+ }
+#endif
g_current_preprocessing_state = PREPROCESSING_STATE_NONE;
}
break;
case PREPROCESSING_STATE_EVENT_PREPROCESSING_FAILED:
{
- mas_bring_client_to_foreground(current_maclient_appid);
+#ifdef BRING_PREPROCESSING_ASSISTANT_TO_FRONT
+ if (PREPROCESSING_STATE_EVENT_UTTERANCE_STREAMING_STARTED == g_current_preprocessing_state ||
+ PREPROCESSING_STATE_EVENT_FOLLOW_UP_STREAMING_STARTED == g_current_preprocessing_state) {
+ mas_bring_client_to_foreground(current_maclient_appid);
+ }
+#endif
g_current_preprocessing_state = PREPROCESSING_STATE_NONE;
}
break;