Remove duplicate code and unvaluable function 69/259869/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Wed, 16 Jun 2021 07:08:47 +0000 (16:08 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Wed, 16 Jun 2021 07:08:47 +0000 (16:08 +0900)
This patch removes duplicated code and unvaluble function to enhance readbility.
Using 'tts_core_check_screen_reader()' remove and simplify the condition check code.
And also, 'tts_core_set_mode()' just call 'tts_client_set_mode()', this patch makes 'tts_set_mode()'
calls 'tts_client_set_mode()' directly and removes 'tts_core_set_mode()'.

Change-Id: Ia1338770fe243bd7b99cab23089ce17547bc6325
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
client/tts.c
client/tts_core.c
client/tts_core.h

index 77405e9b515e1d5bf1b988b064ea8c2ea675b9d6..b5521d62da521adb63aa3f434812295d417e373d 100644 (file)
@@ -405,11 +405,7 @@ int tts_set_mode(tts_h tts, tts_mode_e mode)
                return TTS_ERROR_INVALID_STATE;
        }
 
-       int ret = tts_core_set_mode(client, mode);
-       if (TTS_ERROR_NONE != ret) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to set mode to client. ret(%d)", ret);
-               return ret;
-       }
+       tts_client_set_mode(client, mode);
 
        SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
        return TTS_ERROR_NONE;
index daa2bbc6c0f69e5f9fdaf6a728ff736918589020..85f43efe0f63b552033c05154f17a42137731d8a 100644 (file)
@@ -894,18 +894,6 @@ int tts_core_notify_engine_changed(tts_client_s* client, const char* engine_id,
        return TTS_ERROR_NONE;
 }
 
-int tts_core_set_mode(tts_client_s* client, tts_mode_e mode)
-{
-       if (false == tts_client_is_valid_client(client)) {
-               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] client is not valid");
-               return TTS_ERROR_INVALID_PARAMETER;
-       }
-
-       tts_client_set_mode(client, mode);
-
-       return TTS_ERROR_NONE;
-}
-
 bool tts_core_is_valid_text(const char* text)
 {
        if (NULL == text) {
@@ -1066,19 +1054,17 @@ int tts_core_unprepare(tts_client_s* client)
                client->hello_timer = NULL;
        }
 
-       bool is_screen_reader_on = __is_screen_reader_turned_on();
-       tts_mode_e mode = tts_client_get_mode(client);
-       SLOG(LOG_INFO, TAG_TTSC, "[INFO] screen_reader(%s), mode(%d)", (true == is_screen_reader_on) ? "True" : "False", mode);
-
        int ret = -1;
-       if (false == is_screen_reader_on && TTS_MODE_SCREEN_READER == mode) {
-               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Do not request finalize : is_screen_reader(%d) mode(%d)", is_screen_reader_on, mode);
+       if (false == tts_core_check_screen_reader(client)) {
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Do not request finalize. Handled by screen reader");
 
                ret = tts_ipc_stop_listening(uid);
                if (0 != ret) {
                        SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to remove match : %s", __tts_get_error_code(ret));
                }
        } else {
+               SLOG(LOG_INFO, TAG_TTSC, "[INFO] Request finalize");
+
                bool is_prepared = false;
                for (int count = 0; count < TTS_RETRY_COUNT; count++) {
                        ret = tts_ipc_request_finalize(uid);
index fe9adcefd5296bc0e62c0446c8f8397e5fa87ac0..fb33d9cd5bd69ef1a6e6ba826ec04cb9bbace547 100644 (file)
@@ -30,8 +30,6 @@ int tts_core_notify_error_async(tts_client_s* client, tts_error_e reason, int ut
 int tts_core_notify_default_voice_changed(tts_client_s* client, const char* before_lang, int before_voice_type, const char* language, int voice_type);
 int tts_core_notify_engine_changed(tts_client_s* client, const char* engine_id, const char* language, int voice_type, bool need_credential);
 
-int tts_core_set_mode(tts_client_s* client, tts_mode_e mode);
-
 bool tts_core_is_valid_text(const char* text);
 bool tts_core_check_screen_reader(tts_client_s* client);