Fix stte TC fail while tct-mgr execute 29/228229/1
authorwn.jang <wn.jang@samsung.com>
Fri, 20 Mar 2020 01:32:30 +0000 (10:32 +0900)
committerwn.jang <wn.jang@samsung.com>
Fri, 20 Mar 2020 01:32:30 +0000 (10:32 +0900)
Change-Id: I82aa425cd7b89703cd03d86d4c03ea302251d5b6

server/stte.c

index 04b86ad..48ddc0f 100755 (executable)
@@ -11,7 +11,9 @@
 *  limitations under the License.
 */
 
+#include <aul.h>
 #include <Ecore.h>
+#include <vconf.h>
 
 #include "stt_engine.h"
 #include "stt_defs.h"
 
 #include "stte.h"
 
+static bool __is_default_engine()
+{
+       char* engine = NULL;
+       engine = vconf_get_str(VCONFKEY_STT_ENGINE_DEFAULT);
+       if (NULL == engine) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get sting for stt engine");
+               return FALSE;
+       }
+
+       char appid[1024] = {'\0', };
+       if (0 != aul_app_get_appid_bypid(getpid(), appid, sizeof(appid) - 1)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get callee appid by pid");
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTD, "[Server] STT Default Engine(%s), appId(%s)", engine, appid);
+       if (0 == strncmp(engine, appid, strlen(engine))) {
+               free(engine);
+               return TRUE;
+       }
+       free(engine);
+       return FALSE;
+}
 
 int stte_main(int argc, char**argv, stte_request_callback_s *callback)
 {
@@ -33,10 +57,12 @@ int stte_main(int argc, char**argv, stte_request_callback_s *callback)
                return STTE_ERROR_OPERATION_FAILED;
        }
 
-       if (0 != sttd_dbus_open_connection()) {
-               SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Fail to open connection");
-               ecore_shutdown();
-               return STTE_ERROR_OPERATION_FAILED;
+       if (TRUE == __is_default_engine()) {
+               if (0 != sttd_dbus_open_connection()) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Fail to open connection");
+                       ecore_shutdown();
+                       return STTE_ERROR_OPERATION_FAILED;
+               }
        }
 
        ret = sttd_initialize(callback);