Launch exact service process for each mode 04/260004/3
authorSuyeon Hwang <stom.hwang@samsung.com>
Fri, 7 May 2021 06:07:13 +0000 (15:07 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Fri, 25 Jun 2021 11:29:46 +0000 (20:29 +0900)
Change-Id: I515b3e552c633d0af75443d643bd012182c23a89
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
client/tts_tidl.c
server/ttse.c

index bc3dc9e..9754996 100644 (file)
@@ -24,6 +24,7 @@ typedef struct {
        int uid;
        bool connected;
        rpc_port_proxy_tts_h rpc_h;
+       int mode;
 } tts_tidl_info_s;
 
 static GList* g_tidl_infos = NULL;
@@ -281,12 +282,6 @@ static rpc_port_proxy_tts_h __open_rpc_port(int uid, int mode)
                return NULL;
        }
 
-       if (0 != rpc_port_proxy_tts_connect(handle)) {
-               rpc_port_proxy_tts_destroy(handle);
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to connect the service");
-               return NULL;
-       }
-
        return handle;
 }
 
@@ -306,18 +301,19 @@ int tts_tidl_open_connection(int uid)
                return TTS_ERROR_OUT_OF_MEMORY;
        }
 
-       info->rpc_h = __open_rpc_port(uid, tts_client_get_mode(client));
+       tts_mode_e mode = tts_client_get_mode(client);
+       info->rpc_h = __open_rpc_port(uid, mode);
        if (NULL == info->rpc_h) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to open proxy");
                free(info);
                return TTS_ERROR_OPERATION_FAILED;
        }
 
+       info->mode = mode;
        info->uid = uid;
        g_tidl_infos = g_list_append(g_tidl_infos, info);
 
        SLOG(LOG_ERROR, TAG_TTSC, "[INFO] uid(%d) rpc_h(%p)", uid, info->rpc_h);
-       SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
        return TTS_ERROR_NONE;
 }
 
@@ -377,8 +373,24 @@ int tts_tidl_request_hello(int uid)
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
+       if (info->mode != client->mode) {
+               SLOG(LOG_INFO, TAG_TTSC, "[TIDL] tts mode is changed from (%d) to (%d)", info->mode, client->mode);
+               if (NULL != info->rpc_h && 0 != rpc_port_proxy_tts_destroy(info->rpc_h)) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to destroy old rpc_port");
+                       return TTS_ERROR_OPERATION_FAILED;
+               }
+
+               info->rpc_h = __open_rpc_port(uid, client->mode);
+               if (NULL == info->rpc_h) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to open proxy");
+                       return TTS_ERROR_OPERATION_FAILED;
+               }
+               info->mode = client->mode;
+       }
+
        if (!info->connected) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not Connected");
+               rpc_port_proxy_tts_connect(info->rpc_h);
                return TTS_ERROR_OPERATION_FAILED;
        }
 
index a1e98c5..fe28baa 100755 (executable)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
@@ -24,6 +24,7 @@
 #include <dlog.h>
 #include <Ecore.h>
 #include <vconf.h>
+#include <app_manager.h>
 
 #include "ttse.h"
 #include "ttse_internal.h"
@@ -77,12 +78,47 @@ static bool __is_default_engine()
        return FALSE;
 }
 
+static ttsd_mode_e __get_mode_from_appid()
+{
+       int pid = getpid();
+       char* appid = NULL;
+       app_manager_get_app_id(pid, &appid);
+
+       if (NULL == appid) {
+               return TTSD_MODE_DEFAULT;
+       }
+
+       SLOG(LOG_WARN, tts_tag(), "[WARNING] appid (%s)", appid);
+       char* token = strtok(appid, "-");
+       char* last = NULL;
+       while (NULL != token) {
+               last = token;
+               token = strtok(NULL, "-");
+       }
+
+       ttsd_mode_e mode = TTSD_MODE_DEFAULT;
+       if (!strncmp("noti", last, strlen(last))) {
+               mode = TTSD_MODE_NOTIFICATION;
+       } else if (!strncmp("sr", last, strlen(last))) {
+               mode = TTSD_MODE_SCREEN_READER;
+       } else if (!strncmp("interrupt", last, strlen(last))) {
+               mode = TTSD_MODE_INTERRUPT;
+       } else {
+               SLOG(LOG_INFO, tts_tag(), "[INFO] mode (%s)", last);
+       }
+
+       free(appid);
+
+       return mode;
+}
+
 int ttse_main(int argc, char** argv, ttse_request_callback_s *callback)
 {
        bundle *b = NULL;
        ttsd_mode_e mode = TTSD_MODE_DEFAULT;
        int ret = TTSE_ERROR_NONE;
 
+
        b = bundle_import_from_argv(argc, argv);
        if (NULL != b) {
                char *val = NULL;
@@ -101,8 +137,10 @@ int ttse_main(int argc, char** argv, ttse_request_callback_s *callback)
                                SLOG(LOG_ERROR, tts_tag(), "[ERROR] NULL data");
                        }
                } else {
-                       SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to get data from bundle");
+                       SLOG(LOG_INFO, tts_tag(), "[INFO] Get mode value from app ID");
+                       mode = __get_mode_from_appid();
                }
+
                bundle_free(b);
                val = NULL;
        } else {