From: wn.jang Date: Thu, 19 Mar 2020 10:22:48 +0000 (+0900) Subject: Fix vce TC fail while tct-mgr execute X-Git-Tag: accepted/tizen/unified/20200320.074820~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F88%2F228188%2F1;p=platform%2Fcore%2Fuifw%2Fvoice-control.git Fix vce TC fail while tct-mgr execute vce_ prefix TCs are all failed, because dbus_open_connection was already established. So, if only TC case which means that default appid is differ from current appid is, it will ignore to established dbus connection. Change-Id: I955ef8922d4bbc8ba7f74bd1572ee43383c29afc --- diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c index e0cd0c2..1ef35c2 100755 --- a/server/vcd_dbus.c +++ b/server/vcd_dbus.c @@ -58,6 +58,18 @@ static DBusMessage* __get_message(int pid, const char* method, vcd_client_type_e int vcd_dbus_reconnect() { + if (!g_conn_sender || !g_conn_listener) { + vcd_dbus_close_connection(); + + if (0 != vcd_dbus_open_connection()) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to reconnect"); + return -1; + } + + SLOG(LOG_INFO, TAG_VCD, "[DBUS] Reconnect"); + return 0; + } + bool sender_connected = dbus_connection_get_is_connected(g_conn_sender); bool listener_connected = dbus_connection_get_is_connected(g_conn_listener); SLOG(LOG_WARN, TAG_VCD, "[DBUS] Sender(%s) Listener(%s)", @@ -1374,13 +1386,14 @@ int vcd_dbus_close_connection() g_dbus_fd_handler = NULL; } - dbus_bus_release_name(g_conn_listener, VC_SERVER_SERVICE_NAME, &err); + if (NULL != g_conn_listener) { + dbus_bus_release_name(g_conn_listener, VC_SERVER_SERVICE_NAME, &err); - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] dbus_bus_release_name() : %s", err.message); - dbus_error_free(&err); + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] dbus_bus_release_name() : %s", err.message); + dbus_error_free(&err); + } } - __vcd_dbus_connection_free(); return 0; diff --git a/server/vcd_engine_agent.c b/server/vcd_engine_agent.c index 7fa8479..04cbb6a 100644 --- a/server/vcd_engine_agent.c +++ b/server/vcd_engine_agent.c @@ -261,16 +261,16 @@ int vcd_engine_agent_load_current_engine(vce_request_callback_s* callback) return VCD_ERROR_OPERATION_FAILED; } - if (true == g_dynamic_engine.is_loaded) { - SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent] Engine has already been loaded"); - return 0; - } - if (NULL == callback) { SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Invalid engine"); return VCD_ERROR_ENGINE_NOT_FOUND; } + if (true == g_dynamic_engine.is_loaded) { + SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent] Engine has already been loaded"); + return 0; + } + /* Get current engine info */ int ret = __internal_get_engine_info(callback); if (0 != ret) { diff --git a/server/vcd_server.c b/server/vcd_server.c index 98768a1..56df9a5 100755 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -16,8 +16,10 @@ #include #include +#include #include #include +#include #include "vc_cmd_db.h" #include "vc_info_parser.h" @@ -1238,6 +1240,29 @@ static int __vcd_db_clean_up() return ret; } +static bool __is_default_engine() +{ + char* engine = NULL; + engine = vconf_get_str(VCONFKEY_VC_ENGINE_DEFAULT); + if (NULL == engine) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to get sting for vc engine"); + return FALSE; + } + + char appid[1024] = {'\0', }; + if (0 != aul_app_get_appid_bypid(getpid(), appid, sizeof(appid) - 1)) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to get callee appid by pid"); + } + + SLOG(LOG_DEBUG, TAG_VCD, "[Server] VC Default Engine(%s), appId(%s)", engine, appid); + if (0 == strncmp(engine, appid, strlen(engine))) { + free(engine); + return TRUE; + } + free(engine); + return FALSE; +} + int vcd_initialize(vce_request_callback_s *callback) { int ret = 0; @@ -1285,10 +1310,12 @@ int vcd_initialize(vce_request_callback_s *callback) /* Initialize manager info */ vcd_client_manager_unset(); - /* Open dbus connection */ - if (0 != vcd_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to open connection"); - return VCD_ERROR_OPERATION_FAILED; + if (TRUE == __is_default_engine()) { + /* Open dbus connection */ + if (0 != vcd_dbus_open_connection()) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to open connection"); + return VCD_ERROR_OPERATION_FAILED; + } } vcd_config_set_service_state(VCD_STATE_READY);