From 2f5d1b3eb08e99b1460a7276fdd89ab37fa869ac Mon Sep 17 00:00:00 2001 From: sungrae jo Date: Thu, 18 Jan 2018 16:41:25 +0900 Subject: [PATCH 01/16] Add feature check for vc_widget Change-Id: I9e9d35dab9acfb7e81b83d2f59c89622102dd43a Signed-off-by: sungrae jo --- client/vc_widget.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/client/vc_widget.c b/client/vc_widget.c index 4b4486f..6c9f29b 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -15,6 +15,7 @@ */ #include +#include #include #include "vc_cmd_db.h" #include "vc_command.h" @@ -41,9 +42,41 @@ static Ecore_Timer* g_w_notify_result_timer = NULL; static int g_daemon_pid = 0; +static int g_feature_enabled = -1; + static Eina_Bool __vc_widget_notify_state_changed(void *data); static Eina_Bool __vc_widget_notify_error(void *data); +static int __vc_widget_get_feature_enabled() +{ + if (0 == g_feature_enabled) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Voice control feature NOT supported"); + return VC_ERROR_NOT_SUPPORTED; + } 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_VCW, "[ERROR] Voice control feature NOT supported"); + g_feature_enabled = 0; + return VC_ERROR_NOT_SUPPORTED; + } + + g_feature_enabled = 1; + } else { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get feature value"); + return VC_ERROR_NOT_SUPPORTED; + } + } else { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get feature value"); + return VC_ERROR_NOT_SUPPORTED; + } + } + + return 0; +} + const char* vc_tag() { return TAG_VCW; @@ -118,6 +151,11 @@ int vc_widget_initialize(vc_h* vc_w) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Initialize"); + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_ERROR, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NOT_SUPPORTED; + } + if (NULL == vc_w) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; -- 2.7.4 From 55ed2236925ea87e03f627bb4acb2be60946d535 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 17 Jan 2018 15:37:23 +0900 Subject: [PATCH 02/16] Use secure log to write result for security Change-Id: Icccb67c84d674dfc6b45bb868827486b74266a01 Signed-off-by: Jihoon Kim --- client/vc.c | 2 +- client/vc_mgr.c | 4 ++-- client/vc_widget.c | 4 ++-- server/vcd_server.c | 16 ++++++++-------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/client/vc.c b/client/vc.c index 9d0248c..c942050 100644 --- a/client/vc.c +++ b/client/vc.c @@ -1675,7 +1675,7 @@ static Eina_Bool __vc_notify_result(void *data) vc_info_parser_get_result(&temp_text, &event, NULL, getpid(), vc_cmd_list, false); - SLOG(LOG_INFO, TAG_VCC, "Result info : result text(%s) event(%d)", temp_text, event); + SECURE_SLOG(LOG_INFO, TAG_VCC, "Result info : result text(%s) event(%d)", temp_text, event); vc_cmd_print_list(vc_cmd_list); diff --git a/client/vc_mgr.c b/client/vc_mgr.c index be3cdb4..5e33f6a 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -1999,7 +1999,7 @@ static void __vc_mgr_notify_all_result(vc_result_type_e result_type) vc_info_parser_get_result(&temp_text, &event, &temp_message, -1, vc_cmd_list, vc_mgr_client_get_exclusive_command(g_vc_m)); - SLOG(LOG_INFO, TAG_VCM, "Result info : result type(%d) result text(%s) event(%d) result_message(%s)", + SECURE_SLOG(LOG_INFO, TAG_VCM, "Result info : result type(%d) result text(%s) event(%d) result_message(%s)", result_type, temp_text, event, temp_message); vc_cmd_print_list(vc_cmd_list); @@ -2092,7 +2092,7 @@ static Eina_Bool __vc_mgr_notify_result(void *data) vc_info_parser_get_result(&temp_text, &event, NULL, getpid(), vc_cmd_list, false); - SLOG(LOG_INFO, TAG_VCM, "Result : result text(%s) event(%d)", temp_text, event); + SECURE_SLOG(LOG_INFO, TAG_VCM, "Result : result text(%s) event(%d)", temp_text, event); vc_cmd_print_list(vc_cmd_list); diff --git a/client/vc_widget.c b/client/vc_widget.c index 6c9f29b..7fd9c4a 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -1146,7 +1146,7 @@ static Eina_Bool __vc_widget_notify_result(void *data) vc_info_parser_get_result(&temp_text, &event, NULL, getpid(), vc_cmd_list, false); - SLOG(LOG_DEBUG, TAG_VCW, "Result info : result text(%s) event(%d)", temp_text, event); + SECURE_SLOG(LOG_DEBUG, TAG_VCW, "Result info : result text(%s) event(%d)", temp_text, event); vc_result_cb callback = NULL; void* user_data = NULL; @@ -1195,7 +1195,7 @@ void __vc_widget_cb_result() bool __vc_widget_cb_asr_result(int event, const char* asr_result) { - SLOG(LOG_DEBUG, TAG_VCW, "Result info : result text(%s) event(%d)", asr_result, event); + SECURE_SLOG(LOG_DEBUG, TAG_VCW, "Result info : result text(%s) event(%d)", asr_result, event); vc_asr_result_cb callback = NULL; void* user_data = NULL; diff --git a/server/vcd_server.c b/server/vcd_server.c index d6b6155..6cbc2b9 100755 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -425,7 +425,7 @@ static Eina_Bool __vcd_send_selected_result(void *data) int vcd_send_asr_result(vce_asr_result_event_e event, const char* asr_result, void *user_data) { if (NULL != asr_result) { - SLOG(LOG_DEBUG, TAG_VCD, "[Server] ASR result - Event(%d), Text(%s)", event, asr_result); + SECURE_SLOG(LOG_DEBUG, TAG_VCD, "[Server] ASR result - Event(%d), Text(%s)", event, asr_result); vcdc_send_pre_result_to_manager(vcd_client_manager_get_pid(), event, asr_result); } @@ -436,13 +436,13 @@ int vcd_send_nlg_result(const char* nlg_result, void *user_data) { int ret = __vcd_server_launch_manager_app(); if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send dialog : mgr_pid(%d), nlg_result(%s)", vcd_client_manager_get_pid(), nlg_result); + SECURE_SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send dialog : mgr_pid(%d), nlg_result(%s)", vcd_client_manager_get_pid(), nlg_result); return ret; } ret = vcdc_send_dialog(vcd_client_manager_get_pid(), -1, nlg_result, NULL, 0); //0: VC_DIALOG_END if (0 != ret) - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send dialog : mgr_pid(%d), nlg_result(%s)", vcd_client_manager_get_pid(), nlg_result); + SECURE_SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send dialog : mgr_pid(%d), nlg_result(%s)", vcd_client_manager_get_pid(), nlg_result); return ret; } @@ -466,7 +466,7 @@ int vcd_send_result(vce_result_event_e event, int* result_id, int count, const c vc_info_parser_unset_result(vcd_client_manager_get_exclusive()); vcd_client_manager_set_result_text(all_result); - SLOG(LOG_INFO, TAG_VCD, "[Server] Event(%d), Text(%s) Nonfixed(%s) Msg(%s) Result count(%d)", + SECURE_SLOG(LOG_INFO, TAG_VCD, "[Server] Event(%d), Text(%s) Nonfixed(%s) Msg(%s) Result count(%d)", event, all_result, non_fixed_result, msg, count); if (VCD_RECOGNITION_MODE_RESTART_AFTER_REJECT == vcd_client_get_recognition_mode()) { @@ -644,7 +644,7 @@ int vcd_send_result(vce_result_event_e event, int* result_id, int count, const c } if (NULL != nlu_result) { - SLOG(LOG_INFO, TAG_VCD, "[Server] NLU (%s)", nlu_result); + SECURE_SLOG(LOG_INFO, TAG_VCD, "[Server] NLU (%s)", nlu_result); vc_info_parser_set_nlu_result(nlu_result); if (0 == is_action) { vc_cmd_h nlu_cmd; @@ -678,7 +678,7 @@ int vcd_send_result(vce_result_event_e event, int* result_id, int count, const c if (0 == result_count) { /* No result */ if (NULL != all_result) { - SLOG(LOG_DEBUG, TAG_VCD, "[Server] Engine result is no command : %s", all_result); + SECURE_SLOG(LOG_DEBUG, TAG_VCD, "[Server] Engine result is no command : %s", all_result); } else { SLOG(LOG_DEBUG, TAG_VCD, "[Server] Engine result is NULL"); } @@ -894,8 +894,8 @@ int vcd_send_result(vce_result_event_e event, int* result_id, int count, const c #if 0 static void __vcd_server_nlu_result_cb(vce_result_event_e event, const char* nlu_result, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "[Server] NLU result cb - event(%d)", event); - SLOG(LOG_DEBUG, TAG_VCD, "[Server] result (%s)", nlu_result); + SECURE_SLOG(LOG_DEBUG, TAG_VCD, "[Server] NLU result cb - event(%d)", event); + SECURE_SLOG(LOG_DEBUG, TAG_VCD, "[Server] result (%s)", nlu_result); int ret = vc_info_parser_set_nlu_result(nlu_result); if (0 != ret) { -- 2.7.4 From da82c8b949faa5a020bbe8e29c15786ad145b7a1 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 17 Jan 2018 18:32:56 +0900 Subject: [PATCH 03/16] Remove trailing whitespaces Change-Id: I47248fff4e6e2438aceb34c56ecb9d5f8157b81c Signed-off-by: Jihoon Kim --- include/voice_control_manager.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/voice_control_manager.h b/include/voice_control_manager.h index 1039771..eb0055b 100644 --- a/include/voice_control_manager.h +++ b/include/voice_control_manager.h @@ -170,7 +170,7 @@ typedef void (*vc_mgr_begin_speech_detected_cb)(void *user_data); * @param[in] pid Pid of VC client to request dialog * @param[in] disp_text Text that wants to be displayed * @param[in] utt_text Text that wants to be spoken -* @param[in] continuous Continue dialog session +* @param[in] continuous Continue dialog session * @param[in] user_data The user data passed from the callback registration function * * @pre An application registers callback function using vc_mgr_set_dialog_request_cb(). @@ -981,7 +981,7 @@ int vc_mgr_unset_error_cb(); /** -* @brief Registers a callback function to be called when dialog requests. +* @brief Registers a callback function to be called when dialog requests. * * @param[in] callback Callback function to register * @param[in] user_data The user data to be passed to the callback function -- 2.7.4 From 024aba56234b38e49b5c93524c0148b686bf830c Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Thu, 18 Jan 2018 17:57:28 +0900 Subject: [PATCH 04/16] Fix memory leaks of dbus Change-Id: Iedf8b56d98f0e59248f445ab13dd2a243f8eba12 Signed-off-by: Suyeon Hwang (cherry picked from commit e9423a086b7267e07d09b4d2f9bad0f29ec8f865) --- client/vc_dbus.c | 2 ++ client/vc_mgr_dbus.c | 2 ++ client/vc_widget_dbus.c | 2 ++ server/vcd_dbus.c | 2 ++ 4 files changed, 8 insertions(+) diff --git a/client/vc_dbus.c b/client/vc_dbus.c index 2bfeb78..c8d3937 100644 --- a/client/vc_dbus.c +++ b/client/vc_dbus.c @@ -191,10 +191,12 @@ static void __vc_dbus_connection_free() { if (NULL != g_conn_listener) { dbus_connection_close(g_conn_listener); + dbus_connection_unref(g_conn_listener); g_conn_listener = NULL; } if (NULL != g_conn_sender) { dbus_connection_close(g_conn_sender); + dbus_connection_unref(g_conn_sender); g_conn_sender = NULL; } } diff --git a/client/vc_mgr_dbus.c b/client/vc_mgr_dbus.c index 26124cd..4d182c3 100644 --- a/client/vc_mgr_dbus.c +++ b/client/vc_mgr_dbus.c @@ -594,10 +594,12 @@ static void __vc_mgr_dbus_connection_free() { if (NULL != g_m_conn_listener) { dbus_connection_close(g_m_conn_listener); + dbus_connection_unref(g_m_conn_listener); g_m_conn_listener = NULL; } if (NULL != g_m_conn_sender) { dbus_connection_close(g_m_conn_sender); + dbus_connection_unref(g_m_conn_sender); g_m_conn_sender = NULL; } } diff --git a/client/vc_widget_dbus.c b/client/vc_widget_dbus.c index 59d7a60..14d3f4d 100644 --- a/client/vc_widget_dbus.c +++ b/client/vc_widget_dbus.c @@ -274,10 +274,12 @@ static void __vc_mgr_dbus_connection_free() { if (NULL != g_w_conn_listener) { dbus_connection_close(g_w_conn_listener); + dbus_connection_unref(g_w_conn_listener); g_w_conn_listener = NULL; } if (NULL != g_w_conn_sender) { dbus_connection_close(g_w_conn_sender); + dbus_connection_unref(g_w_conn_sender); g_w_conn_sender = NULL; } } diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c index 8091d79..325aaf3 100755 --- a/server/vcd_dbus.c +++ b/server/vcd_dbus.c @@ -1146,7 +1146,9 @@ int vcd_dbus_close_connection() } dbus_connection_close(g_conn_listener); + dbus_connection_unref(g_conn_listener); dbus_connection_close(g_conn_sender); + dbus_connection_unref(g_conn_sender); g_conn_listener = NULL; g_conn_sender = NULL; -- 2.7.4 From 0011a3e9e52e748b897e20fb843b449de5adcc33 Mon Sep 17 00:00:00 2001 From: sungrae jo Date: Mon, 8 Jan 2018 10:45:03 +0900 Subject: [PATCH 05/16] Fixed sound-manager function. Signed-off-by: sungrae jo Change-Id: I303e29277b528926c89b24dc6e0dba0edf4ad740 --- server/vcd_recorder.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index aab017a..7c08a6f 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -259,13 +259,13 @@ static int __apply_device_for_stream_routing() sound_device_type_e type; sound_device_io_direction_e io_direction; - if (0 != sound_manager_get_current_device_list(SOUND_DEVICE_IO_DIRECTION_IN_MASK, &device_list)) { + if (0 != sound_manager_get_device_list(SOUND_DEVICE_IO_DIRECTION_IN_MASK, &device_list)) { SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to get current device list"); return -1; } - int ret = 0; - while (0 == (ret = sound_manager_get_next_device(device_list, &device))) { + int ret = -1; + while (0 == sound_manager_get_next_device(device_list, &device)) { if (0 != sound_manager_get_device_type(device, &type)) { SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to get device tyep"); continue; @@ -280,16 +280,23 @@ static int __apply_device_for_stream_routing() continue; } if (0 != sound_manager_apply_stream_routing(g_stream_info_h)) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR} Fail to apply stream routing"); + SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to apply stream routing"); continue; } - SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] Apply device for stream routing"); - return 0; + ret = 0; + break; } } - SLOG(LOG_WARN, TAG_VCD, "[Recorder] No device"); - return -1; + sound_manager_free_device_list(device_list); + device_list = NULL; + + if (0 != ret) { + SLOG(LOG_WARN, TAG_VCD, "[Recorder] No device"); + } else { + SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] Apply device for stream routing"); + } + return ret; } static void __device_connection_changed_cb(sound_device_h device, bool is_connected, void *user_data) -- 2.7.4 From e7cc4b804f8ffda99680be06c18b155b2cddb24a Mon Sep 17 00:00:00 2001 From: sungrae jo Date: Fri, 19 Jan 2018 17:18:15 +0900 Subject: [PATCH 06/16] Add feature check for vc_widget Change-Id: If44f3a47174b9320748116798412cba11caf626a Signed-off-by: sungrae jo (cherry picked from commit 29d4307edf01b7361bf0a72327ae405bc84d0508) --- client/vc_widget.c | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/client/vc_widget.c b/client/vc_widget.c index 7fd9c4a..89426e1 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -256,6 +256,11 @@ int vc_widget_deinitialize(vc_h vc_w) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Deinitialize"); + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + if (false == vc_widget_client_is_valid(vc_w)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] NOT initialized"); SLOG(LOG_DEBUG, TAG_VCW, "@@@"); @@ -411,6 +416,11 @@ int vc_widget_prepare(vc_h vc_w) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Prepare"); + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); @@ -443,6 +453,11 @@ int vc_widget_unprepare(vc_h vc_w) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Unprepare"); + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); @@ -471,6 +486,11 @@ int vc_widget_enable_asr_result(vc_h vc_w, bool enable) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Enable asr result"); + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); @@ -517,6 +537,11 @@ int vc_widget_foreach_supported_languages(vc_h vc_w, vc_supported_language_cb ca { SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Foreach Supported Language"); + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + if (NULL == callback) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "@@@"); @@ -546,6 +571,11 @@ int vc_widget_get_current_language(vc_h vc_w, char** language) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Get Current Language"); + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + if (NULL == language) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "@@@"); @@ -575,6 +605,11 @@ int vc_widget_get_state(vc_h vc_w, vc_state_e* state) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Get State"); + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + if (NULL == state) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -605,6 +640,11 @@ int vc_widget_get_service_state(vc_h vc_w, vc_service_state_e* state) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Get Service State"); + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + if (NULL == state) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -649,6 +689,11 @@ int vc_widget_set_foreground(vc_h vc_w, bool value) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Set foreground state"); + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not valid"); @@ -881,6 +926,11 @@ int vc_widget_cancel(vc_h vc_w) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Cancel Recognition"); + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); @@ -1270,6 +1320,11 @@ static Eina_Bool __vc_widget_notify_state_changed(void *data) int vc_widget_set_result_cb(vc_h vc_w, vc_result_cb callback, void* user_data) { + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + if (NULL == vc_w) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -1297,6 +1352,11 @@ int vc_widget_set_result_cb(vc_h vc_w, vc_result_cb callback, void* user_data) int vc_widget_unset_result_cb(vc_h vc_w) { + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + if (NULL == vc_w) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -1322,6 +1382,11 @@ int vc_widget_unset_result_cb(vc_h vc_w) int vc_widget_set_show_tooltip_cb(vc_h vc_w, vc_widget_show_tooltip_cb callback, void* user_data) { + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + if (NULL == vc_w) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -1350,6 +1415,11 @@ int vc_widget_set_show_tooltip_cb(vc_h vc_w, vc_widget_show_tooltip_cb callback, int vc_widget_unset_show_tooltip_cb(vc_h vc_w) { + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + if (NULL == vc_w) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -1375,6 +1445,11 @@ int vc_widget_unset_show_tooltip_cb(vc_h vc_w) int vc_widget_set_send_current_command_list_cb(vc_h vc_w, vc_widget_send_current_command_list_cb callback, void* user_data) { + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + if (NULL == vc_w) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -1400,6 +1475,11 @@ int vc_widget_set_send_current_command_list_cb(vc_h vc_w, vc_widget_send_current int vc_widget_unset_send_current_command_list_cb(vc_h vc_w) { + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + if (NULL == vc_w) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -1471,6 +1551,11 @@ int __vc_widget_cb_service_state(int state) int vc_widget_set_service_state_changed_cb(vc_h vc_w, vc_service_state_changed_cb callback, void* user_data) { + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + if (NULL == vc_w) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -1496,6 +1581,11 @@ int vc_widget_set_service_state_changed_cb(vc_h vc_w, vc_service_state_changed_c int vc_widget_unset_service_state_changed_cb(vc_h vc_w) { + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + if (NULL == vc_w) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -1521,6 +1611,11 @@ int vc_widget_unset_service_state_changed_cb(vc_h vc_w) int vc_widget_set_state_changed_cb(vc_h vc_w, vc_state_changed_cb callback, void* user_data) { + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + if (NULL == vc_w) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -1549,6 +1644,11 @@ int vc_widget_set_state_changed_cb(vc_h vc_w, vc_state_changed_cb callback, void int vc_widget_unset_state_changed_cb(vc_h vc_w) { + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + if (NULL == vc_w) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -1574,6 +1674,11 @@ int vc_widget_unset_state_changed_cb(vc_h vc_w) int vc_widget_set_asr_result_cb(vc_h vc_w, vc_asr_result_cb callback, void* user_data) { + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + if (NULL == vc_w) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -1602,6 +1707,11 @@ int vc_widget_set_asr_result_cb(vc_h vc_w, vc_asr_result_cb callback, void* user int vc_widget_unset_asr_result_cb(vc_h vc_w) { + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + if (NULL == vc_w) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -1627,6 +1737,11 @@ int vc_widget_unset_asr_result_cb(vc_h vc_w) int vc_widget_set_current_language_changed_cb(vc_h vc_w, vc_current_language_changed_cb callback, void* user_data) { + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + if (NULL == vc_w) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -1655,6 +1770,11 @@ int vc_widget_set_current_language_changed_cb(vc_h vc_w, vc_current_language_cha int vc_widget_unset_current_language_changed_cb(vc_h vc_w) { + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + if (NULL == vc_w) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -1680,6 +1800,11 @@ int vc_widget_unset_current_language_changed_cb(vc_h vc_w) int vc_widget_set_error_cb(vc_h vc_w, vc_error_cb callback, void* user_data) { + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + if (NULL == vc_w) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; @@ -1708,6 +1833,11 @@ int vc_widget_set_error_cb(vc_h vc_w, vc_error_cb callback, void* user_data) int vc_widget_unset_error_cb(vc_h vc_w) { + if (0 != __vc_widget_get_feature_enabled()) { + SLOG(LOG_INFO, TAG_VCW, "@@@ [Widget] not supported"); + return VC_ERROR_NONE; + } + if (NULL == vc_w) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); return VC_ERROR_INVALID_PARAMETER; -- 2.7.4 From 687e7b4c2e48ac2b1d23a1afadcaa33b85134338 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Mon, 15 Jan 2018 15:49:53 +0900 Subject: [PATCH 07/16] Try to prepare when dbus call is requested earlier while a vc engine is reset Change-Id: Id95a5d7154681cd4b066b8e6582d15eabe7774f6 Signed-off-by: Suyeon Hwang (cherry picked from commit d4e615b4a7be6a668af8e61319be43f009478e26) --- client/vc.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 13 deletions(-) diff --git a/client/vc.c b/client/vc.c index c942050..da52879 100644 --- a/client/vc.c +++ b/client/vc.c @@ -566,7 +566,6 @@ static void __start_prepare_thread(void *data, Ecore_Thread *thread) /* Send hello */ while (0 != ret) { - if (retry_count == 10) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request hello !!"); return; @@ -655,7 +654,7 @@ int vc_prepare_sync(void) /* check state */ if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'CREATED'"); + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'INITIALIZED'"); SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -913,11 +912,17 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) bool is_sys_cmd_valid = false; int count = 0; int ret = -1; - + bool is_prepared = false; do { ret = vc_dbus_request_is_system_command_valid(g_vc->handle, &is_sys_cmd_valid); if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { + if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { + vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); + if (0 == vc_prepare_sync()) { + is_prepared = true; + SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); + } + } else if (VC_ERROR_TIMED_OUT != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to ask system command is : %s", __vc_get_error_code(ret)); break; } else { @@ -1150,10 +1155,17 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to save command list : %s", __vc_get_error_code(ret)); } else { int count = 0; + bool is_prepared = false; do { ret = vc_dbus_request_set_command(g_vc->handle, (vc_cmd_type_e)type); if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { + if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { + vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); + if (0 == vc_prepare_sync()) { + is_prepared = true; + SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); + } + } else if (VC_ERROR_TIMED_OUT != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request set command to daemon : %s", __vc_get_error_code(ret)); break; } else { @@ -1209,10 +1221,17 @@ int vc_unset_command_list(int type) int count = 0; int ret = -1; + bool is_prepared = false; while (0 != ret) { ret = vc_dbus_request_unset_command(g_vc->handle, (vc_cmd_type_e)type); if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { + if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { + vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); + if (0 == vc_prepare_sync()) { + is_prepared = true; + SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); + } + } else if (VC_ERROR_TIMED_OUT != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request unset command to daemon : %s", __vc_get_error_code(ret)); break; } else { @@ -1289,10 +1308,17 @@ int vc_set_command_list_from_file(const char* file_path, int type) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set commands from file : %s", __vc_get_error_code(ret)); } else { int count = 0; + bool is_prepared = false; do { ret = vc_dbus_request_set_command(g_vc->handle, (vc_cmd_type_e)type); if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { + if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { + vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); + if (0 == vc_prepare_sync()) { + is_prepared = true; + SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); + } + } else if (VC_ERROR_TIMED_OUT != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request set command to daemon : %s", __vc_get_error_code(ret)); break; } else { @@ -2411,15 +2437,20 @@ int vc_auth_start(void) return VC_ERROR_OPERATION_FAILED; } - int ret; + int ret = -1; int count = 0; + bool is_prepared = false; /* Request */ - ret = -1; - count = 0; while (0 != ret) { ret = vc_dbus_request_auth_start(g_vc->handle, mgr_pid); if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { + if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { + vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); + if (0 == vc_prepare_sync()) { + is_prepared = true; + SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); + } + } else if (VC_ERROR_TIMED_OUT != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request auth start : %s", __vc_get_error_code(ret)); break; } else { @@ -2489,11 +2520,18 @@ int vc_auth_stop(void) int ret = -1; int count = 0; + bool is_prepared = false; /* do request */ while (0 != ret) { ret = vc_dbus_request_auth_stop(g_vc->handle, mgr_pid); if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { + if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { + vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); + if (0 == vc_prepare_sync()) { + is_prepared = true; + SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); + } + } else if (VC_ERROR_TIMED_OUT != ret) { SLOG(LOG_DEBUG, TAG_VCC, "[ERROR] Fail to request auth stop: %s", __vc_get_error_code(ret)); break; } else { @@ -2563,10 +2601,17 @@ int vc_auth_cancel(void) int ret = -1; int count = 0; + bool is_prepared = false; while (0 != ret) { ret = vc_dbus_request_auth_cancel(g_vc->handle, mgr_pid); if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { + if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { + vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); + if (0 == vc_prepare_sync()) { + is_prepared = true; + SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); + } + } else if (VC_ERROR_TIMED_OUT != ret) { SLOG(LOG_DEBUG, TAG_VCC, "[ERROR] Fail to request auth cancel: %s", __vc_get_error_code(ret)); break; } else { -- 2.7.4 From 2cdea0cceffe58976806a8e4a252647a386262aa Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Mon, 15 Jan 2018 20:22:36 +0900 Subject: [PATCH 08/16] Load default config file when user config is invalid Change-Id: I0021fefc33e167a256c6ad3f52f0854b4c60987a Signed-off-by: Wonnam Jang (cherry picked from commit bc058016cd72cb627aa9a6d3f51f4c7d3aed8dc2) --- common/vc_config_parser.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/common/vc_config_parser.c b/common/vc_config_parser.c index 0048a05..ac89c5a 100644 --- a/common/vc_config_parser.c +++ b/common/vc_config_parser.c @@ -322,7 +322,14 @@ int vc_parser_load_config(vc_config_s** config_info) if (VC_RETRY_COUNT == retry_count) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to parse file error : %s", VC_CONFIG); - return -1; + doc = xmlParseFile(VC_CONFIG_DEFAULT); + if (NULL == doc) { + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to parse file error : %s", VC_CONFIG_DEFAULT); + xmlCleanupParser(); + return -1; + } + is_default_open = true; + break; } } } @@ -426,9 +433,25 @@ int vc_parser_load_config(vc_config_s** config_info) g_config_doc = doc; if (is_default_open) { - xmlSaveFile(VC_CONFIG, g_config_doc); + int retry_count = 0; + int ret = -1; + do { + ret = xmlSaveFile(VC_CONFIG, g_config_doc); + if (0 < ret) + break; + retry_count++; + usleep(10000); + + if (VC_RETRY_COUNT == retry_count) { + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save config file: %d", ret); + return -1; + } + } while (0 != ret); + if (0 != __vc_config_parser_set_file_mode(VC_CONFIG)) SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to set file mode - %s", VC_CONFIG); + + SLOG(LOG_ERROR, vc_config_tag(), "Default config is changed : pid(%d)", getpid()); } return 0; -- 2.7.4 From 8b68b96409cbe2e0929f693b555079a40c694573 Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Tue, 16 Jan 2018 14:50:41 +0900 Subject: [PATCH 09/16] Add log for debugging Change-Id: I80ffb9f2238c273119373f39b0b054f8c3ce253d Signed-off-by: Wonnam Jang --- client/vc_mgr.c | 60 ++++++++++++++++++++++++++--------------------------- server/vcd_server.c | 39 +++++++++++++++++++++------------- 2 files changed, 55 insertions(+), 44 deletions(-) diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 5e33f6a..2ed9ab5 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -123,7 +123,7 @@ static int __vc_mgr_get_feature_enabled() int vc_mgr_initialize() { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Initialize"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Initialize"); if (0 != __vc_mgr_get_feature_enabled()) { @@ -170,7 +170,7 @@ int vc_mgr_initialize() return ret; } - SLOG(LOG_DEBUG, TAG_VCM, "[Success] pid(%d)", g_vc_m->handle); + SLOG(LOG_ERROR, TAG_VCM, "[Success] pid(%d)", g_vc_m->handle); SLOG(LOG_DEBUG, TAG_VCM, "@@@"); @@ -190,7 +190,7 @@ static void __vc_mgr_internal_unprepare() int vc_mgr_deinitialize() { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Deinitialize"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Deinitialize"); if (false == vc_mgr_client_is_valid(g_vc_m)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] NOT initialized"); @@ -242,7 +242,7 @@ int vc_mgr_deinitialize() SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to close connection"); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_ERROR, TAG_VCM, "@@@"); return VC_ERROR_NONE; } @@ -280,7 +280,7 @@ static Eina_Bool __vc_mgr_connect_daemon(void *data) /* Set foreground */ vc_mgr_client_set_foreground(g_vc_m, foreground, true); - SLOG(LOG_DEBUG, TAG_VCM, "[SUCCESS] Connected daemon"); + SLOG(LOG_ERROR, TAG_VCM, "[SUCCESS] Connected daemon"); vc_mgr_client_set_client_state(g_vc_m, VC_STATE_READY); @@ -354,7 +354,7 @@ static void __end_prepare_thread(void *data, Ecore_Thread *thread) int vc_mgr_prepare() { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Prepare"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Prepare"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -379,7 +379,7 @@ int vc_mgr_prepare() int vc_mgr_unprepare() { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Unprepare"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Unprepare"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -453,7 +453,7 @@ int vc_mgr_get_current_language(char** language) ret = vc_config_convert_error_code((vc_config_error_e)ret); SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get current languages : %s", __vc_mgr_get_error_code(ret)); } else { - SLOG(LOG_DEBUG, TAG_VCM, "[Get current language] language : %s", *language); + SLOG(LOG_ERROR, TAG_VCM, "[Get current language] language : %s", *language); } return ret; @@ -597,7 +597,7 @@ int vc_mgr_unset_demandable_client_rule() int vc_mgr_is_command_format_supported(vc_cmd_format_e format, bool* support) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Is command type supported"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Is command type supported"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -630,7 +630,7 @@ int vc_mgr_is_command_format_supported(vc_cmd_format_e format, bool* support) int vc_mgr_enable_command_type(int cmd_type) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Enable Command Type"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Enable Command Type, cmd_type(%d)", cmd_type); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -675,14 +675,14 @@ int vc_mgr_enable_command_type(int cmd_type) } } while (0 != ret); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); return ret; } int vc_mgr_disable_command_type(int cmd_type) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Disable Command Type"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Disable Command Type, cmd_type(%d)", cmd_type); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -727,14 +727,14 @@ int vc_mgr_disable_command_type(int cmd_type) } } while (0 != ret); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); return ret; } int vc_mgr_set_command_list(vc_cmd_list_h vc_cmd_list) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Set Command list"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Set Command list"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -814,14 +814,14 @@ int vc_mgr_set_command_list(vc_cmd_list_h vc_cmd_list) } while (0 != ret); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); return ret; } int vc_mgr_unset_command_list() { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Unset Command list"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Unset Command list"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -862,14 +862,14 @@ int vc_mgr_unset_command_list() SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to delete file, type(%d), ret(%d)", i, ret); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_ERROR, TAG_VCM, "@@@"); return 0; } int vc_mgr_set_command_list_from_file(const char* file_path, int type) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Set Command list from file"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Set Command list from file, type(%d)", type); if (NULL == file_path) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid parameter!!"); @@ -933,14 +933,14 @@ int vc_mgr_set_command_list_from_file(const char* file_path, int type) } while (0 != ret); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); return ret; } int vc_mgr_set_preloaded_commands_from_file(const char* file_path) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Set preloaded command list"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Set preloaded command list"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -967,13 +967,13 @@ int vc_mgr_set_preloaded_commands_from_file(const char* file_path) if (0 != ret) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to insert preloaded commands into db"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); return ret; } int vc_mgr_set_audio_type(const char* audio_id) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Set audio type"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Set audio type, audio_id(%s)", audio_id); if (NULL == audio_id) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Input parameter is NULL"); @@ -1029,14 +1029,14 @@ int vc_mgr_set_audio_type(const char* audio_id) } } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); return ret; } int vc_mgr_get_audio_type(char** audio_id) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Get audio type"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Get audio type"); if (NULL == audio_id) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Input parameter is NULL"); @@ -1090,7 +1090,7 @@ int vc_mgr_get_audio_type(char** audio_id) } } } else { - SLOG(LOG_DEBUG, TAG_VCM, "[SUCCESS] Get audio type : %s", temp); + SLOG(LOG_ERROR, TAG_VCM, "[SUCCESS] Get audio type : %s", temp); /* Save */ vc_mgr_client_set_audio_type(g_vc_m, temp); } @@ -1108,7 +1108,7 @@ int vc_mgr_get_audio_type(char** audio_id) int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Foreach current commands"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Foreach current commands"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1294,7 +1294,7 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) SLOG(LOG_DEBUG, TAG_VCM, "[Manager] No background commands"); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_ERROR, TAG_VCM, "@@@"); return 0; } @@ -1587,7 +1587,7 @@ int vc_mgr_do_action(vc_send_event_type_e type, char* send_event) int vc_mgr_start(bool exclusive_command_option) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Request start"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Request start"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1665,14 +1665,14 @@ int vc_mgr_start(bool exclusive_command_option) g_prev_volume_db = 0; g_cur_volume_db = 0; - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); return ret; } int vc_mgr_stop() { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Request stop"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Request stop"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { diff --git a/server/vcd_server.c b/server/vcd_server.c index 6cbc2b9..6b13ed0 100755 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -400,7 +400,7 @@ static Eina_Bool __vcd_send_selected_result(void *data) SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send result, ret(%d)", ret); break; } else { - SLOG(LOG_DEBUG, TAG_VCD, "[Server] Send result : pid(%d) type(%d)", temp_cmd->pid, temp_cmd->type); + SLOG(LOG_ERROR, TAG_VCD, "[Server] Send result : pid(%d) type(%d)", temp_cmd->pid, temp_cmd->type); pre_pid = temp_cmd->pid; pre_type = temp_cmd->type; } @@ -440,6 +440,7 @@ int vcd_send_nlg_result(const char* nlg_result, void *user_data) return ret; } + SLOG(LOG_ERROR, TAG_VCD, "[Server] send dialog : mgr_pid(%d), nlg_result(%s)", vcd_client_manager_get_pid(), nlg_result); ret = vcdc_send_dialog(vcd_client_manager_get_pid(), -1, nlg_result, NULL, 0); //0: VC_DIALOG_END if (0 != ret) SECURE_SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send dialog : mgr_pid(%d), nlg_result(%s)", vcd_client_manager_get_pid(), nlg_result); @@ -469,6 +470,8 @@ int vcd_send_result(vce_result_event_e event, int* result_id, int count, const c SECURE_SLOG(LOG_INFO, TAG_VCD, "[Server] Event(%d), Text(%s) Nonfixed(%s) Msg(%s) Result count(%d)", event, all_result, non_fixed_result, msg, count); + SLOG(LOG_ERROR, TAG_VCD, "[Server] NLU result(%s)", nlu_result); + if (VCD_RECOGNITION_MODE_RESTART_AFTER_REJECT == vcd_client_get_recognition_mode()) { if (VCE_RESULT_EVENT_REJECTED == event) { SLOG(LOG_DEBUG, TAG_VCD, "[Server] Restart by no or rejected result"); @@ -572,7 +575,7 @@ int vcd_send_result(vce_result_event_e event, int* result_id, int count, const c if (true == is_consumed) { if (NULL != user_info) { *user_info = 0x01; - SLOG(LOG_DEBUG, TAG_VCD, "[Server] Send whether ASR result is consumed or not (%d)", *user_info); + SLOG(LOG_ERROR, TAG_VCD, "[Server] Send whether ASR result is consumed or not (%d)", *user_info); } vcdc_send_show_tooltip(pid, false); if (-1 != vcd_client_manager_get_pid()) { @@ -1024,7 +1027,7 @@ int vcd_initialize(vce_request_callback_s *callback) vcd_config_set_service_state(VCD_STATE_READY); vcdc_send_service_state(VCD_STATE_READY); - SLOG(LOG_DEBUG, TAG_VCD, "[Server SUCCESS] initialize"); + SLOG(LOG_ERROR, TAG_VCD, "[Server SUCCESS] initialize"); return 0; } @@ -1069,7 +1072,7 @@ void vcd_finalize() vcd_config_set_service_state(VCD_STATE_NONE); vcdc_send_service_state(VCD_STATE_NONE); - SLOG(LOG_DEBUG, TAG_VCD, "[Server] mode finalize"); + SLOG(LOG_ERROR, TAG_VCD, "[Server] mode finalize"); return; } @@ -1325,7 +1328,7 @@ int vcd_server_mgr_initialize(int pid) if (0 != vcdc_send_manager_pid(pid)) SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send manager pid"); - SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Manager initialize : pid(%d)", pid); + SLOG(LOG_ERROR, TAG_VCD, "[Server Success] Manager initialize : pid(%d)", pid); return VCD_ERROR_NONE; } @@ -1354,7 +1357,7 @@ int vcd_server_mgr_finalize(int pid) ecore_timer_add(0, __finalize_quit_ecore_loop, NULL); } - SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Manager Finalize : pid(%d)", pid); + SLOG(LOG_ERROR, TAG_VCD, "[Server Success] Manager Finalize : pid(%d)", pid); return VCD_ERROR_NONE; } @@ -1486,7 +1489,7 @@ static int __start_internal_recognition() return VCD_ERROR_OPERATION_FAILED; } - SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Set command"); + SLOG(LOG_ERROR, TAG_VCD, "[Server Success] Set command"); bool stop_by_silence = true; if (VCD_RECOGNITION_MODE_MANUAL == vcd_client_get_recognition_mode()) { @@ -1506,7 +1509,7 @@ static int __start_internal_recognition() return VCD_ERROR_OPERATION_FAILED; } - SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Start engine"); + SLOG(LOG_ERROR, TAG_VCD, "[Server Success] Start engine"); #if 1 /* 5. recorder start */ @@ -1525,7 +1528,7 @@ static int __start_internal_recognition() vcd_config_set_service_state(VCD_STATE_RECORDING); vcdc_send_service_state(VCD_STATE_RECORDING); - SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Start recognition(%d)", stop_by_silence); + SLOG(LOG_ERROR, TAG_VCD, "[Server Success] Start recognition(%d)", stop_by_silence); return 0; } @@ -1534,7 +1537,7 @@ static Eina_Bool __vcd_request_show_tooltip(void *data) { int pid = vcd_client_widget_get_foreground_pid(); if (-1 != pid) { - SLOG(LOG_DEBUG, TAG_VCD, "[Server] Request tooltip show and widget command"); + SLOG(LOG_ERROR, TAG_VCD, "[Server] Request tooltip show and widget command, show(%d)", (bool)data); vcdc_send_show_tooltip(pid, (bool)data); } @@ -1556,7 +1559,7 @@ int vcd_server_mgr_start(vcd_recognition_mode_e recognition_mode, bool exclusive } vcd_client_widget_set_waiting_for_recording(-1, false); - SLOG(LOG_DEBUG, TAG_VCD, "[Server] set recognition mode = %d", recognition_mode); + SLOG(LOG_ERROR, TAG_VCD, "[Server] set recognition mode = %d", recognition_mode); vcd_client_set_recognition_mode(recognition_mode); if (false == exclusive_cmd) { @@ -1565,7 +1568,7 @@ int vcd_server_mgr_start(vcd_recognition_mode_e recognition_mode, bool exclusive if (1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_WIDGET)) { int pid = vcd_client_widget_get_foreground_pid(); if (-1 != pid) { - SLOG(LOG_INFO, TAG_VCD, "[Server] Request tooltip show and widget command"); + SLOG(LOG_ERROR, TAG_VCD, "[Server] Request tooltip show and widget command"); ecore_timer_add(0, __vcd_request_show_tooltip, (void*)true); vcd_client_widget_set_waiting_for_recording(pid, true); return 0; @@ -1588,6 +1591,8 @@ int vcd_server_mgr_start(vcd_recognition_mode_e recognition_mode, bool exclusive } } + SLOG(LOG_ERROR, TAG_VCD, "[Server] start internal recognition"); + int ret = __start_internal_recognition(); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to start recongition : %d", ret); @@ -1598,6 +1603,7 @@ int vcd_server_mgr_start(vcd_recognition_mode_e recognition_mode, bool exclusive vcd_client_unset_exclusive_command(fg_pid); } + SLOG(LOG_ERROR, TAG_VCD, "[Server Success] start internal recognition"); return VCD_ERROR_NONE; } @@ -1612,6 +1618,7 @@ int vcd_server_mgr_stop() SLOG(LOG_DEBUG, TAG_VCD, "[Server] Manager is NOT available."); return VCD_ERROR_OPERATION_FAILED; } + SLOG(LOG_ERROR, TAG_VCD, "[Server] stop internal recognition"); #if 1 /* 2. Stop recorder */ @@ -1628,6 +1635,7 @@ int vcd_server_mgr_stop() vcd_config_set_service_state(VCD_STATE_PROCESSING); vcdc_send_service_state(VCD_STATE_PROCESSING); + SLOG(LOG_ERROR, TAG_VCD, "[Server Success] stop internal recognition"); return VCD_ERROR_NONE; } @@ -1663,6 +1671,7 @@ int vcd_server_mgr_cancel() vcdc_send_service_state(VCD_STATE_READY); return VCD_ERROR_NONE; } + SLOG(LOG_ERROR, TAG_VCD, "[Server] cancel internal recognition"); #if 1 /* 2. Stop recorder */ @@ -1691,6 +1700,7 @@ int vcd_server_mgr_cancel() vcd_config_set_service_state(VCD_STATE_READY); vcdc_send_service_state(VCD_STATE_READY); + SLOG(LOG_ERROR, TAG_VCD, "[Server Success] cancel internal recognition"); return VCD_ERROR_NONE; } @@ -1831,7 +1841,7 @@ int vcd_server_mgr_enable_command_type(int pid, int cmd_type) if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to enable command type"); } else { - SLOG(LOG_DEBUG, TAG_VCD, "[Server] Enable command type(%d)", cmd_type); + SLOG(LOG_ERROR, TAG_VCD, "[Server] Enable command type(%d)", cmd_type); } return ret; @@ -1857,7 +1867,7 @@ int vcd_server_mgr_disable_command_type(int pid, int cmd_type) if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to disable command type"); } else { - SLOG(LOG_DEBUG, TAG_VCD, "[Server] Disable command type(%d)", cmd_type); + SLOG(LOG_ERROR, TAG_VCD, "[Server] Disable command type(%d)", cmd_type); } return ret; @@ -2250,6 +2260,7 @@ int vcd_server_widget_start_recording(int pid, bool widget_command) SLOG(LOG_WARN, TAG_VCD, "[Server] widget command is NOT available"); } + SLOG(LOG_ERROR, TAG_VCD, "[Server] start internal recongition : %d", widget_command); int ret = __start_internal_recognition(); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to start recongition : %d", ret); -- 2.7.4 From b6bd8182b5ef14425febae7684d39fb1e825da81 Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Tue, 16 Jan 2018 20:13:28 +0900 Subject: [PATCH 10/16] Reset waiting flag when recognition starts by widget Change-Id: I3bbfbaa4d8bfee09563ec0ecccfdca2e167e06af Signed-off-by: Wonnam Jang (cherry picked from commit 2f1663d67c69531413405f80bdca4b47b5322305) --- server/vcd_server.c | 1 + 1 file changed, 1 insertion(+) diff --git a/server/vcd_server.c b/server/vcd_server.c index 6cbc2b9..d6646f2 100755 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1465,6 +1465,7 @@ int vcd_server_mgr_set_client_info(int pid) static int __start_internal_recognition() { int ret; + vcd_client_widget_set_waiting_for_recording(-1, false); if (0 != vcd_client_command_collect_command()) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to collect command"); -- 2.7.4 From e5aa26e2ab9eb8fc4bbff513a5d2af93c865433b Mon Sep 17 00:00:00 2001 From: sungrae jo Date: Wed, 24 Jan 2018 15:08:53 +0900 Subject: [PATCH 11/16] Fixed logic for stt unprepare Change-Id: Icd0b56cda3d049fea008e72dec7127332fd3002e Signed-off-by: sungrae jo --- server/vcd_engine_agent.c | 8 ++++++-- server/vcd_recorder.c | 4 +++- server/vcd_server.c | 22 ++++++++++++++-------- server/vcd_server.h | 2 +- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/server/vcd_engine_agent.c b/server/vcd_engine_agent.c index 1f4c585..28748fd 100644 --- a/server/vcd_engine_agent.c +++ b/server/vcd_engine_agent.c @@ -120,7 +120,10 @@ int vcd_engine_agent_release() } /* unload current engine */ - vcd_engine_agent_unload_current_engine(); + if (0 != vcd_engine_agent_unload_current_engine()) { + SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to deinitialize"); + return VCD_ERROR_OPERATION_FAILED; + } /* release current engine data */ if (NULL != g_dynamic_engine.callbacks) { @@ -298,12 +301,13 @@ int vcd_engine_agent_unload_current_engine() ret = g_dynamic_engine.callbacks->deinitialize(); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to deinitialize"); + return VCD_ERROR_OPERATION_FAILED; } /* reset current engine data */ g_dynamic_engine.is_loaded = false; - return 0; + return VCD_ERROR_NONE; } diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index f3194d4..eea8f50 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -483,7 +483,9 @@ int vcd_recorder_destroy() if (0 != ret) SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to destroy stream info, ret(%d)", ret); - audio_in_destroy(g_audio_h); + ret = audio_in_destroy(g_audio_h); + if (0 != ret) + SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to audio in destroy, ret(%d)", ret); #ifdef TV_BT_MODE bt_hid_unset_audio_data_receive_cb(); diff --git a/server/vcd_server.c b/server/vcd_server.c index 6cbc2b9..9c28722 100755 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1029,7 +1029,7 @@ int vcd_initialize(vce_request_callback_s *callback) return 0; } -void vcd_finalize() +bool vcd_finalize() { GList *iter = NULL; if (0 < g_list_length(g_proc_list)) { @@ -1054,12 +1054,14 @@ void vcd_finalize() } if (0 != vcd_recorder_destroy()) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to destroy recorder"); + return false; } else { SLOG(LOG_DEBUG, TAG_VCD, "[Server] destroy recorder"); } if (0 != vcd_engine_agent_release()) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to release engine"); + return false; } else { SLOG(LOG_DEBUG, TAG_VCD, "[Server] release engine"); } @@ -1071,14 +1073,18 @@ void vcd_finalize() SLOG(LOG_DEBUG, TAG_VCD, "[Server] mode finalize"); - return; + return true; } static Eina_Bool __finalize_quit_ecore_loop(void *data) { - SLOG(LOG_ERROR, TAG_VCD, "[Server] quit ecore main loop"); - ecore_main_loop_quit(); - return EINA_FALSE; + bool ret = vcd_finalize(); + if (false == ret) { + return EINA_TRUE; + } else { + ecore_main_loop_quit(); + return EINA_FALSE; + } } static void __read_proc() @@ -1351,7 +1357,7 @@ int vcd_server_mgr_finalize(int pid) if (0 == vcd_client_get_ref_count()) { SLOG(LOG_DEBUG, TAG_VCD, "[Server] Connected client list is empty"); - ecore_timer_add(0, __finalize_quit_ecore_loop, NULL); + ecore_timer_add(0.5, __finalize_quit_ecore_loop, NULL); } SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Manager Finalize : pid(%d)", pid); @@ -1905,7 +1911,7 @@ int vcd_server_finalize(int pid) if (0 == vcd_client_get_ref_count()) { SLOG(LOG_DEBUG, TAG_VCD, "[Server] Connected client list is empty"); - ecore_timer_add(0, __finalize_quit_ecore_loop, NULL); + ecore_timer_add(0.5, __finalize_quit_ecore_loop, NULL); } SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Client Finalize : pid(%d)", pid); @@ -2218,7 +2224,7 @@ int vcd_server_widget_finalize(int pid) if (0 == vcd_client_get_ref_count()) { SLOG(LOG_ERROR, TAG_VCD, "[Server] connected client list is empty"); - ecore_timer_add(0, __finalize_quit_ecore_loop, NULL); + ecore_timer_add(0.5, __finalize_quit_ecore_loop, NULL); return 0; } diff --git a/server/vcd_server.h b/server/vcd_server.h index b328a7e..6df0154 100644 --- a/server/vcd_server.h +++ b/server/vcd_server.h @@ -32,7 +32,7 @@ extern "C" { */ int vcd_initialize(vce_request_callback_s *callback); -void vcd_finalize(); +bool vcd_finalize(); Eina_Bool vcd_cleanup_client_all(void *data); -- 2.7.4 From 07c58373ab34e4992c76f5575737a082af12326a Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Thu, 8 Feb 2018 14:14:13 +0900 Subject: [PATCH 12/16] Fix typo in log Change-Id: I75166ed67d73e2a7cc3d3351adc985a85630697f Signed-off-by: Jihoon Kim --- server/vcd_dbus.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c index 325aaf3..a60006a 100755 --- a/server/vcd_dbus.c +++ b/server/vcd_dbus.c @@ -502,7 +502,7 @@ int vcdc_send_service_state(vcd_state_e state) SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); return VCD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_VCD, "@@ Send serive state message to manager : state(%d)", state); + SLOG(LOG_DEBUG, TAG_VCD, "@@ Send service state message to manager : state(%d)", state); dbus_connection_flush(g_conn_sender); } @@ -527,7 +527,7 @@ int vcdc_send_service_state(vcd_state_e state) SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); return VCD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_VCD, "@@ Send serive state message to client : state(%d)", state); + SLOG(LOG_DEBUG, TAG_VCD, "@@ Send service state message to client : state(%d)", state); dbus_connection_flush(g_conn_sender); } @@ -552,7 +552,7 @@ int vcdc_send_service_state(vcd_state_e state) SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); return VCD_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, TAG_VCD, "@@ Send serive state message to widget client : state(%d)", state); + SLOG(LOG_DEBUG, TAG_VCD, "@@ Send service state message to widget client : state(%d)", state); dbus_connection_flush(g_conn_sender); } -- 2.7.4 From d663fe04dceec46a9b1893a813eab766535d1917 Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Mon, 19 Feb 2018 11:43:12 +0900 Subject: [PATCH 13/16] Fix memory leak when engine is not found Change-Id: I3bb6c64cb76eb6a646c2ad747e50937921b35e4f Signed-off-by: Wonnam Jang --- common/vc_config_mgr.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/vc_config_mgr.c b/common/vc_config_mgr.c index 77bd3a2..296e88a 100755 --- a/common/vc_config_mgr.c +++ b/common/vc_config_mgr.c @@ -602,6 +602,7 @@ int vc_config_mgr_initialize(int uid) if (0 != __vc_config_mgr_check_engine_is_valid(g_config_info->engine_id)) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to get default engine"); + vc_parser_unload_config(g_config_info); pthread_mutex_unlock(&vc_config_mgr_mutex); return VC_CONFIG_ERROR_ENGINE_NOT_FOUND; } @@ -615,6 +616,7 @@ int vc_config_mgr_initialize(int uid) char* tmp_language; if (0 != __vc_config_mgr_select_lang(g_config_info->engine_id, &tmp_language)) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to select language"); + vc_parser_unload_config(g_config_info); pthread_mutex_unlock(&vc_config_mgr_mutex); return -1; } @@ -628,6 +630,7 @@ int vc_config_mgr_initialize(int uid) if (0 != vc_parser_set_language(tmp_language)) { free(tmp_language); SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save config"); + vc_parser_unload_config(g_config_info); pthread_mutex_unlock(&vc_config_mgr_mutex); return -1; } @@ -652,6 +655,7 @@ int vc_config_mgr_initialize(int uid) temp_client = (vc_config_client_s*)calloc(1, sizeof(vc_config_client_s)); if (NULL == temp_client) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to allocate memory"); + vc_parser_unload_config(g_config_info); pthread_mutex_unlock(&vc_config_mgr_mutex); return VC_ERROR_OUT_OF_MEMORY; } -- 2.7.4 From 6e35a7628707b49ded839c966a15247bf524736e Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Fri, 23 Feb 2018 07:03:30 +0000 Subject: [PATCH 14/16] Revert "Fixed logic for stt unprepare" This reverts commit e5aa26e2ab9eb8fc4bbff513a5d2af93c865433b. Change-Id: I9b3ad6918c8db94babc641d003da84456de91b6a --- server/vcd_engine_agent.c | 8 ++------ server/vcd_recorder.c | 4 +--- server/vcd_server.c | 22 ++++++++-------------- server/vcd_server.h | 2 +- 4 files changed, 12 insertions(+), 24 deletions(-) diff --git a/server/vcd_engine_agent.c b/server/vcd_engine_agent.c index 28748fd..1f4c585 100644 --- a/server/vcd_engine_agent.c +++ b/server/vcd_engine_agent.c @@ -120,10 +120,7 @@ int vcd_engine_agent_release() } /* unload current engine */ - if (0 != vcd_engine_agent_unload_current_engine()) { - SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to deinitialize"); - return VCD_ERROR_OPERATION_FAILED; - } + vcd_engine_agent_unload_current_engine(); /* release current engine data */ if (NULL != g_dynamic_engine.callbacks) { @@ -301,13 +298,12 @@ int vcd_engine_agent_unload_current_engine() ret = g_dynamic_engine.callbacks->deinitialize(); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent ERROR] Fail to deinitialize"); - return VCD_ERROR_OPERATION_FAILED; } /* reset current engine data */ g_dynamic_engine.is_loaded = false; - return VCD_ERROR_NONE; + return 0; } diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index eea8f50..f3194d4 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -483,9 +483,7 @@ int vcd_recorder_destroy() if (0 != ret) SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to destroy stream info, ret(%d)", ret); - ret = audio_in_destroy(g_audio_h); - if (0 != ret) - SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to audio in destroy, ret(%d)", ret); + audio_in_destroy(g_audio_h); #ifdef TV_BT_MODE bt_hid_unset_audio_data_receive_cb(); diff --git a/server/vcd_server.c b/server/vcd_server.c index 9c28722..6cbc2b9 100755 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1029,7 +1029,7 @@ int vcd_initialize(vce_request_callback_s *callback) return 0; } -bool vcd_finalize() +void vcd_finalize() { GList *iter = NULL; if (0 < g_list_length(g_proc_list)) { @@ -1054,14 +1054,12 @@ bool vcd_finalize() } if (0 != vcd_recorder_destroy()) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to destroy recorder"); - return false; } else { SLOG(LOG_DEBUG, TAG_VCD, "[Server] destroy recorder"); } if (0 != vcd_engine_agent_release()) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to release engine"); - return false; } else { SLOG(LOG_DEBUG, TAG_VCD, "[Server] release engine"); } @@ -1073,18 +1071,14 @@ bool vcd_finalize() SLOG(LOG_DEBUG, TAG_VCD, "[Server] mode finalize"); - return true; + return; } static Eina_Bool __finalize_quit_ecore_loop(void *data) { - bool ret = vcd_finalize(); - if (false == ret) { - return EINA_TRUE; - } else { - ecore_main_loop_quit(); - return EINA_FALSE; - } + SLOG(LOG_ERROR, TAG_VCD, "[Server] quit ecore main loop"); + ecore_main_loop_quit(); + return EINA_FALSE; } static void __read_proc() @@ -1357,7 +1351,7 @@ int vcd_server_mgr_finalize(int pid) if (0 == vcd_client_get_ref_count()) { SLOG(LOG_DEBUG, TAG_VCD, "[Server] Connected client list is empty"); - ecore_timer_add(0.5, __finalize_quit_ecore_loop, NULL); + ecore_timer_add(0, __finalize_quit_ecore_loop, NULL); } SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Manager Finalize : pid(%d)", pid); @@ -1911,7 +1905,7 @@ int vcd_server_finalize(int pid) if (0 == vcd_client_get_ref_count()) { SLOG(LOG_DEBUG, TAG_VCD, "[Server] Connected client list is empty"); - ecore_timer_add(0.5, __finalize_quit_ecore_loop, NULL); + ecore_timer_add(0, __finalize_quit_ecore_loop, NULL); } SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Client Finalize : pid(%d)", pid); @@ -2224,7 +2218,7 @@ int vcd_server_widget_finalize(int pid) if (0 == vcd_client_get_ref_count()) { SLOG(LOG_ERROR, TAG_VCD, "[Server] connected client list is empty"); - ecore_timer_add(0.5, __finalize_quit_ecore_loop, NULL); + ecore_timer_add(0, __finalize_quit_ecore_loop, NULL); return 0; } diff --git a/server/vcd_server.h b/server/vcd_server.h index 6df0154..b328a7e 100644 --- a/server/vcd_server.h +++ b/server/vcd_server.h @@ -32,7 +32,7 @@ extern "C" { */ int vcd_initialize(vce_request_callback_s *callback); -bool vcd_finalize(); +void vcd_finalize(); Eina_Bool vcd_cleanup_client_all(void *data); -- 2.7.4 From 978089d3660047ebcca2be26f39d8c5e2bfba5d3 Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Wed, 17 Jan 2018 19:41:29 +0900 Subject: [PATCH 15/16] Send error signal to manager client when widget doesn't start recording Change-Id: Id9adae3e2a86f5eb8f7433a103c586bce0d05270 Signed-off-by: Wonnam Jang (cherry picked from commit 58d8c3f96d0da340dd31c9f7ecb76e82a5c6c6c1) --- server/vcd_client_data.c | 4 ++-- server/vcd_server.c | 54 +++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/server/vcd_client_data.c b/server/vcd_client_data.c index c18b8b2..358ddb7 100644 --- a/server/vcd_client_data.c +++ b/server/vcd_client_data.c @@ -1413,7 +1413,7 @@ int vcd_client_widget_set_waiting_for_recording(int pid, bool waiting) g_is_waiting_recording = waiting; g_waiting_recording_pid = pid; - SLOG(LOG_INFO, TAG_VCD, "[INFO] Success to set waiting for recording, pid(%d), waiting(%d)", pid, waiting); + SLOG(LOG_ERROR, TAG_VCD, "[INFO] Success to set waiting for recording, pid(%d), waiting(%d)", pid, waiting); return 0; } @@ -1425,7 +1425,7 @@ int vcd_client_widget_get_waiting_for_recording(int pid, bool* waiting) } *waiting = g_is_waiting_recording; - SLOG(LOG_INFO, TAG_VCD, "[INFO] Success to get waiting for recording, waiting(%d)", *waiting); + SLOG(LOG_ERROR, TAG_VCD, "[INFO] Success to get waiting for recording, waiting(%d)", *waiting); return 0; } diff --git a/server/vcd_server.c b/server/vcd_server.c index 65fb25b..ecdd61c 100755 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -39,6 +39,7 @@ static GList *g_proc_list = NULL; static Ecore_Timer *g_restart_timer = NULL; +static Ecore_Timer *g_check_widget_client_timer = NULL; /** * @brief Enumerations of send event type. @@ -1465,10 +1466,45 @@ int vcd_server_mgr_set_client_info(int pid) return VCD_ERROR_NONE; } +static int __reset_waiting_for_widget_recording(void) +{ + SLOG(LOG_ERROR, TAG_VCD, "[Server] Reet waiting for widget recording"); + // Delete timer to check that widget client is terminated + if (g_check_widget_client_timer) { + ecore_timer_del(g_check_widget_client_timer); + g_check_widget_client_timer = NULL; + } + // Reset flag to wait for recording from widget client + vcd_client_widget_set_waiting_for_recording(-1, false); + return 0; +} + +static Eina_Bool __send_waiting_timeout_error_to_manager(void* data) +{ + SLOG(LOG_ERROR, TAG_VCD, "Widget client didn't send to start recording, pid(%d)", (int)data); + __reset_waiting_for_widget_recording(); + + vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "voice_engine.error.proc_fail"); + return EINA_FALSE; +} + +static int __set_waiting_for_widget_recording(int pid) +{ + SLOG(LOG_ERROR, TAG_VCD, "[Server] Set waiting for widget recording, pid(%d)", pid); + + // Check if the app included widget client is terminated or not. If it is terminated, vcd_server_widget_finalize() function will be called + // In that function, it will start recording + g_check_widget_client_timer = ecore_timer_add(2.0, __send_waiting_timeout_error_to_manager, (void*)pid); + + // Set flag to wait for recording from widget client + vcd_client_widget_set_waiting_for_recording(pid, true); + return 0; +} + static int __start_internal_recognition() { int ret; - vcd_client_widget_set_waiting_for_recording(-1, false); + __reset_waiting_for_widget_recording(); if (0 != vcd_client_command_collect_command()) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to collect command"); @@ -1558,7 +1594,7 @@ int vcd_server_mgr_start(vcd_recognition_mode_e recognition_mode, bool exclusive SLOG(LOG_DEBUG, TAG_VCD, "[Server] Manager is NOT available."); return VCD_ERROR_OPERATION_FAILED; } - vcd_client_widget_set_waiting_for_recording(-1, false); + __reset_waiting_for_widget_recording(); SLOG(LOG_ERROR, TAG_VCD, "[Server] set recognition mode = %d", recognition_mode); vcd_client_set_recognition_mode(recognition_mode); @@ -1571,7 +1607,8 @@ int vcd_server_mgr_start(vcd_recognition_mode_e recognition_mode, bool exclusive if (-1 != pid) { SLOG(LOG_ERROR, TAG_VCD, "[Server] Request tooltip show and widget command"); ecore_timer_add(0, __vcd_request_show_tooltip, (void*)true); - vcd_client_widget_set_waiting_for_recording(pid, true); + + __set_waiting_for_widget_recording(pid); return 0; } } @@ -2208,10 +2245,11 @@ int vcd_server_widget_initialize(int pid) static void __vcd_server_widget_start_recording(void *data) { + SLOG(LOG_ERROR, TAG_VCD, "[Server INFO] start recording"); + if (0 != __start_internal_recognition()) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to start recongition"); } - vcd_client_widget_set_waiting_for_recording(-1, false); } int vcd_server_widget_finalize(int pid) @@ -2239,7 +2277,7 @@ int vcd_server_widget_finalize(int pid) } if (true == is_waiting) { - SLOG(LOG_INFO, TAG_VCD, "[Server INFO] invoke to start recording"); + SLOG(LOG_ERROR, TAG_VCD, "[Server INFO] invoke to start recording"); ecore_main_loop_thread_safe_call_async(__vcd_server_widget_start_recording, NULL); } return VCD_ERROR_NONE; @@ -2253,6 +2291,12 @@ int vcd_server_widget_start_recording(int pid, bool widget_command) return VCD_ERROR_INVALID_PARAMETER; } + bool waiting; + if (0 != vcd_client_widget_get_waiting_for_recording(pid, &waiting) || false == waiting) { + SLOG(LOG_ERROR, TAG_VCD, "[Server] Server is not waiting for recording, pid(%d), waiting(%d)", pid, waiting); + return 0; + } + if (true == widget_command) { vcd_client_widget_set_command(pid); SLOG(LOG_DEBUG, TAG_VCD, "[Server] widget command is available"); -- 2.7.4 From 3d18b21c01b9a1158645f76895e4259e98a4d977 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Mon, 22 Jan 2018 20:35:42 +0900 Subject: [PATCH 16/16] Move adding match rule code Change-Id: I56713583b07392fbdcb5926f0a805c21a4fd736e Signed-off-by: Suyeon Hwang (cherry picked from commit 4890129b35545db17e2ebf5e84490d8248a21e09) --- client/vc.c | 7 +++++-- client/vc_dbus.c | 28 ++++++++++++++-------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/client/vc.c b/client/vc.c index da52879..9cfc04b 100644 --- a/client/vc.c +++ b/client/vc.c @@ -1631,8 +1631,11 @@ int __vc_cb_error(int reason, int daemon_pid, char* msg) /* check state */ if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] not connected client yet"); - return -1; + if (VC_ERROR_SERVICE_RESET != reason) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] not connected client yet"); + return -1; + } + return 0; } if (VC_ERROR_SERVICE_RESET == reason) { diff --git a/client/vc_dbus.c b/client/vc_dbus.c index c8d3937..7bc8cef 100644 --- a/client/vc_dbus.c +++ b/client/vc_dbus.c @@ -272,8 +272,8 @@ int vc_dbus_open_connection() return 0; } - char rule[128] = {0, }; - snprintf(rule, 128, "type='signal',interface='%s'", VC_CLIENT_SERVICE_INTERFACE); + char rule[256] = {0, }; + snprintf(rule, 256, "type='signal',interface='%s'", VC_CLIENT_SERVICE_INTERFACE); /* add a rule for which messages we want to see */ dbus_bus_add_match(g_conn_listener, rule, &err); @@ -286,6 +286,18 @@ int vc_dbus_open_connection() return VC_ERROR_OPERATION_FAILED; } + /* add a rule for daemon error */ + snprintf(rule, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); + dbus_bus_add_match(g_conn_listener, rule, &err); + dbus_connection_flush(g_conn_listener); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCC, "Match Error (%s)", err.message); + dbus_error_free(&err); + __vc_dbus_connection_free(); + return VC_ERROR_OPERATION_FAILED; + } + int fd = 0; if (1 != dbus_connection_get_unix_fd(g_conn_listener, &fd)) { SLOG(LOG_ERROR, TAG_VCC, "fail to get fd from dbus "); @@ -485,18 +497,6 @@ int vc_dbus_request_initialize(int pid, int* mgr_pid, int* service_state, int* d *service_state = tmp_service_state; *daemon_pid = tmp_daemon_pid; - /* add a rule for daemon error */ - char rule_err[256] = {0, }; - snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); - dbus_bus_add_match(g_conn_listener, rule_err, &err); - dbus_connection_flush(g_conn_listener); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "Match Error (%s)", err.message); - dbus_error_free(&err); - return VC_ERROR_OPERATION_FAILED; - } - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc initialize : result = %d mgr = %d service = %d daemon_pid = %d", result, *mgr_pid, *service_state, *daemon_pid); } else { SLOG(LOG_ERROR, TAG_VCC, "@@ vc initialize : result = %d", result); -- 2.7.4