#define MAS_METHOD_STREAMING_AUDIO_DATA "mas_method_streaming_audio_data"
#define MAS_METHOD_WAKEUP_ENGINE_COMMAND "mas_method_wakeup_engine_command"
#define MAS_METHOD_ERROR "mas_method_error"
+#define MAS_METHOD_SEND_PREPROCESSING_INFORMATION "mas_method_send_preprocessing_information"
#define MAS_UI_METHOD_SEND_ASR_RESULT "mas_ui_method_send_asr_result"
#define MAS_UI_METHOD_SEND_RESULT "mas_ui_method_send_result"
return 0;
}
+int masc_dbus_send_preprocessing_information(int pid, const char* app_id)
+{
+ if (0 != __dbus_check()) {
+ return -1; //MAS_ERROR_OPERATION_FAILED;
+ }
+
+ DBusMessage* msg;
+
+ DBusError err;
+ dbus_error_init(&err);
+
+ char service_name[64];
+ memset(service_name, '\0', 64);
+ snprintf(service_name, 64, "%s_%d", MA_CLIENT_SERVICE_NAME, pid);
+
+ msg = dbus_message_new_method_call(
+ service_name,
+ MA_CLIENT_SERVICE_OBJECT_PATH,
+ MA_CLIENT_SERVICE_INTERFACE,
+ MAS_METHOD_SEND_PREPROCESSING_INFORMATION);
+
+ static int count = 0;
+ if (NULL == msg) {
+ MAS_LOGE(">>>> Request mas send preprocessing assistant information : Fail to make message");
+ return -1; // MAS_ERROR_OPERATION_FAILED;
+ } else {
+ MAS_LOGD(">>>> Request mas send preprocessing assistant information : %s", service_name);
+ }
+
+ char* temp_app_id = NULL;
+ if (!app_id)
+ temp_app_id = strdup("#NULL");
+ else
+ temp_app_id = strdup(app_id);
+
+ if (true != dbus_message_append_args(msg,
+ DBUS_TYPE_STRING, &temp_app_id,
+ DBUS_TYPE_INVALID)) {
+ dbus_message_unref(msg);
+ MAS_LOGE("[ERROR] Fail to append args");
+ if (temp_app_id)
+ free(temp_app_id);
+ return -1;
+ }
+
+ dbus_message_set_no_reply(msg, TRUE);
+
+ if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) {
+ MAS_LOGE("[Dbus ERROR] Fail to Send");
+ if (temp_app_id)
+ free(temp_app_id);
+ return -1; // MAS_ERROR_OPERATION_FAILED;
+ } else {
+ MAS_LOGD("[Dbus DEBUG] Success to Send preprocessing assistant information : %s", app_id);
+ dbus_connection_flush(g_conn_sender);
+ }
+
+ dbus_message_unref(msg);
+
+ if (temp_app_id)
+ free(temp_app_id);
+
+ return 0;
+}
+
int masc_ui_dbus_send_hello(void)
{
if (0 != __dbus_check()) {
int masc_dbus_active_state_change(int pid, int state);
+int masc_dbus_send_preprocessing_information(int pid, const char* app_id);
+
int masc_ui_dbus_send_hello(void);
int masc_ui_dbus_send_asr_result(int pid, int event, char* asr_result);
#define MULTI_ASSISTANT_SETTINGS_ACTIVATED "db/multi-assistant/activated"
#define WAKEUP_SETTINGS_KEY_DEFAULT_ASSISTANT_APPID "db/multi-assistant/default_assistant_appid"
+#define WAKEUP_SETTINGS_KEY_PREPROCESSING_ASSISTANT_APPID "db/multi-assistant/preprocessing_assistant_appid"
#define WAKEUP_SETTINGS_KEY_PRELAUNCH_MODE "db/multi-assistant/prelaunch_mode"
#define MAX_MACLIENT_INFO_NUM 16
if (g_wakeup_maclient_appid && strncmp(g_wakeup_maclient_appid, appid, MAX_APPID_LEN) == 0) {
g_wakeup_maclient_appid = NULL;
+ mas_client_send_preprocessing_information(pid);
mas_client_activate(pid);
} else {
MAS_LOGE("[ERROR] g_wakeup_maclient_appid and appid differ : %s %s",
return ret;
}
-int mas_client_activate(int pid)
+bool check_pid_is_current_maclient(int pid)
{
- int ret = -1;
- MAS_LOGD("[Enter] pid(%d)", pid);
-
+ bool ret = false;
char appid[MAX_APPID_LEN] = {'\0',};
if (AUL_R_OK == aul_app_get_appid_bypid(pid, appid, sizeof(appid))) {
appid[MAX_APPID_LEN - 1] = '\0';
}
if (current_maclient_appid && 0 == strncmp(current_maclient_appid, appid, MAX_APPID_LEN)) {
- MAS_LOGD("appid %s matches with current MA Client, activating", appid);
- /*
- ret = multi_assistant_service_plugin_start_streaming_utterance_data();
- if (0 != ret) {
- MAS_LOGE("[ERROR] Fail to request speech data(%d)", ret);
- }
- */
- masc_dbus_active_state_change(pid, MA_ACTIVE_STATE_ACTIVE);
+ ret = true;
} else {
MAS_LOGE("appid %s does not match with current MA Client", appid);
}
}
+ return ret;
+}
+
+int mas_client_send_preprocessing_information(int pid)
+{
+ int ret = -1;
+ MAS_LOGD("[Enter] pid(%d)", pid);
+
+ if (check_pid_is_current_maclient(pid)) {
+ char* vconf_str = vconf_get_str(WAKEUP_SETTINGS_KEY_PREPROCESSING_ASSISTANT_APPID);
+ MAS_LOGD("preprocessing_assistant_appid : %s", vconf_str);
+ ret = masc_dbus_send_preprocessing_information(pid, vconf_str);
+ free(vconf_str);
+ vconf_str = NULL;
+ }
+
+ return ret;
+}
+
+int mas_client_activate(int pid)
+{
+ int ret = -1;
+ MAS_LOGD("[Enter] pid(%d)", pid);
+
+ if (check_pid_is_current_maclient(pid)) {
+ MAS_LOGD("pid %d matches with current MA Client, activating", pid);
+ ret = masc_dbus_active_state_change(pid, MA_ACTIVE_STATE_ACTIVE);
+ }
return ret;
}
if (pid != -1) {
/* Bring MA client to foreground - is there a better way instead of launching? */
mas_launch_client_by_appid(appid, CLIENT_LAUNCH_MODE_ACTIVATION);
+ mas_client_send_preprocessing_information(pid);
masc_dbus_active_state_change(pid, MA_ACTIVE_STATE_ACTIVE);
MAS_LOGD("MA Client with appid %s exists, requesting speech data", (appid ? appid : "NULL"));
/*
mas_set_current_client_by_appid(appid);
if (ui_panel_enabled) masc_ui_dbus_change_assistant(appid);
if ((pid = mas_get_client_pid_by_appid(appid)) != -1) {
+ mas_client_send_preprocessing_information(pid);
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_appid(appid, CLIENT_LAUNCH_MODE_ACTIVATION);