From: wn.jang Date: Wed, 22 Jan 2020 06:08:13 +0000 (+0900) Subject: Fix pkgmgr status and move hello_timer into client handle X-Git-Tag: submit/tizen/20200220.060827~2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Ftts.git;a=commitdiff_plain;h=f862b6bd4f3899c47e0e2588195ece477ac4cb66 Fix pkgmgr status and move hello_timer into client handle Change-Id: Ifb917210c844503725584a9024577658e78b2af3 (cherry picked from commit 2c205ab6adc5c18807c3206bab995c752e5f4a1f) --- diff --git a/client/tts.c b/client/tts.c index 3ec8220..8b2c42b 100644 --- a/client/tts.c +++ b/client/tts.c @@ -41,8 +41,6 @@ static int g_max_text_size = -1; static Ecore_Timer* g_check_state_timer = NULL; -static Ecore_Timer* g_hello_timer; - /* for repetition */ static char* g_language = NULL; @@ -269,11 +267,11 @@ static int __pkgmgr_status_cb(uid_t target_uid, int req_id, const char *type, co } else { if (key && 0 == strncmp(key, "start", strlen(key))) { if (val && (0 == strncmp(val, "update", strlen(val) || 0 == strncmp(val, "uninstall", strlen(val))))) { - SLOG(LOG_INFO, TAG_TTSC, "[INFO] start to install."); + SLOG(LOG_ERROR, TAG_TTSC, "[INFO] start to install."); g_engine_update_status = 1; } } else if (key && 0 == strncmp(key, "end", strlen(key))) { - SLOG(LOG_INFO, TAG_TTSC, "[INFO] finish to install"); + SLOG(LOG_ERROR, TAG_TTSC, "[INFO] finish to install"); g_engine_update_status = 0; } } @@ -292,13 +290,23 @@ static void __create_pkgmgr_thread(void* data, Ecore_Thread* thread) if (NULL == g_pkgmgr) { SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to create pkgmgr handle"); } else { - if (pkgmgr_client_listen_status(g_pkgmgr, __pkgmgr_status_cb, NULL) < 0) { - SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to listen pkgmgr status. remove and recreate client"); + int ret = pkgmgr_client_set_status_type(g_pkgmgr, PKGMGR_CLIENT_STATUS_UNINSTALL | PKGMGR_CLIENT_STATUS_UPGRADE); + if (0 == ret) { + if (pkgmgr_client_listen_status(g_pkgmgr, __pkgmgr_status_cb, NULL) < 0) { + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to listen pkgmgr status. remove and recreate client"); + pkgmgr_client_free(g_pkgmgr); + g_pkgmgr = NULL; + usleep(10000); + continue; + } else { + SLOG(LOG_ERROR, TAG_TTSC, "[INFO] Succeed to register pkgmgr cb"); + } + } else { + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to set status type on pkgmgr, ret(%d)", ret); pkgmgr_client_free(g_pkgmgr); g_pkgmgr = NULL; + usleep(10000); continue; - } else { - SLOG(LOG_ERROR, TAG_TTSC, "[DEBUG] Succeed to register pkgmgr cb"); } } usleep(10000); @@ -356,6 +364,8 @@ int tts_create(tts_h* tts) return TTS_ERROR_OPERATION_FAILED; } + SLOG(LOG_ERROR, TAG_TTSC, "[INFO] tts_h(%p), tts_client(%p), uid(%d)", tts, client, client->uid); + int ret = tts_config_mgr_initialize(client->uid); if (0 != ret) { SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to init config manager : %d", ret); @@ -408,22 +418,21 @@ int tts_destroy(tts_h tts) return TTS_ERROR_INVALID_PARAMETER; } + SLOG(LOG_ERROR, TAG_TTSC, "[INFO] tts_h(%p), tts_client(%p), uid(%d)", tts, client, client->uid); + /* check used callback */ if (0 != tts_client_get_use_callback(client)) { SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Cannot destroy in Callback function"); return TTS_ERROR_OPERATION_FAILED; } - pthread_mutex_lock(&g_pkgmgr_mutex); - if (g_pkgmgr) { - pkgmgr_client_remove_listen_status(g_pkgmgr); - pkgmgr_client_free(g_pkgmgr); - g_pkgmgr = NULL; - } - pthread_mutex_unlock(&g_pkgmgr_mutex); - tts_config_mgr_finalize(client->uid); + if (client->hello_timer) { + ecore_timer_del(client->hello_timer); + client->hello_timer = NULL; + } + int ret = -1; int count = 0; int screen_reader = -1; @@ -484,10 +493,21 @@ int tts_destroy(tts_h tts) break; } - if (0 == tts_client_get_size()) { + int num_of_client = tts_client_get_size(); + if (0 == num_of_client) { + SLOG(LOG_ERROR, TAG_TTSC, "[INFO] all clients are destroied"); if (0 != tts_dbus_close_connection()) { SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to close connection"); } + pthread_mutex_lock(&g_pkgmgr_mutex); + if (g_pkgmgr) { + pkgmgr_client_remove_listen_status(g_pkgmgr); + pkgmgr_client_free(g_pkgmgr); + g_pkgmgr = NULL; + } + pthread_mutex_unlock(&g_pkgmgr_mutex); + } else { + SLOG(LOG_ERROR, TAG_TTSC, "[INFO] num_of_client(%d)", num_of_client); } if (NULL != g_language) { @@ -832,9 +852,9 @@ int __tts_cb_hello(int uid, int ret, int credential_needed) return TTS_ERROR_OPERATION_FAILED; } - if (g_hello_timer) { - ecore_timer_del(g_hello_timer); - g_hello_timer = NULL; + if (client->hello_timer) { + ecore_timer_del(client->hello_timer); + client->hello_timer = NULL; } if (TTS_STATE_READY == client->current_state) { @@ -887,23 +907,24 @@ static Eina_Bool __send_hello(void *data) /* check handle */ if (NULL == client) { SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid"); - g_hello_timer = NULL; return EINA_FALSE; } /* check state */ if (client->current_state == TTS_STATE_READY) { SLOG(LOG_ERROR, TAG_TTSC, "[INFO] TTS client has been already connected to tts service"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_TTSC, "@@@"); - g_hello_timer = NULL; + SLOG(LOG_ERROR, TAG_TTSC, "@@@"); + client->hello_timer = NULL; return EINA_FALSE; } + SLOG(LOG_ERROR, TAG_TTSC, "[INFO] tts_h(%p), tts_client(%p), uid(%d)", tts, client, client->uid); + /* check whether engine is updating or not */ if (g_engine_update_status) { SLOG(LOG_ERROR, TAG_TTSC, "[DEBUG] cannot prepare due to engine update"); __tts_cb_error(-1, TTS_ERROR_SERVICE_RESET, -1, "Daemon Reset"); - g_hello_timer = NULL; + client->hello_timer = NULL; return EINA_FALSE; } @@ -919,13 +940,13 @@ static Eina_Bool __send_hello(void *data) if (TTS_HELLO_RETRY_COUNT == g_retry_cnt) { SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Stop to send hello, retry count reaches the limit"); g_retry_cnt = 0; - g_hello_timer = NULL; + client->hello_timer = NULL; return EINA_FALSE; } - if (!g_hello_timer) { + if (!client->hello_timer) { SLOG(LOG_ERROR, TAG_TTSC, "@@@ Call checking Hello timer callback"); - g_hello_timer = ecore_timer_add(0.5, __send_hello, tts); + client->hello_timer = ecore_timer_add(0.5, __send_hello, tts); return EINA_FALSE; } return EINA_TRUE; @@ -955,7 +976,9 @@ int tts_prepare(tts_h tts) return TTS_ERROR_INVALID_STATE; } - if (NULL == g_hello_timer) { + SLOG(LOG_ERROR, TAG_TTSC, "[INFO] tts_h(%p), tts_client(%p), uid(%d)", tts, client, client->uid); + + if (NULL == client->hello_timer) { SLOG(LOG_ERROR, TAG_TTSC, "@@@ Call checking Hello timer callback"); g_retry_cnt = 0; ecore_thread_main_loop_begin(); @@ -1031,6 +1054,13 @@ int tts_unprepare(tts_h tts) return TTS_ERROR_INVALID_STATE; } + SLOG(LOG_ERROR, TAG_TTSC, "[INFO] tts_h(%p), tts_client(%p), uid(%d)", tts, client, client->uid); + + if (client->hello_timer) { + ecore_timer_del(client->hello_timer); + client->hello_timer = NULL; + } + int ret = -1; int count = 0; int screen_reader = -1; @@ -1255,10 +1285,10 @@ int tts_get_state(tts_h tts, tts_state_e* state) *state = client->current_state; switch (*state) { - case TTS_STATE_CREATED: SLOG(LOG_DEBUG, TAG_TTSC, "Current state is 'Created'"); break; - case TTS_STATE_READY: SLOG(LOG_DEBUG, TAG_TTSC, "Current state is 'Ready'"); break; - case TTS_STATE_PLAYING: SLOG(LOG_DEBUG, TAG_TTSC, "Current state is 'Playing'"); break; - case TTS_STATE_PAUSED: SLOG(LOG_DEBUG, TAG_TTSC, "Current state is 'Paused'"); break; + case TTS_STATE_CREATED: SLOG(LOG_INFO, TAG_TTSC, "Current state is 'Created'"); break; + case TTS_STATE_READY: SLOG(LOG_INFO, TAG_TTSC, "Current state is 'Ready'"); break; + case TTS_STATE_PLAYING: SLOG(LOG_INFO, TAG_TTSC, "Current state is 'Playing'"); break; + case TTS_STATE_PAUSED: SLOG(LOG_INFO, TAG_TTSC, "Current state is 'Paused'"); break; default: SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid value"); break; } @@ -1323,7 +1353,7 @@ int tts_get_error_message(tts_h tts, char** err_msg) int tts_add_text(tts_h tts, const char* text, const char* language, int voice_type, int speed, int* utt_id) { - SLOG(LOG_INFO, TAG_TTSC, "[DEBUG] Add text: text(%s), language(%s), type(%d)", (NULL == text) ? "NULL" : text, (NULL == language) ? "NULL" : language, voice_type); + SLOG(LOG_ERROR, TAG_TTSC, "[INFO] Add text: text(%s), language(%s), type(%d)", (NULL == text) ? "NULL" : text, (NULL == language) ? "NULL" : language, voice_type); if (0 != __tts_get_feature_enabled()) { return TTS_ERROR_NOT_SUPPORTED; diff --git a/client/tts_client.c b/client/tts_client.c index 94a713d..570910b 100644 --- a/client/tts_client.c +++ b/client/tts_client.c @@ -82,6 +82,7 @@ int tts_client_new(tts_h* tts) client->err_msg = NULL; client->conn_timer = NULL; + client->hello_timer = NULL; client->credential = NULL; client->credential_needed = false; @@ -93,7 +94,7 @@ int tts_client_new(tts_h* tts) *tts = temp; - SLOG(LOG_DEBUG, TAG_TTSC, "[Success] Create client object : uid(%d)", client->uid); + SLOG(LOG_ERROR, TAG_TTSC, "[Success] Create client object : uid(%d)", client->uid); return TTS_ERROR_NONE; } @@ -137,15 +138,16 @@ int tts_client_destroy(tts_h tts) data->text_repeat = NULL; } + int uid = data->uid; free(data); free(tts); data = NULL; tts = NULL; - SLOG(LOG_DEBUG, TAG_TTSC, "Client destroy"); g_list_free(iter); + SLOG(LOG_ERROR, TAG_TTSC, "Client destroy : uid(%d)", uid); return TTS_ERROR_NONE; } diff --git a/client/tts_client.h b/client/tts_client.h index 0db3bf9..67b61d2 100644 --- a/client/tts_client.h +++ b/client/tts_client.h @@ -63,6 +63,7 @@ typedef struct { /* connection */ Ecore_Timer* conn_timer; + Ecore_Timer* hello_timer; /* options */ char* credential;