From c3204c389c3d25d6cee573b11997f5db3e30b015 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Tue, 18 Jul 2023 15:09:59 +0900 Subject: [PATCH] Remove unused or unreachable code - Contents: This patch removes some unused or unrechable code. Through this patch, unvaluable code is removed and also test cases covers more code and logics. Change-Id: I1fe9c3e17303740b8793d56def022b26b4acb110 Signed-off-by: Suyeon Hwang --- client/vc.c | 579 ++++++++++------------------------- client/vc_client.c | 39 +-- client/vc_mgr.c | 90 +++--- client/vc_mgr_client.c | 58 ++-- client/vc_mgr_core.c | 74 ++--- common/vc_command.c | 36 ++- packaging/voice-control.spec | 8 +- 7 files changed, 305 insertions(+), 579 deletions(-) diff --git a/client/vc.c b/client/vc.c index afb3334..6695e1a 100644 --- a/client/vc.c +++ b/client/vc.c @@ -73,25 +73,29 @@ static int __vc_get_feature_enabled() } else if (-1 == g_feature_enabled) { bool vc_supported = false; bool mic_supported = false; - if (0 == system_info_get_platform_bool(VC_FEATURE_PATH, &vc_supported)) { - if (0 == system_info_get_platform_bool(VC_MIC_FEATURE_PATH, &mic_supported)) { - if (false == vc_supported || false == mic_supported) { - //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Voice control feature NOT supported"); - g_feature_enabled = 0; - return VC_ERROR_NOT_SUPPORTED; - //LCOV_EXCL_STOP - } + if (SYSTEM_INFO_ERROR_NONE != system_info_get_platform_bool(VC_FEATURE_PATH, &vc_supported)) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get feature value"); + return VC_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } - g_feature_enabled = 1; - } else { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get feature value"); //LCOV_EXCL_LINE - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get feature value"); //LCOV_EXCL_LINE - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + if (SYSTEM_INFO_ERROR_NONE != system_info_get_platform_bool(VC_MIC_FEATURE_PATH, &mic_supported)) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get feature value"); + return VC_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP } + + if (false == vc_supported || false == mic_supported) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Voice control feature NOT supported"); + g_feature_enabled = 0; + return VC_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + + g_feature_enabled = 1; } return VC_ERROR_NONE; @@ -270,6 +274,7 @@ static int __vc_convert_config_error_code(vc_config_error_e code) return VC_ERROR_NONE; } +//LCOV_EXCL_STOP static void __vc_lang_changed_cb(const char* previous_lang, const char* current_lang) { @@ -288,10 +293,9 @@ static void __vc_lang_changed_cb(const char* previous_lang, const char* current_ } else { SLOG(LOG_WARN, TAG_VCC, "[WARNING] Language changed callback is null"); } - - return; } +//LCOV_EXCL_START static Eina_Bool __notify_auth_changed_cb(void *data) { vc_auth_state_changed_cb callback = NULL; @@ -388,8 +392,8 @@ int vc_initialize(void) /* check handle */ if (true == vc_client_is_valid()) { - SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] Already initialized"); //LCOV_EXCL_LINE - return VC_ERROR_NONE; //LCOV_EXCL_LINE + SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] Already initialized"); + return VC_ERROR_NONE; } if (0 != vc_tidl_open_connection()) { @@ -405,23 +409,23 @@ int vc_initialize(void) g_pid = getpid(); ret = vc_config_mgr_initialize(g_pid); if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to init config manager : %s", - __vc_get_error_code(__vc_convert_config_error_code(ret))); //LCOV_EXCL_LINE + ret = __vc_convert_config_error_code(ret); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to init config manager : %s", __vc_get_error_code(ret)); //LCOV_EXCL_LINE vc_client_destroy(); //LCOV_EXCL_LINE - return __vc_convert_config_error_code(ret); //LCOV_EXCL_LINE + return ret; //LCOV_EXCL_LINE } ret = vc_config_mgr_set_lang_cb(g_pid, __vc_lang_changed_cb); if (0 != ret) { + ret = __vc_convert_config_error_code(ret); //LCOV_EXCL_LINE SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set config changed : %d", ret); //LCOV_EXCL_LINE vc_config_mgr_finalize(g_pid); //LCOV_EXCL_LINE vc_client_destroy(); //LCOV_EXCL_LINE - return __vc_convert_config_error_code(ret); + return ret; //LCOV_EXCL_LINE } SLOG(LOG_DEBUG, TAG_VCC, "[Success] pid(%d)", g_pid); - return VC_ERROR_NONE; } @@ -434,7 +438,7 @@ static void __vc_internal_unprepare(void) } if (VC_AUTH_STATE_NONE != state) { - if (0 != vc_auth_disable()) { + if (0 != vc_auth_disable()) { //LCOV_EXCL_LINE SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to auth disable"); //LCOV_EXCL_LINE } } @@ -459,8 +463,6 @@ static void __vc_internal_unprepare(void) ret = vc_cmd_parser_delete_file(getpid(), VC_COMMAND_TYPE_FOREGROUND); if (0 != ret) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to delete file, type(%d), ret(%d)", VC_COMMAND_TYPE_FOREGROUND, ret); //LCOV_EXCL_LINE - - return; } int vc_deinitialize(void) @@ -526,7 +528,7 @@ int vc_deinitialize(void) return VC_ERROR_NONE; } -static Eina_Bool __vc_connect_daemon(void *data) +static Eina_Bool connect_service(void *data) { SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Connect daemon"); @@ -536,110 +538,111 @@ static Eina_Bool __vc_connect_daemon(void *data) int service_state = 0; /* check handle */ - if (true == vc_client_is_valid()) { - SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] The current client is valid"); + if (false == vc_client_is_valid()) { + SLOG(LOG_ERROR, TAG_VCC, "[Not ERROR] The current client is not valid. It is destroyed."); //LCOV_EXCL_LINE + return EINA_FALSE; + } - /* Initialize DB */ - ret = vc_db_initialize(); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to initialize DB : %d", ret); //LCOV_EXCL_LINE - return EINA_TRUE; - } + SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] The current client is valid"); - ret = vc_cmd_parser_delete_file(getpid(), VC_COMMAND_TYPE_FOREGROUND); - if (0 != ret) - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to delete file, type(%d), ret(%d)", VC_COMMAND_TYPE_FOREGROUND, ret); //LCOV_EXCL_LINE + /* Initialize DB */ + ret = vc_db_initialize(); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to initialize DB : %d", ret); //LCOV_EXCL_LINE + return EINA_TRUE; + } - ret = vc_tidl_request_initialize(g_pid, &mgr_pid, &service_state, &g_daemon_pid); - //LCOV_EXCL_START - if (VC_ERROR_ENGINE_NOT_FOUND == ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to initialize : %s", __vc_get_error_code(ret)); + ret = vc_cmd_parser_delete_file(getpid(), VC_COMMAND_TYPE_FOREGROUND); + if (0 != ret) + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to delete file, type(%d), ret(%d)", VC_COMMAND_TYPE_FOREGROUND, ret); //LCOV_EXCL_LINE - vc_client_set_error(VC_ERROR_ENGINE_NOT_FOUND); - ecore_main_loop_thread_safe_call_async(__vc_notify_error, NULL); + ret = vc_tidl_request_initialize(g_pid, &mgr_pid, &service_state, &g_daemon_pid); + //LCOV_EXCL_START + if (VC_ERROR_ENGINE_NOT_FOUND == ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to initialize : %s", __vc_get_error_code(ret)); - return EINA_FALSE; - //LCOV_EXCL_STOP - } else if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to initialize :%s", __vc_get_error_code(ret)); //LCOV_EXCL_LINE + vc_client_set_error(VC_ERROR_ENGINE_NOT_FOUND); + ecore_main_loop_thread_safe_call_async(__vc_notify_error, NULL); - vc_client_set_error(VC_ERROR_TIMED_OUT); - ecore_main_loop_thread_safe_call_async(__vc_notify_error, NULL); + return EINA_FALSE; + //LCOV_EXCL_STOP + } else if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to initialize :%s", __vc_get_error_code(ret)); //LCOV_EXCL_LINE - ret = vc_db_finalize(); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to finalize DB : %d", ret); //LCOV_EXCL_LINE - } + vc_client_set_error(VC_ERROR_TIMED_OUT); + ecore_main_loop_thread_safe_call_async(__vc_notify_error, NULL); - return EINA_TRUE; - } else { - /* Success to connect */ + ret = vc_db_finalize(); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to finalize DB : %d", ret); //LCOV_EXCL_LINE } - /* Set service state */ - vc_service_state_e previous_service_state; - vc_client_get_service_state(&previous_service_state); + return EINA_TRUE; + } else { + /* Success to connect */ + } - vc_client_set_service_state((vc_service_state_e)service_state); + /* Set service state */ + vc_service_state_e previous_service_state; + vc_client_get_service_state(&previous_service_state); - vc_service_state_changed_cb service_changed_callback = NULL; - void* user_data = NULL; - vc_client_get_service_state_changed_cb(&service_changed_callback, &user_data); + vc_client_set_service_state((vc_service_state_e)service_state); - if (NULL != service_changed_callback) { - vc_client_use_callback(); - service_changed_callback(previous_service_state, service_state, user_data); - vc_client_not_use_callback(); - SLOG(LOG_DEBUG, TAG_VCC, "Service state changed callback is called"); //LCOV_EXCL_LINE - } else { - SLOG(LOG_WARN, TAG_VCC, "[WARNING] Service state changed callback is null"); //LCOV_EXCL_LINE - } + vc_service_state_changed_cb service_changed_callback = NULL; + void* user_data = NULL; + vc_client_get_service_state_changed_cb(&service_changed_callback, &user_data); - /* Register focus handler */ - ecore_thread_main_loop_begin(); - g_focus_in_handler = ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN, __focus_changed_cb, NULL); - g_focus_out_handler = ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT, __focus_changed_cb, NULL); - ecore_thread_main_loop_end(); - - char appid[1024] = {'\0',}; - ret = aul_app_get_appid_bypid(getpid(), appid, sizeof(appid) - 1); - if (ret != AUL_R_OK) - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get aul_app_get_appid_bypid : %d", ret); - - int status = aul_app_get_status(appid); - if (STATUS_FOCUS == status) { - SLOG(LOG_DEBUG, TAG_VCC, "@@@ Set foreground"); //LCOV_EXCL_LINE - ret = vc_tidl_request_set_foreground(getpid(), true); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set foreground (true) : %d", ret); //LCOV_EXCL_LINE - } + if (NULL != service_changed_callback) { + vc_client_use_callback(); + service_changed_callback(previous_service_state, service_state, user_data); + vc_client_not_use_callback(); + SLOG(LOG_DEBUG, TAG_VCC, "Service state changed callback is called"); //LCOV_EXCL_LINE + } else { + SLOG(LOG_WARN, TAG_VCC, "[WARNING] Service state changed callback is null"); //LCOV_EXCL_LINE + } - ret = vc_client_set_is_foreground(true); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to save is_foreground (true) : %d", ret); //LCOV_EXCL_LINE - } + /* Register focus handler */ + ecore_thread_main_loop_begin(); + g_focus_in_handler = ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN, __focus_changed_cb, NULL); + g_focus_out_handler = ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT, __focus_changed_cb, NULL); + ecore_thread_main_loop_end(); - /* set authority valid */ - vc_auth_state_e state = VC_AUTH_STATE_NONE; - if (0 != vc_client_get_auth_state(&state)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state"); //LCOV_EXCL_LINE - } - if (VC_AUTH_STATE_INVALID == state) { - vc_client_set_auth_state(VC_AUTH_STATE_VALID); + char appid[1024] = {'\0',}; + ret = aul_app_get_appid_bypid(getpid(), appid, sizeof(appid) - 1); + if (ret != AUL_R_OK) + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get aul_app_get_appid_bypid : %d", ret); - /* notify auth changed cb */ - ecore_idler_add(__notify_auth_changed_cb, NULL); - } + int status = aul_app_get_status(appid); + if (STATUS_FOCUS == status) { + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Set foreground"); //LCOV_EXCL_LINE + ret = vc_tidl_request_set_foreground(getpid(), true); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set foreground (true) : %d", ret); //LCOV_EXCL_LINE } - vc_client_set_client_state(VC_STATE_READY); - ecore_main_loop_thread_safe_call_async(__vc_notify_state_changed, NULL); + ret = vc_client_set_is_foreground(true); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to save is_foreground (true) : %d", ret); //LCOV_EXCL_LINE + } - vc_client_set_mgr_pid(mgr_pid); - } else { - SLOG(LOG_ERROR, TAG_VCC, "[Not ERROR] The current client is not valid. It is destroyed."); //LCOV_EXCL_LINE - return EINA_FALSE; + /* set authority valid */ + vc_auth_state_e state = VC_AUTH_STATE_NONE; + if (0 != vc_client_get_auth_state(&state)) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state"); //LCOV_EXCL_LINE + } + if (VC_AUTH_STATE_INVALID == state) { + vc_client_set_auth_state(VC_AUTH_STATE_VALID); + + /* notify auth changed cb */ + ecore_idler_add(__notify_auth_changed_cb, NULL); + } } + + vc_client_set_client_state(VC_STATE_READY); + ecore_main_loop_thread_safe_call_async(__vc_notify_state_changed, NULL); + + vc_client_set_mgr_pid(mgr_pid); + /* TODO set_start_listening should be move to proper place */ vc_client_set_start_listening(true); @@ -657,15 +660,15 @@ static void __start_prepare_thread(void *data, Ecore_Thread *thread) while (0 != ret) { pthread_mutex_lock(&g_prepare_thread_mutex); if (EINA_TRUE == ecore_thread_check(thread)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request hello !!"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request hello !!"); pthread_mutex_unlock(&g_prepare_thread_mutex); return; } if (retry_count == VC_TIDL_RETRY_COUNT) { // 200 ms * 20 = 4 sec SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request hello !!"); //LCOV_EXCL_LINE - pthread_mutex_unlock(&g_prepare_thread_mutex); - return; + pthread_mutex_unlock(&g_prepare_thread_mutex); //LCOV_EXCL_LINE + return; //LCOV_EXCL_LINE } ret = vc_tidl_request_hello(); @@ -685,17 +688,17 @@ static void __start_prepare_thread(void *data, Ecore_Thread *thread) pthread_mutex_lock(&g_prepare_thread_mutex); if (EINA_TRUE == ecore_thread_check(thread)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request hello !!"); //LCOV_EXCL_LINE - pthread_mutex_unlock(&g_prepare_thread_mutex); - return; + pthread_mutex_unlock(&g_prepare_thread_mutex); //LCOV_EXCL_LINE + return; //LCOV_EXCL_LINE } if (retry_count == 10) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to connect daemon !!"); //LCOV_EXCL_LINE - pthread_mutex_unlock(&g_prepare_thread_mutex); - return; + pthread_mutex_unlock(&g_prepare_thread_mutex); //LCOV_EXCL_LINE + return; //LCOV_EXCL_LINE } - ret = __vc_connect_daemon(NULL); + ret = connect_service(NULL); pthread_mutex_unlock(&g_prepare_thread_mutex); if (ret == 0) break; @@ -773,7 +776,7 @@ int vc_prepare_sync(void) } cnt = 0; - while (EINA_TRUE == __vc_connect_daemon(NULL) && VC_CONNECTION_RETRY_COUNT > cnt) { + while (EINA_TRUE == connect_service(NULL) && VC_CONNECTION_RETRY_COUNT > cnt) { cnt++; } @@ -829,7 +832,7 @@ int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user ret = vc_config_mgr_get_language_list(callback, user_data); if (0 != ret) { - ret = vc_config_convert_error_code((vc_config_error_e)ret); + ret = vc_config_convert_error_code((vc_config_error_e)ret); //LCOV_EXCL_LINE SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get languages : %s", __vc_get_error_code(ret)); //LCOV_EXCL_LINE } @@ -854,12 +857,11 @@ int vc_get_current_language(char** language) return VC_ERROR_INVALID_STATE; } - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get Current Language"); ret = vc_config_mgr_get_default_language(language); if (0 != ret) { - ret = vc_config_convert_error_code((vc_config_error_e)ret); + ret = vc_config_convert_error_code((vc_config_error_e)ret); //LCOV_EXCL_LINE SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get current languages : %s", __vc_get_error_code(ret)); //LCOV_EXCL_LINE } @@ -888,9 +890,9 @@ int vc_get_state(vc_state_e* state) case VC_STATE_NONE: SLOG(LOG_DEBUG, TAG_VCC, "Current state is 'None'"); break; case VC_STATE_INITIALIZED: SLOG(LOG_DEBUG, TAG_VCC, "Current state is 'Created'"); break; case VC_STATE_READY: SLOG(LOG_DEBUG, TAG_VCC, "Current state is 'Ready'"); break; - default: - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid state. Return state as 'None'."); - temp = VC_STATE_NONE; + default: //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid state. Return state as 'None'."); //LCOV_EXCL_LINE + temp = VC_STATE_NONE; //LCOV_EXCL_LINE } *state = temp; @@ -920,7 +922,7 @@ int vc_get_service_state(vc_service_state_e* state) vc_service_state_e service_state; if (0 != vc_client_get_service_state(&service_state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get service state"); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; + return VC_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE } SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get Service State"); @@ -928,11 +930,11 @@ int vc_get_service_state(vc_service_state_e* state) *state = service_state; switch (*state) { - case VC_SERVICE_STATE_NONE: SLOG(LOG_DEBUG, TAG_VCC, "Current service state is 'None'"); break; + case VC_SERVICE_STATE_NONE: SLOG(LOG_DEBUG, TAG_VCC, "Current service state is 'None'"); break; //LCOV_EXCL_LINE case VC_SERVICE_STATE_READY: SLOG(LOG_DEBUG, TAG_VCC, "Current service state is 'Ready'"); break; case VC_SERVICE_STATE_RECORDING: SLOG(LOG_DEBUG, TAG_VCC, "Current service state is 'Recording'"); break; case VC_SERVICE_STATE_PROCESSING: SLOG(LOG_DEBUG, TAG_VCC, "Current service state is 'Processing'"); break; - default: SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid state"); + default: SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid state"); //LCOV_EXCL_LINE } SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get Service State DONE"); @@ -1001,7 +1003,7 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) ret = vc_client_get_mgr_pid(&mgr_pid); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get the manager pid"); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; + return VC_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE } if (true == is_sys_cmd_valid) { @@ -1009,26 +1011,26 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) ret = vc_cmd_list_create((vc_cmd_list_h*)&list); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to create command list"); //LCOV_EXCL_LINE - return ret; + return ret; //LCOV_EXCL_LINE } ret = vc_cmd_parser_get_commands(mgr_pid, VC_COMMAND_TYPE_SYSTEM, &(list->list)); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get parsing commands"); //LCOV_EXCL_LINE - vc_cmd_list_destroy((vc_cmd_list_h)list, true); - return ret; + vc_cmd_list_destroy((vc_cmd_list_h)list, true); //LCOV_EXCL_LINE + return ret; //LCOV_EXCL_LINE } ret = vc_cmd_parser_get_commands(mgr_pid, VC_COMMAND_TYPE_SYSTEM_BACKGROUND, &(list->list)); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get parsing commands"); //LCOV_EXCL_LINE - vc_cmd_list_destroy((vc_cmd_list_h)list, true); - return ret; + vc_cmd_list_destroy((vc_cmd_list_h)list, true); //LCOV_EXCL_LINE + return ret; //LCOV_EXCL_LINE } *vc_sys_cmd_list = (vc_cmd_list_h)list; } else { - SLOG(LOG_WARN, TAG_VCC, "[WARNING] No system commands"); //LCOV_EXCL_LINE + SLOG(LOG_WARN, TAG_VCC, "[WARNING] No system commands"); return VC_ERROR_NONE; } @@ -1107,7 +1109,7 @@ static int __vc_get_invocation_name(char** invocation_name) ret = app_manager_get_app_id(getpid(), &appid); if (0 != ret || NULL == appid) { //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get appid, ret(%d)", ret); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get appid, ret(%d)", ret); FREE(appid); return VC_ERROR_OPERATION_FAILED; //LCOV_EXCL_STOP @@ -1115,16 +1117,18 @@ static int __vc_get_invocation_name(char** invocation_name) ret = vc_get_current_language(&lang); if (0 != ret || NULL == lang) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get current language, ret(%d)", ret); //LCOV_EXCL_LINE + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get current language, ret(%d)", ret); FREE(appid); FREE(lang); return VC_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP } ret = app_info_get_localed_label(appid, lang, &temp_label); if (0 != ret || NULL == temp_label) { //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get localed label, ret(%d) appid(%s) lang(%s)", ret, appid, lang); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get localed label, ret(%d) appid(%s) lang(%s)", ret, appid, lang); FREE(appid); FREE(lang); FREE(temp_label); @@ -1134,11 +1138,13 @@ static int __vc_get_invocation_name(char** invocation_name) *invocation_name = strdup(temp_label); if (NULL == *invocation_name) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to allocate memory"); //LCOV_EXCL_LINE + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to allocate memory"); FREE(appid); FREE(lang); FREE(temp_label); return VC_ERROR_OUT_OF_MEMORY; + //LCOV_EXCL_STOP } FREE(appid); @@ -1180,8 +1186,6 @@ void __set_command(vc_cmd_type_e type) //LCOV_EXCL_STOP } } while (0 != ret); - - return; } int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) @@ -1207,7 +1211,7 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) /* check type */ if ((VC_COMMAND_TYPE_FOREGROUND != type) && (VC_COMMAND_TYPE_BACKGROUND != type)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid command type: input type is %d", type); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid command type: input type is %d", type); return VC_ERROR_INVALID_PARAMETER; } @@ -1221,7 +1225,7 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) ret = __vc_get_invocation_name(&invocation_name); if (0 != ret || NULL == invocation_name) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get invocation name, ret(%d)", ret); //LCOV_EXCL_LINE - return ret; + return ret;//LCOV_EXCL_LINE } } @@ -1302,7 +1306,7 @@ int vc_unset_command_list(int type) ret = vc_cmd_parser_delete_file(getpid(), (vc_cmd_type_e)type); if (0 != ret) { - ret = vc_config_convert_error_code((vc_config_error_e)ret); + ret = vc_config_convert_error_code((vc_config_error_e)ret); //LCOV_EXCL_LINE SLOG(LOG_ERROR, TAG_VCC, "[ERROR] cmd_type(%d), Fail to delete command list : %s", type, __vc_get_error_code(ret)); //LCOV_EXCL_LINE } @@ -1366,263 +1370,6 @@ int vc_set_command_list_from_file(const char* file_path, int type) return ret; } -#if 0 -int vc_get_exclusive_command_option(bool* value) -{ - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get exclusive command"); - - vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } - - /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } - - int ret = vc_client_get_exclusive_cmd(g_vc, value); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set exclusive option : %d", ret); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return ret; - } - - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - - return ret; -} - -int vc_set_exclusive_command_option(bool value) -{ - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } - - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Set exclusive command"); - - vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } - - /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } - - int ret = vc_client_set_exclusive_cmd(g_vc, value); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set exclusive option : %d", ret); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return ret; - } - - int count = 0; - do { - ret = vc_dbus_request_set_exclusive_command(g_vc->handle, value); - if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request set exclusive command to daemon : %s", __vc_get_error_code(ret)); - break; - } else { - SLOG(LOG_WARN, TAG_VCC, "[WARNING] retry request set exclusive command : %s", __vc_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request"); - break; - } - } - } - } while (0 != ret); - - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - - return ret; -} -#endif - -#if 0 -int vc_request_start(bool stop_by_silence) -{ - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Request start"); - - vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } - - /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: client state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } - - /* Check service state */ - vc_service_state_e service_state = -1; - vc_client_get_service_state(g_vc, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } - - int ret; - int count = 0; - - /* Request */ - ret = -1; - count = 0; - while (0 != ret) { - ret = vc_dbus_request_start(g_vc->handle, stop_by_silence); - if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to start request start : %s", __vc_get_error_code(ret)); - break; - } else { - SLOG(LOG_WARN, TAG_VCC, "[WARNING] retry start request start : %s", __vc_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request"); - break; - } - } - } else { - SLOG(LOG_DEBUG, TAG_VCC, "[SUCCESS] start interrupt"); - } - } - - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - - return ret; -} - -int vc_request_stop(void) -{ - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Request stop"); - - vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } - - /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: client state is not 'Ready'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } - - /* Check service state */ - vc_service_state_e service_state = -1; - vc_client_get_service_state(g_vc, &service_state); - if (service_state != VC_SERVICE_STATE_RECORDING) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state is not 'RECORDING'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } - - int ret = -1; - int count = 0; - /* do request */ - while (0 != ret) { - ret = vc_dbus_request_stop(g_vc->handle); - if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_DEBUG, TAG_VCC, "[ERROR] Fail to stop request : %s", __vc_get_error_code(ret)); - break; - } else { - SLOG(LOG_WARN, TAG_VCC, "[WARNING] retry stop request : %s", __vc_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request"); - break; - } - } - } else { - SLOG(LOG_DEBUG, TAG_VCC, "[SUCCESS] Stop interrupt"); - } - } - - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - - return ret; -} - -int vc_request_cancel(void) -{ - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Request cancel Interrupt"); - - vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } - - /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'Ready'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } - - /* Check service state */ - vc_service_state_e service_state = -1; - vc_client_get_service_state(g_vc, &service_state); - if (service_state != VC_SERVICE_STATE_RECORDING && service_state != VC_SERVICE_STATE_PROCESSING) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state is not 'RECORDING' or 'PROCESSING'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } - - int ret = -1; - int count = 0; - while (0 != ret) { - ret = vc_dbus_request_cancel(g_vc->handle); - if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_DEBUG, TAG_VCC, "[ERROR] Fail to cancel request : %s", __vc_get_error_code(ret)); - break; - } else { - SLOG(LOG_WARN, TAG_VCC, "[WARNING] retry cancel request : %s", __vc_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request"); - break; - } - } - } else { - SLOG(LOG_DEBUG, TAG_VCC, "[SUCCESS] Cancel interrupt"); - } - } - - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - - return ret; -} -#endif - static void __vc_notify_error(void *data) { vc_error_cb callback = NULL; @@ -1728,8 +1475,6 @@ static Eina_Bool __vc_notify_result(void *data) void __vc_cb_result(void) { ecore_timer_add(0, __vc_notify_result, NULL); - - return; } //LCOV_EXCL_STOP @@ -1751,7 +1496,6 @@ int vc_get_result(vc_result_cb callback, void* user_data) RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client result callback is NULL"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get result"); char* temp_text = NULL; @@ -1760,15 +1504,16 @@ int vc_get_result(vc_result_cb callback, void* user_data) if (0 != vc_cmd_list_create(&vc_cmd_list)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to create command list"); //LCOV_EXCL_LINE - return VC_ERROR_INVALID_PARAMETER; + return VC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE } ret = vc_info_parser_get_result(&temp_text, &event, NULL, getpid(), vc_cmd_list, false); if (0 != ret || NULL == temp_text) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get result, ret(%d) temp_text(%s)", ret, temp_text); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get result, ret(%d) temp_text(%s)", ret, temp_text); return ret; } + //LCOV_EXCL_START SLOG(LOG_DEBUG, TAG_VCC, "Result info : result text(%s) event(%d)", temp_text, event); //LCOV_EXCL_LINE vc_cmd_print_list(vc_cmd_list); @@ -1786,6 +1531,7 @@ int vc_get_result(vc_result_cb callback, void* user_data) SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get result DONE"); return VC_ERROR_NONE; + //LCOV_EXCL_STOP } int vc_set_result_cb(vc_result_cb callback, void* user_data) @@ -1866,7 +1612,7 @@ int __vc_cb_service_state(int state) int __vc_cb_manager_pid(int manager_pid) { - SLOG(LOG_DEBUG, TAG_VCC, "Manager pid is changed : %d", manager_pid); //LCOV_EXCL_LINE + SLOG(LOG_DEBUG, TAG_VCC, "Manager pid is changed : %d", manager_pid); /* Save service state */ vc_client_set_mgr_pid(manager_pid); @@ -2057,13 +1803,12 @@ int vc_set_invocation_name(const char* name) if (VC_ERROR_NONE != ret) return ret; - vc_state_e state; SLOG(LOG_DEBUG, TAG_VCC, "@@@ Set invocation name"); - ret = vc_client_get_client_state(&state); - if (0 != ret) { + vc_state_e state; + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); - return ret; + return VC_ERROR_INVALID_STATE; } /* check state */ @@ -2751,6 +2496,7 @@ int __vc_cb_tts_streaming(int utt_id, vc_tts_event_e event, char* buffer, int le return ret; } +//LCOV_EXCL_STOP int vc_tts_request(const char* text, const char* language, bool to_vc_manager, int* utt_id) { @@ -2785,6 +2531,7 @@ int vc_tts_request(const char* text, const char* language, bool to_vc_manager, i do { ret = vc_tidl_request_request_tts(pid, text, language, to_vc_manager, utt_id); if (0 != ret) { + //LCOV_EXCL_START if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { vc_client_set_client_state(VC_STATE_INITIALIZED); if (0 == vc_prepare_sync()) { @@ -2803,6 +2550,7 @@ int vc_tts_request(const char* text, const char* language, bool to_vc_manager, i break; } } + //LCOV_EXCL_STOP } } while (0 != ret); @@ -2849,6 +2597,7 @@ int vc_tts_cancel(int utt_id) do { ret = vc_tidl_request_cancel_tts(pid, utt_id); if (0 != ret) { + //LCOV_EXCL_START if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { vc_client_set_client_state(VC_STATE_INITIALIZED); if (0 == vc_prepare_sync()) { @@ -2867,6 +2616,7 @@ int vc_tts_cancel(int utt_id) break; } } + //LCOV_EXCL_STOP } } while (0 != ret); @@ -2875,6 +2625,7 @@ int vc_tts_cancel(int utt_id) return ret; } +//LCOV_EXCL_START int vc_tts_get_synthesized_audio_details(int* rate, vc_audio_channel_e* channel, vc_audio_type_e* audio_type) { vc_state_e state; diff --git a/client/vc_client.c b/client/vc_client.c index 5ae8f29..f01c5bd 100644 --- a/client/vc_client.c +++ b/client/vc_client.c @@ -145,10 +145,10 @@ int vc_client_destroy(void) /* wait for release callback function */ usleep(10000); } - if (NULL != g_client->invocation_name) { - free(g_client->invocation_name); - g_client->invocation_name = NULL; - } + + free(g_client->invocation_name); + g_client->invocation_name = NULL; + free(g_client); g_client = NULL; @@ -253,7 +253,6 @@ int vc_client_set_current_lang_changed_cb(vc_current_language_changed_cb callbac return VC_ERROR_NONE; } -//LCOV_EXCL_START int vc_client_get_current_lang_changed_cb(vc_current_language_changed_cb* callback, void** user_data) { /* check handle */ @@ -265,7 +264,6 @@ int vc_client_get_current_lang_changed_cb(vc_current_language_changed_cb* callba return VC_ERROR_NONE; } -//LCOV_EXCL_STOP int vc_client_set_error_cb(vc_error_cb callback, void* user_data) { @@ -398,34 +396,6 @@ int vc_client_get_is_foreground(bool* value) return VC_ERROR_NONE; } - -#if 0 -int vc_client_set_exclusive_cmd(vc_h vc, bool value) -{ - vc_client_s* client = __client_get(vc); - - /* check handle */ - if (NULL == client) - return VC_ERROR_INVALID_PARAMETER; - - client->exclusive_cmd = value; - - return VC_ERROR_NONE; -} - -int vc_client_get_exclusive_cmd(vc_h vc, bool* value) -{ - vc_client_s* client = __client_get(vc); - - /* check handle */ - if (NULL == client) - return VC_ERROR_INVALID_PARAMETER; - - *value = client->exclusive_cmd; - - return VC_ERROR_NONE; -} -#endif //LCOV_EXCL_STOP int vc_client_set_error(int reason) @@ -450,7 +420,6 @@ int vc_client_get_error(int* reason) return VC_ERROR_NONE; } - /* utils */ int vc_client_use_callback(void) { diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 2fc2d44..73d5c6b 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -65,6 +65,7 @@ static pthread_mutex_t g_vc_tts_streaming_cb_mutex = PTHREAD_MUTEX_INITIALIZER; static Eina_Bool __vc_mgr_notify_state_changed(void *data); +//LCOV_EXCL_START static const char* __vc_mgr_get_error_code(vc_error_e err) { switch (err) { @@ -82,6 +83,7 @@ static const char* __vc_mgr_get_error_code(vc_error_e err) } return NULL; } +//LCOV_EXCL_STOP static void __vc_mgr_lang_changed_cb(const char* previous_lang, const char* current_lang) { @@ -100,29 +102,41 @@ static void __vc_mgr_lang_changed_cb(const char* previous_lang, const char* curr } else { SLOG(LOG_WARN, TAG_VCM, "[WARNING] Language changed callback is null"); } - - return; } static int __vc_mgr_get_feature_enabled() { if (0 == g_feature_enabled) { + //LCOV_EXCL_START SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Voice control feature NOT supported"); return VC_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP } else if (-1 == g_feature_enabled) { - bool vc_supported = false; + bool vc_mgr_supported = false; bool mic_supported = false; - if (0 == system_info_get_platform_bool(VC_MGR_FEATURE_PATH, &vc_supported)) { - if (0 == system_info_get_platform_bool(VC_MIC_FEATURE_PATH, &mic_supported)) { - if (false == vc_supported || false == mic_supported) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Voice control feature NOT supported"); - g_feature_enabled = 0; - return VC_ERROR_NOT_SUPPORTED; - } + if (SYSTEM_INFO_ERROR_NONE != system_info_get_platform_bool(VC_MGR_FEATURE_PATH, &vc_mgr_supported)) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get feature value"); + return VC_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } - g_feature_enabled = 1; - } + if (SYSTEM_INFO_ERROR_NONE != system_info_get_platform_bool(VC_MIC_FEATURE_PATH, &mic_supported)) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get feature value"); + return VC_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + + if (false == vc_mgr_supported || false == mic_supported) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Voice control feature NOT supported"); + g_feature_enabled = 0; + return VC_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP } + + g_feature_enabled = 1; } return VC_ERROR_NONE; @@ -132,7 +146,7 @@ static int __check_privilege_initialize() { int ret = cynara_initialize(&p_cynara, NULL); if (NULL == p_cynara || CYNARA_API_SUCCESS != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] fail to initialize(%d)", ret); + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] fail to initialize(%d)", ret); //LCOV_EXCL_LINE return ret; } @@ -161,8 +175,7 @@ static int __check_privilege(const char* uid, const char * privilege) pid_t pid = getpid(); char *session = cynara_session_from_pid(pid); int ret = cynara_check(p_cynara, smack_label, session, uid, privilege); - if (session) - free(session); + free(session); session = NULL; if (ret != CYNARA_API_ACCESS_ALLOWED) { @@ -194,10 +207,12 @@ static int __vc_mgr_check_privilege() bool ret = true; ret = __check_privilege_initialize(); if (false == ret) { + //LCOV_EXCL_START SLOG(LOG_ERROR, TAG_VCM, "[ERROR] privilege initialize is failed"); g_privilege_allowed = false; pthread_mutex_unlock(&g_cynara_mutex); return VC_ERROR_PERMISSION_DENIED; + //LCOV_EXCL_STOP } char uid[32]; @@ -205,20 +220,24 @@ static int __vc_mgr_check_privilege() ret = true; ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER); if (false == ret) { + //LCOV_EXCL_START SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_RECORDER, uid); __check_privilege_deinitialize(); g_privilege_allowed = false; pthread_mutex_unlock(&g_cynara_mutex); return VC_ERROR_PERMISSION_DENIED; + //LCOV_EXCL_STOP } ret = __check_privilege(uid, VC_MGR_PRIVILEGE); if (false == ret) { + //LCOV_EXCL_START SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Permission is denied(%s)(%s)", VC_MGR_PRIVILEGE, uid); __check_privilege_deinitialize(); g_privilege_allowed = false; pthread_mutex_unlock(&g_cynara_mutex); return VC_ERROR_PERMISSION_DENIED; + //LCOV_EXCL_STOP } __check_privilege_deinitialize(); @@ -312,7 +331,6 @@ static void __vc_mgr_internal_unprepare() } vc_mgr_client_set_internal_state(VC_INTERNAL_STATE_NONE); - return; } int vc_mgr_deinitialize(void) @@ -388,10 +406,12 @@ int vc_mgr_deinitialize(void) return VC_ERROR_NONE; } +//LCOV_EXCL_START static void __notify_error(void *data) { vc_mgr_core_notify_error(); } +//LCOV_EXCL_STOP static Eina_Bool __request_initialize(void *data) { @@ -418,6 +438,7 @@ static Eina_Bool __request_initialize(void *data) ret = vc_mgr_tidl_request_initialize(g_pid, (int)streaming_mode, &service_state, &foreground, &g_daemon_pid); if (VC_ERROR_ENGINE_NOT_FOUND == ret) { + //LCOV_EXCL_START SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to initialize : %s", __vc_mgr_get_error_code(ret)); vc_mgr_client_set_error(VC_ERROR_ENGINE_NOT_FOUND); @@ -426,6 +447,7 @@ static Eina_Bool __request_initialize(void *data) SLOG(LOG_DEBUG, TAG_VCM, "@@@"); g_request_init_timer = NULL; return EINA_FALSE; + //LCOV_EXCL_STOP } else if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[WARNING] Fail to connection. Retry to connect : %s", __vc_mgr_get_error_code(ret)); @@ -661,7 +683,7 @@ int vc_mgr_get_state(vc_state_e* state) case VC_STATE_NONE: SLOG(LOG_INFO, TAG_VCM, "Current state is 'None'"); break; case VC_STATE_INITIALIZED: SLOG(LOG_INFO, TAG_VCM, "Current state is 'Created'"); break; case VC_STATE_READY: SLOG(LOG_INFO, TAG_VCM, "Current state is 'Ready'"); break; - default: SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid state"); + default: SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid state"); //LCOV_EXCL_LINE } SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Get State DONE"); @@ -703,7 +725,7 @@ int vc_mgr_get_service_state(vc_service_state_e* state) case VC_SERVICE_STATE_READY: SLOG(LOG_DEBUG, TAG_VCM, "Current service state is 'Ready'"); break; case VC_SERVICE_STATE_RECORDING: SLOG(LOG_DEBUG, TAG_VCM, "Current service state is 'Recording'"); break; case VC_SERVICE_STATE_PROCESSING: SLOG(LOG_DEBUG, TAG_VCM, "Current service state is 'Processing'"); break; - default: SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid state"); + default: SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid state"); //LCOV_EXCL_LINE } SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Get Service State DONE"); @@ -1195,7 +1217,7 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) vc_cmd_list_h temp_list = NULL; if (0 != vc_cmd_list_create(&temp_list)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to create list"); - return VC_ERROR_INVALID_PARAMETER; + return VC_ERROR_OUT_OF_MEMORY; } *vc_cmd_list = temp_list; @@ -1242,6 +1264,7 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) return VC_ERROR_NONE; } + //LCOV_EXCL_START if (VC_NO_FOREGROUND_PID != fg_pid) { iter = g_slist_nth(client_info_list, 0); while (NULL != iter) { @@ -1289,9 +1312,7 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) while (NULL != iter) { client_info = iter->data; - if (NULL != client_info) { - free(client_info); - } + free(client_info); client_info_list = g_slist_remove_link(client_info_list, iter); iter = g_slist_nth(client_info_list, 0); } @@ -1334,6 +1355,7 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) // TODO: check return value correct or not return VC_ERROR_NONE; + //LCOV_EXCL_STOP } int vc_mgr_set_recognition_mode(vc_recognition_mode_e mode) @@ -1697,10 +1719,7 @@ int vc_mgr_stop(void) /* Check internal state for async */ vc_internal_state_e internal_state = -1; vc_mgr_client_get_internal_state(&internal_state); - if (VC_INTERNAL_STATE_STARTING == internal_state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State : Internal state is STARTING"); - return VC_ERROR_IN_PROGRESS_TO_RECORDING; - } else if (VC_INTERNAL_STATE_STOPPING == internal_state) { + if (VC_INTERNAL_STATE_STOPPING == internal_state) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State : Internal state is STOPPING"); return VC_ERROR_IN_PROGRESS_TO_PROCESSING; } else if (VC_INTERNAL_STATE_CANCELING == internal_state) { @@ -2612,6 +2631,7 @@ int vc_mgr_unset_vc_tts_streaming_cb() return VC_ERROR_NONE; } +//LCOV_EXCL_START static void __tts_feedback_thread(void* data, Ecore_Thread* thread) { SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Start thread"); @@ -2714,6 +2734,7 @@ static void __cancel_tts_feedback_thread(void* data, Ecore_Thread* thread) SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Cancel thread"); g_feedback_thread = NULL; } +//LCOV_EXCL_STOP int vc_mgr_start_feedback(void) { @@ -2970,6 +2991,7 @@ int vc_mgr_set_audio_streaming_mode(vc_audio_streaming_mode_e mode) return VC_ERROR_NONE; } +//LCOV_EXCL_START //TODO it's internal api, so will remove it. int vc_mgr_change_system_volume(vc_system_volume_event_e event) { @@ -2981,6 +3003,7 @@ int vc_mgr_recover_system_volume(void) { return vc_mgr_reset_background_volume(); } +//LCOV_EXCL_STOP int vc_mgr_change_background_volume(vc_background_volume_event_e event) { @@ -3003,11 +3026,6 @@ int vc_mgr_change_background_volume(vc_background_volume_event_e event) return VC_ERROR_INVALID_STATE; } - if (state != VC_STATE_READY && state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY' and not 'INITIALIZED', state(%d)", state); - return VC_ERROR_INVALID_STATE; - } - double ratio = 0.0; if (VC_BACKGROUND_VOLUME_EVENT_CHANGE_FOR_FARFIELD == event) ratio = VC_MGR_DEFAULT_FARFIELD_DUCKING_RATIO; @@ -3043,11 +3061,6 @@ int vc_mgr_change_background_volume_by_ratio(double ratio) return VC_ERROR_INVALID_STATE; } - if (state != VC_STATE_READY && state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY' and not 'INITIALIZED', state(%d)", state); - return VC_ERROR_INVALID_STATE; - } - ret = vc_mgr_ducking_activate(ratio); if (VC_ERROR_NONE != ret) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to set ratio"); @@ -3073,11 +3086,6 @@ int vc_mgr_reset_background_volume(void) return VC_ERROR_INVALID_STATE; } - if (state != VC_STATE_READY && state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY' and not 'INITIALIZED', state(%d)", state); - return VC_ERROR_INVALID_STATE; - } - ret = vc_mgr_ducking_deactivate(); if (VC_ERROR_NONE != ret) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to recover volume"); diff --git a/client/vc_mgr_client.c b/client/vc_mgr_client.c index e590383..9739040 100644 --- a/client/vc_mgr_client.c +++ b/client/vc_mgr_client.c @@ -215,17 +215,14 @@ int vc_mgr_client_destroy() usleep(10000); } - if (NULL != g_mgr_client->audio_id) { - free(g_mgr_client->audio_id); - } + free(g_mgr_client->audio_id); + g_mgr_client->audio_id = NULL; - if (NULL != g_mgr_client->all_result_text) { - free(g_mgr_client->all_result_text); - } + free(g_mgr_client->all_result_text); + g_mgr_client->all_result_text = NULL; - if (NULL != g_mgr_client->err_msg) { - free(g_mgr_client->err_msg); - } + free(g_mgr_client->err_msg); + g_mgr_client->err_msg = NULL; free(g_mgr_client); g_mgr_client = NULL; @@ -317,6 +314,7 @@ int vc_mgr_client_set_pre_result_cb(vc_mgr_pre_result_cb callback, void* user_da return VC_ERROR_NONE; } +//LCOV_EXCL_START int vc_mgr_client_get_pre_result_cb(vc_mgr_pre_result_cb* callback, void** user_data) { /* check handle */ @@ -328,6 +326,7 @@ int vc_mgr_client_get_pre_result_cb(vc_mgr_pre_result_cb* callback, void** user_ return VC_ERROR_NONE; } +//LCOV_EXCL_STOP int vc_mgr_client_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* user_data) { @@ -461,6 +460,7 @@ int vc_mgr_client_set_dialog_request_cb(vc_mgr_dialog_request_cb callback, void* return VC_ERROR_NONE; } +//LCOV_EXCL_START int vc_mgr_client_get_dialog_request_cb(vc_mgr_dialog_request_cb* callback, void** user_data) { /* check handle */ @@ -472,7 +472,7 @@ int vc_mgr_client_get_dialog_request_cb(vc_mgr_dialog_request_cb* callback, void return VC_ERROR_NONE; } - +//LCOV_EXCL_STOP int vc_mgr_client_set_private_data_set_cb(vc_mgr_private_data_set_cb callback, void* user_data) { @@ -486,6 +486,7 @@ int vc_mgr_client_set_private_data_set_cb(vc_mgr_private_data_set_cb callback, v return VC_ERROR_NONE; } +//LCOV_EXCL_START int vc_mgr_client_get_private_data_set_cb(vc_mgr_private_data_set_cb* callback, void** user_data) { /* check handle */ @@ -497,6 +498,7 @@ int vc_mgr_client_get_private_data_set_cb(vc_mgr_private_data_set_cb* callback, return VC_ERROR_NONE; } +//LCOV_EXCL_STOP int vc_mgr_client_set_private_data_requested_cb(vc_mgr_private_data_requested_cb callback, void* user_data) { @@ -510,6 +512,7 @@ int vc_mgr_client_set_private_data_requested_cb(vc_mgr_private_data_requested_cb return VC_ERROR_NONE; } +//LCOV_EXCL_START int vc_mgr_client_get_private_data_requested_cb(vc_mgr_private_data_requested_cb* callback, void** user_data) { /* check handle */ @@ -521,6 +524,7 @@ int vc_mgr_client_get_private_data_requested_cb(vc_mgr_private_data_requested_cb return VC_ERROR_NONE; } +//LCOV_EXCL_STOP int vc_mgr_client_set_feedback_audio_format_cb(vc_mgr_feedback_audio_format_cb callback, void* user_data) { @@ -534,6 +538,7 @@ int vc_mgr_client_set_feedback_audio_format_cb(vc_mgr_feedback_audio_format_cb c return VC_ERROR_NONE; } +//LCOV_EXCL_START int vc_mgr_client_get_feedback_audio_format_cb(vc_mgr_feedback_audio_format_cb* callback, void** user_data) { /* check handle */ @@ -545,6 +550,7 @@ int vc_mgr_client_get_feedback_audio_format_cb(vc_mgr_feedback_audio_format_cb* return VC_ERROR_NONE; } +//LCOV_EXCL_STOP int vc_mgr_client_set_feedback_streaming_cb(vc_mgr_feedback_streaming_cb callback, void* user_data) { @@ -558,6 +564,7 @@ int vc_mgr_client_set_feedback_streaming_cb(vc_mgr_feedback_streaming_cb callbac return VC_ERROR_NONE; } +//LCOV_EXCL_START int vc_mgr_client_get_feedback_streaming_cb(vc_mgr_feedback_streaming_cb* callback, void** user_data) { /* check handle */ @@ -569,6 +576,7 @@ int vc_mgr_client_get_feedback_streaming_cb(vc_mgr_feedback_streaming_cb* callba return VC_ERROR_NONE; } +//LCOV_EXCL_STOP int vc_mgr_client_set_vc_tts_streaming_cb(vc_mgr_vc_tts_streaming_cb callback, void* user_data) { @@ -582,6 +590,7 @@ int vc_mgr_client_set_vc_tts_streaming_cb(vc_mgr_vc_tts_streaming_cb callback, v return VC_ERROR_NONE; } +//LCOV_EXCL_START int vc_mgr_client_get_vc_tts_streaming_cb(vc_mgr_vc_tts_streaming_cb* callback, void** user_data) { /* check handle */ @@ -593,6 +602,7 @@ int vc_mgr_client_get_vc_tts_streaming_cb(vc_mgr_vc_tts_streaming_cb* callback, return VC_ERROR_NONE; } +//LCOV_EXCL_STOP /* set/get option */ int vc_mgr_client_set_service_state(vc_service_state_e state) @@ -702,10 +712,8 @@ int vc_mgr_client_set_error_message(const char* err_msg) if (NULL == g_mgr_client) return VC_ERROR_OPERATION_FAILED; - if (NULL != g_mgr_client->err_msg) { - free(g_mgr_client->err_msg); - g_mgr_client->err_msg = NULL; - } + free(g_mgr_client->err_msg); + g_mgr_client->err_msg = NULL; if (NULL != err_msg) { g_mgr_client->err_msg = strdup(err_msg); @@ -800,10 +808,9 @@ int vc_mgr_client_set_all_result(int event, const char* result_text) g_mgr_client->all_result_event = event; - if (NULL != g_mgr_client->all_result_text) { - free(g_mgr_client->all_result_text); - g_mgr_client->all_result_text = NULL; - } + free(g_mgr_client->all_result_text); + g_mgr_client->all_result_text = NULL; + if (NULL != result_text) { g_mgr_client->all_result_text = strdup(result_text); } @@ -835,10 +842,8 @@ int vc_mgr_client_unset_all_result() g_mgr_client->all_result_event = -1; - if (NULL != g_mgr_client->all_result_text) { - free(g_mgr_client->all_result_text); - g_mgr_client->all_result_text = NULL; - } + free(g_mgr_client->all_result_text); + g_mgr_client->all_result_text = NULL; return VC_ERROR_NONE; } @@ -850,10 +855,7 @@ int vc_mgr_client_set_audio_type(const char* audio_id) return VC_ERROR_OPERATION_FAILED; if (NULL != audio_id) { - if (NULL != g_mgr_client->audio_id) { - free(g_mgr_client->audio_id); - g_mgr_client->audio_id = NULL; - } + free(g_mgr_client->audio_id); g_mgr_client->audio_id = strdup(audio_id); } @@ -951,6 +953,7 @@ int vc_mgr_client_not_use_callback() return VC_ERROR_NONE; } +//LCOV_EXCL_START /* Authority */ int vc_mgr_client_add_authorized_client(int pid) { @@ -1078,6 +1081,7 @@ int vc_mgr_client_set_start_by_client(bool option) return VC_ERROR_NONE; } +//LCOV_EXCL_STOP int vc_mgr_client_get_start_by_client(bool* option) { @@ -1102,6 +1106,7 @@ int vc_mgr_client_set_specific_engine_result_cb(vc_mgr_specific_engine_result_cb return VC_ERROR_NONE; } +//LCOV_EXCL_START int vc_mgr_client_get_specific_engine_result_cb(vc_mgr_specific_engine_result_cb* callback, void** user_data) { /* check handle */ @@ -1113,6 +1118,7 @@ int vc_mgr_client_get_specific_engine_result_cb(vc_mgr_specific_engine_result_cb return VC_ERROR_NONE; } +//LCOV_EXCL_STOP int vc_mgr_client_set_audio_streaming_mode(vc_audio_streaming_mode_e streaming_mode) { diff --git a/client/vc_mgr_core.c b/client/vc_mgr_core.c index 3fe5d06..e016ef1 100644 --- a/client/vc_mgr_core.c +++ b/client/vc_mgr_core.c @@ -69,12 +69,14 @@ static Eina_Bool __vc_mgr_core_set_volume_timer_cb(void* data) return EINA_TRUE; } +//LCOV_EXCL_START static Eina_Bool __vc_mgr_core_set_select_result(void *data) { // TODO: remove vc_mgr dependency by separate vc_mgr_set_selected_results core logic to core layer vc_mgr_set_selected_results(NULL); return EINA_FALSE; } +//LCOV_EXCL_STOP static void __vc_mgr_core_notify_all_result(vc_result_type_e result_type) { @@ -110,6 +112,7 @@ static void __vc_mgr_core_notify_all_result(vc_result_type_e result_type) vc_mgr_client_not_use_callback(); if (true == vc_mgr_client_get_exclusive_command()) { + //LCOV_EXCL_START /* exclusive */ vc_result_cb callback = NULL; void* user_data = NULL; @@ -123,14 +126,11 @@ static void __vc_mgr_core_notify_all_result(vc_result_type_e result_type) SLOG(LOG_DEBUG, TAG_VCM, "Exclusive result callback called"); /* Release result */ - if (NULL != temp_text) { - free(temp_text); - temp_text = NULL; - } - if (NULL != temp_message) { - free(temp_message); - temp_message = NULL; - } + free(temp_text); + temp_text = NULL; + + free(temp_message); + temp_message = NULL; /* Release list */ if (vc_cmd_list) @@ -140,6 +140,7 @@ static void __vc_mgr_core_notify_all_result(vc_result_type_e result_type) vc_mgr_client_set_exclusive_command(false); return; + //LCOV_EXCL_STOP } int count = 0; @@ -162,21 +163,16 @@ static void __vc_mgr_core_notify_all_result(vc_result_type_e result_type) } /* Release result */ - if (NULL != temp_text) { - free(temp_text); - temp_text = NULL; - } - if (NULL != temp_message) { - free(temp_message); - temp_message = NULL; - } + free(temp_text); + temp_text = NULL; + + free(temp_message); + temp_message = NULL; /* Release list */ if (vc_cmd_list) vc_cmd_list_destroy(vc_cmd_list, true); vc_cmd_list = NULL; - - return; } static void __vc_mgr_core_notify_result() @@ -212,8 +208,7 @@ static void __vc_mgr_core_notify_result() vc_cmd_list = NULL; /* Release result */ - if (temp_text) - free(temp_text); + free(temp_text); temp_text = NULL; } @@ -224,10 +219,9 @@ void vc_mgr_core_send_all_result(vc_result_type_e type) } else { __vc_mgr_core_notify_result(); } - - return; } +//LCOV_EXCL_START void vc_mgr_core_send_pre_result(vc_pre_result_event_e event, const char* pre_result) { vc_mgr_pre_result_cb callback = NULL; @@ -240,14 +234,12 @@ void vc_mgr_core_send_pre_result(vc_pre_result_event_e event, const char* pre_re callback(event, pre_result, user_data); vc_mgr_client_not_use_callback(); SLOG(LOG_INFO, TAG_VCM, "Pre result callback is called"); - - return; } +//LCOV_EXCL_STOP void vc_mgr_core_send_system_result() { __vc_mgr_core_notify_result(); - return; } void vc_mgr_core_send_speech_detected() @@ -262,9 +254,6 @@ void vc_mgr_core_send_speech_detected() callback(user_data); vc_mgr_client_not_use_callback(); SLOG(LOG_INFO, TAG_VCM, "Speech detected callback called"); - - - return; } void vc_mgr_core_notify_error() @@ -298,10 +287,8 @@ int vc_mgr_core_set_selected_results(vc_cmd_list_h vc_cmd_list, int pid) vc_info_parser_set_result(result_text, event, NULL, vc_cmd_list, false); - if (NULL != result_text) { - free(result_text); - result_text = NULL; - } + free(result_text); + result_text = NULL; } /* Request */ @@ -400,8 +387,6 @@ int vc_mgr_core_get_error_message(char** err_msg) return ret; } - - int vc_mgr_core_send_service_state(int state) { vc_service_state_e current_state = (vc_service_state_e)state; @@ -449,6 +434,7 @@ int vc_mgr_core_send_service_state(int state) return VC_ERROR_NONE; } +//LCOV_EXCL_START int vc_mgr_core_send_dialog(int pid, const char* disp_text, const char* utt_text, bool continuous) { vc_mgr_dialog_request_cb callback = NULL; @@ -520,9 +506,8 @@ void vc_mgr_core_send_specific_engine_result(const char* engine_app_id, const ch callback(engine_app_id, event, result, user_data); vc_mgr_client_not_use_callback(); SLOG(LOG_INFO, TAG_VCM, "Specific engine result callback is called, engine app id(%s), event(%s), result(%s)", engine_app_id, event, result); - - return; } +//LCOV_EXCL_STOP int vc_mgr_core_send_set_volume(float volume) { @@ -558,6 +543,7 @@ void vc_mgr_core_initialize_volume_variable() g_cur_volume_db = 0; } +//LCOV_EXCL_START int vc_mgr_core_send_set_foreground(int pid, bool value) { vc_mgr_client_set_foreground(pid, value); @@ -655,14 +641,11 @@ int vc_mgr_core_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e int ret = vc_mgr_data_add_feedback_data(temp_feedback_data); if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to add feedback data"); - if (NULL != temp_feedback_data->data) { - free(temp_feedback_data->data); - temp_feedback_data->data = NULL; - } - if (NULL != temp_feedback_data) { - free(temp_feedback_data); - temp_feedback_data = NULL; - } + free(temp_feedback_data->data); + temp_feedback_data->data = NULL; + + free(temp_feedback_data); + temp_feedback_data = NULL; } return ret; @@ -865,4 +848,5 @@ int vc_mgr_core_request_auth_cancel(int pid) ecore_timer_add(0, __request_auth_cancel, NULL); return VC_ERROR_NONE; -} \ No newline at end of file +} +//LCOV_EXCL_STOP diff --git a/common/vc_command.c b/common/vc_command.c index e6b5767..edff3b4 100644 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -63,28 +63,36 @@ static int g_data_eidx; static int __vc_cmd_get_feature_enabled() { if (0 == g_feature_enabled) { + //LCOV_EXCL_START SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Voice control feature NOT supported"); return VC_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP } else if (-1 == g_feature_enabled) { bool vc_supported = false; bool mic_supported = false; - if (0 == system_info_get_platform_bool(VC_FEATURE_PATH, &vc_supported)) { - if (0 == system_info_get_platform_bool(VC_MIC_FEATURE_PATH, &mic_supported)) { - if (false == vc_supported || false == mic_supported) { - SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Voice control feature NOT supported"); - g_feature_enabled = 0; - return VC_ERROR_NOT_SUPPORTED; - } - - g_feature_enabled = 1; - } else { - SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Fail to get feature value"); - return VC_ERROR_NOT_SUPPORTED; - } - } else { + if (SYSTEM_INFO_ERROR_NONE != system_info_get_platform_bool(VC_FEATURE_PATH, &vc_supported)) { + //LCOV_EXCL_START SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Fail to get feature value"); return VC_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP } + + if (SYSTEM_INFO_ERROR_NONE != system_info_get_platform_bool(VC_MIC_FEATURE_PATH, &mic_supported)) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Fail to get feature value"); + return VC_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + + if (false == vc_supported || false == mic_supported) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Voice control feature NOT supported"); + g_feature_enabled = 0; + return VC_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP + } + + g_feature_enabled = 1; } return VC_ERROR_NONE; diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 115ab4e..ff9c2fb 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -160,20 +160,20 @@ rm -rf %{buildroot} builddir=$(basename $PWD) gcno_obj_dir=%{buildroot}%{_datadir}/gcov/obj/%{name}/"$builddir" mkdir -p "$gcno_obj_dir" -find ./client/CMakeFiles/vc_* -name '*.gcno' -exec rm {} \; find ./server/ -name '*.gcno' -exec rm {} \; find ./audio-manager/ -name '*.gcno' -exec rm {} \; find ./tests/ -name '*.gcno' -exec rm {} \; find ./engine-parser/ -name '*.gcno' -exec rm {} \; -find . -name '*_dbus.c.gcno' -exec rm {} \; find . -name '*_cmd_db.c.gcno' -exec rm {} \; find . -name '*_config_*.gcno' -exec rm {} \; find . -name '*_parser.c.gcno' -exec rm {} \; -find . -name 'vc_mgr*.gcno' -exec rm {} \; find . -name 'vc_setting*.gcno' -exec rm {} \; find . -name 'vc_widget*.gcno' -exec rm {} \; -find . -name 'vc_proxy*.gcno' -exec rm {} \; +find . -name '*tidl*.gcno' -exec rm {} \; +find . -name '*proxy*.gcno' -exec rm {} \; +find . -name '*stub*.gcno' -exec rm {} \; find . -name 'vc_command_util*.gcno' -exec rm {} \; +find . -name 'VoiceControl*.gcno' -exec rm {} \; find . -name '*_data*.gcno' -exec rm {} \; find . -name '*.gcno' -exec cp --parents '{}' "$gcno_obj_dir" ';' %endif -- 2.34.1