return 0;
}
+int masc_dbus_send_preprocessing_result(int pid, bool result)
+{
+ 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_RESULT);
+
+ static int count = 0;
+ if (NULL == msg) {
+ MAS_LOGE(">>>> Request mas send preprocessing result : Fail to make message");
+ return -1; // MAS_ERROR_OPERATION_FAILED;
+ } else {
+ MAS_LOGD(">>>> Request mas send preprocessing result : %s", service_name);
+ }
+
+ int temp_result = result;
+
+ if (true != dbus_message_append_args(msg,
+ DBUS_TYPE_INT32, &temp_result,
+ DBUS_TYPE_INVALID)) {
+ dbus_message_unref(msg);
+ MAS_LOGE("[ERROR] Fail to append args");
+ 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");
+ return -1; // MAS_ERROR_OPERATION_FAILED;
+ } else {
+ MAS_LOGD("[Dbus DEBUG] Success to Send preprocessing result : %d", temp_result);
+ dbus_connection_flush(g_conn_sender);
+ }
+
+ dbus_message_unref(msg);
+
+ return 0;
+}
+
int masc_ui_dbus_send_hello(void)
{
if (0 != __dbus_check()) {
} ma_client_s;
static int g_current_maclient_info = 0;
+static int g_current_preprocessing_maclient_info = -1;
static const char *g_wakeup_maclient_appid = NULL;
static PREPROCESSING_STATE g_current_preprocessing_state = PREPROCESSING_STATE_NONE;
for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM; loop++) {
if (g_maclient_info[loop].used) {
if (strncmp(vconf_str, g_maclient_info[loop].appid, MAX_APPID_LEN) == 0) {
- ret = true;
+ ma_client_s* client = ma_client_find_by_appid(vconf_str);
+ if (client && client->pid > 0) {
+ ret = true;
+ }
}
}
}
vconf_str = NULL;
}
+ MAS_LOGD("result : %d", ret);
+
return ret;
}
current_maclient_appid = g_maclient_info[g_current_maclient_info].appid;
}
+ mas_client_send_preprocessing_information(pid);
if (current_maclient_appid && 0 == strncmp(current_maclient_appid, appid, MAX_APPID_LEN)) {
MAS_LOGD("MA client with current maclient appid connected!");
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);
mas_process_preprocessing_state_event(PREPROCESSING_STATE_EVENT_ACTIVE_ASSISTANT_LAUNCHED);
} else {
return ret;
}
-bool check_pid_is_current_maclient(int 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';
- const char *current_maclient_appid = NULL;
- if (g_current_maclient_info >= 0 && g_current_maclient_info < MAX_MACLIENT_INFO_NUM) {
- current_maclient_appid = g_maclient_info[g_current_maclient_info].appid;
- }
-
- if (current_maclient_appid && 0 == strncmp(current_maclient_appid, appid, MAX_APPID_LEN)) {
- 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;
- }
+ 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;
}
}
if (!is_current_preprocessing_assistant(pid_appid)) return -1;
+ const char *current_maclient_appid = NULL;
+ if (g_current_maclient_info >= 0 && g_current_maclient_info < MAX_MACLIENT_INFO_NUM) {
+ current_maclient_appid = g_maclient_info[g_current_maclient_info].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);
}
+
+ ma_client_s* client = ma_client_find_by_appid(current_maclient_appid);
+ if (client) {
+ masc_dbus_send_preprocessing_result(client->pid, result);
+ }
+
return 0;
}
strncpy(g_maclient_info[index].appid, appid, MAX_APPID_LEN);
g_maclient_info[index].appid[MAX_APPID_LEN - 1] = '\0';
+ if (is_current_preprocessing_assistant(g_maclient_info[index].appid)) {
+ g_current_preprocessing_maclient_info = index;
+ }
+
for (loop = 0;loop < MAX_WAKEUP_WORDS_NUM;loop++) {
if (loop < cnt_wakeup && wakeup_list[loop]) {
MAS_LOGD("wakeup_list(%d)(%s)(%s)", loop, wakeup_list[loop], wakeup_language[loop]);
{
int ret = -1;
if (g_current_maclient_info >= 0 && g_current_maclient_info < MAX_MACLIENT_INFO_NUM) {
- const char *current_maclient_appid = g_maclient_info[g_current_maclient_info].appid;
- ma_client_s* client = ma_client_find_by_appid(current_maclient_appid);
+ const char *appid = g_maclient_info[g_current_maclient_info].appid;
+ ma_client_s* client = ma_client_find_by_appid(appid);
+ if (client) {
+ ret = client->pid;
+ }
+ }
+ return ret;
+}
+
+int mas_get_current_preprocessing_client_pid()
+{
+ int ret = -1;
+ if (g_current_preprocessing_maclient_info >= 0 && g_current_preprocessing_maclient_info < MAX_MACLIENT_INFO_NUM) {
+ const char *appid = g_maclient_info[g_current_preprocessing_maclient_info].appid;
+ ma_client_s* client = ma_client_find_by_appid(appid);
if (client) {
ret = client->pid;
}