Fix ttse TC fail while tct-mgr execute 13/228513/2
authorwn.jang <wn.jang@samsung.com>
Mon, 23 Mar 2020 10:45:47 +0000 (19:45 +0900)
committerwn.jang <wn.jang@samsung.com>
Mon, 23 Mar 2020 10:51:36 +0000 (19:51 +0900)
ttse_ 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: Id19e6378674d605382e56d8e61663acc72331001

server/ttsd_engine_agent.c
server/ttse.c

index 83abe14..538647b 100644 (file)
@@ -95,7 +95,7 @@ int ttsd_engine_agent_init()
 {
        if (true == g_agent_init) {
                SLOG(LOG_WARN, tts_tag(), "[Engine Agent] Already initialized");
-               return TTSD_ERROR_OPERATION_FAILED;
+               return TTSD_ERROR_NONE;
        }
 
        ttsengine_info_s* temp;
@@ -267,12 +267,6 @@ int ttsd_engine_agent_load_current_engine(ttse_request_callback_s* callback)
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
-       /* check whether current engine is loaded or not */
-       if (true == g_engine_info->is_loaded) {
-               SLOG(LOG_ERROR, tts_tag(), "[Engine Agent] Engine has already been loaded ");
-               return 0;
-       }
-
        if (NULL == callback) {
                SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Invalid engine");
                return TTSD_ERROR_ENGINE_NOT_FOUND;
@@ -289,6 +283,12 @@ int ttsd_engine_agent_load_current_engine(ttse_request_callback_s* callback)
                return TTSD_ERROR_ENGINE_NOT_FOUND;
        }
 
+       /* check whether current engine is loaded or not */
+       if (true == g_engine_info->is_loaded) {
+               SLOG(LOG_INFO, tts_tag(), "[Engine Agent] Engine has already been loaded ");
+               return 0;
+       }
+
        /* Get current engine info */
        int ret = __internal_get_engine_info(callback);
        if (0 != ret) {
index 4ba73d7..0b91a2b 100755 (executable)
 #include "ttsd_dbus.h"
 #include "ttsd_network.h"
 
+#include <aul.h>
 #include <bundle.h>
 #include <bundle_internal.h>
 #include <dlog.h>
 #include <Ecore.h>
+#include <vconf.h>
 
 #include "ttse.h"
 #include "ttse_internal.h"
@@ -51,6 +53,29 @@ void ttsd_set_mode(ttsd_mode_e mode)
        return;
 }
 
+static bool __is_default_engine()
+{
+       char* engine = NULL;
+       engine = vconf_get_str(VCONFKEY_TTS_ENGINE_DEFAULT);
+       if (NULL == engine) {
+               SLOG(LOG_ERROR, tts_tag(), "[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, tts_tag(), "[Server ERROR] Fail to get callee appid by pid");
+       }
+
+       SLOG(LOG_DEBUG, tts_tag(), "[Server] TTS Default Engine(%s), appId(%s)", engine, appid);
+       if (0 == strncmp(engine, appid, strlen(engine))) {
+               free(engine);
+               return TRUE;
+       }
+       free(engine);
+       return FALSE;
+}
+
 int ttse_main(int argc, char** argv, ttse_request_callback_s *callback)
 {
        bundle *b = NULL;
@@ -95,15 +120,16 @@ int ttse_main(int argc, char** argv, ttse_request_callback_s *callback)
        ret = ttsd_initialize(callback);
        if (0 != ret) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to initialize");
-               ttsd_dbus_close_connection();
                ecore_shutdown();
                return ret;
        }
 
-       if (0 != ttsd_dbus_open_connection()) {
-               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to open dbus connection");
-               ecore_shutdown();
-               return TTSE_ERROR_OPERATION_FAILED;
+       if (TRUE == __is_default_engine()) {
+               if (0 != ttsd_dbus_open_connection()) {
+                       SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to open dbus connection");
+                       ecore_shutdown();
+                       return TTSE_ERROR_OPERATION_FAILED;
+               }
        }
 
        if (0 != ttsd_network_initialize()) {