From ed211d4d6269fe852e8b0d8e2de5aa0439f217eb Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Tue, 18 Jul 2023 17:54:13 +0900 Subject: [PATCH 01/16] Fix typo in function and variable names Change-Id: I7a1c67d688c0903064ccb539e72477a4205b9b04 Signed-off-by: Suyeon Hwang --- tests/src/vc_common_test_util.cpp | 8 ++++---- tests/src/vc_common_test_util.h | 2 +- tests/src/vc_mgr_test_util.cpp | 20 ++++++++++---------- tests/src/vc_mgr_test_util.h | 2 +- tests/src/vc_test_util.cpp | 16 ++++++++-------- tests/src/vc_test_util.h | 2 +- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/src/vc_common_test_util.cpp b/tests/src/vc_common_test_util.cpp index a230eba..4ab7867 100644 --- a/tests/src/vc_common_test_util.cpp +++ b/tests/src/vc_common_test_util.cpp @@ -104,7 +104,7 @@ void VcCommonTestUtility::WaitUntilEngineTerminated(int duration) return !is_running; }; - WaitCondtion(engineChcker, duration); + WaitCondition(engineChcker, duration); } bool VcCommonTestUtility::IsVcFeatureSupported() @@ -161,7 +161,7 @@ void VcCommonTestUtility::EnableAutoLanguageSelection() vc_setting_deinitialize(); } -bool VcCommonTestUtility::WaitCondtion(std::function checker, int duration) +bool VcCommonTestUtility::WaitCondition(std::function checker, int duration) { auto mainLoopQuitTimer = ecore_timer_add(static_cast(duration), [](void *data) -> Eina_Bool { ecore_main_loop_quit(); @@ -169,8 +169,8 @@ bool VcCommonTestUtility::WaitCondtion(std::function checker, int du }, nullptr); auto checkerTimer = ecore_timer_add(0.0, [](void *data) -> Eina_Bool { - auto &checker = *reinterpret_cast *>(data); - if (false == checker()) { + auto &IsConditionSatisfied = *reinterpret_cast *>(data); + if (false == IsConditionSatisfied()) { return EINA_TRUE; } diff --git a/tests/src/vc_common_test_util.h b/tests/src/vc_common_test_util.h index c37c1ac..70fac59 100644 --- a/tests/src/vc_common_test_util.h +++ b/tests/src/vc_common_test_util.h @@ -39,7 +39,7 @@ public: static void SetCurrentLanguage(const char *language); static void EnableAutoLanguageSelection(); - static bool WaitCondtion(std::function checker, int duration); + static bool WaitCondition(std::function checker, int duration); }; diff --git a/tests/src/vc_mgr_test_util.cpp b/tests/src/vc_mgr_test_util.cpp index db17219..009f342 100644 --- a/tests/src/vc_mgr_test_util.cpp +++ b/tests/src/vc_mgr_test_util.cpp @@ -28,7 +28,7 @@ VcMgrTestUtility::VcMgrTestUtility() mCurrentServiceState = VC_SERVICE_STATE_NONE; mDefaultCommandList = nullptr; - mErrorOccured = false; + mErrorOccurred = false; mGetErrorMessageReturn = VC_ERROR_OPERATION_FAILED; mAllResultReceived = false; mSetSelectedResultReturn = VC_ERROR_OPERATION_FAILED; @@ -72,7 +72,7 @@ void VcMgrTestUtility::ServiceStateChangedCallback(vc_service_state_e previous, void VcMgrTestUtility::ErrorCallback(vc_error_e reason, void *user_data) { auto instance = reinterpret_cast(user_data); - instance->mErrorOccured = true; + instance->mErrorOccurred = true; char *error = nullptr; instance->mGetErrorMessageReturn = vc_mgr_get_error_message(&error); @@ -165,7 +165,7 @@ bool VcMgrTestUtility::IsStateChanged(vc_state_e targetState, int duration) return target == instance->mCurrentState; }, this, targetState); - return VcCommonTestUtility::WaitCondtion(stateChecker, duration); + return VcCommonTestUtility::WaitCondition(stateChecker, duration); } bool VcMgrTestUtility::IsServiceStateChanged(vc_service_state_e targetState, int duration) @@ -174,16 +174,16 @@ bool VcMgrTestUtility::IsServiceStateChanged(vc_service_state_e targetState, int return target == instance->mCurrentServiceState; }, this, targetState); - return VcCommonTestUtility::WaitCondtion(serviceStateChecker, duration); + return VcCommonTestUtility::WaitCondition(serviceStateChecker, duration); } bool VcMgrTestUtility::IsErrorOccurring(int duration) { auto errorChecker = std::bind([](VcMgrTestUtility *instance) { - return instance->mErrorOccured; + return instance->mErrorOccurred; }, this); - return VcCommonTestUtility::WaitCondtion(errorChecker, duration); + return VcCommonTestUtility::WaitCondition(errorChecker, duration); } bool VcMgrTestUtility::IsAllResultReceived(int duration) @@ -192,7 +192,7 @@ bool VcMgrTestUtility::IsAllResultReceived(int duration) return instance->mAllResultReceived; }, this); - return VcCommonTestUtility::WaitCondtion(resultChecker, duration); + return VcCommonTestUtility::WaitCondition(resultChecker, duration); } bool VcMgrTestUtility::IsResultReceived(int duration) @@ -201,7 +201,7 @@ bool VcMgrTestUtility::IsResultReceived(int duration) return instance->mResultReceived; }, this); - return VcCommonTestUtility::WaitCondtion(resultChecker, duration); + return VcCommonTestUtility::WaitCondition(resultChecker, duration); } bool VcMgrTestUtility::IsSpeechDetected(int duration) @@ -210,7 +210,7 @@ bool VcMgrTestUtility::IsSpeechDetected(int duration) return instance->mSpeechDetected; }, this); - return VcCommonTestUtility::WaitCondtion(resultChecker, duration); + return VcCommonTestUtility::WaitCondition(resultChecker, duration); } bool VcMgrTestUtility::IsLanguageChanged(int duration) @@ -219,7 +219,7 @@ bool VcMgrTestUtility::IsLanguageChanged(int duration) return instance->mLanguageChanged; }, this); - return VcCommonTestUtility::WaitCondtion(resultChecker, duration); + return VcCommonTestUtility::WaitCondition(resultChecker, duration); } bool VcMgrTestUtility::Prepare() diff --git a/tests/src/vc_mgr_test_util.h b/tests/src/vc_mgr_test_util.h index c0db4ad..5dc2267 100644 --- a/tests/src/vc_mgr_test_util.h +++ b/tests/src/vc_mgr_test_util.h @@ -66,7 +66,7 @@ public: vc_service_state_e mCurrentServiceState; vc_cmd_list_h mDefaultCommandList; - bool mErrorOccured; + bool mErrorOccurred; int mGetErrorMessageReturn; bool mAllResultReceived; int mSetSelectedResultReturn; diff --git a/tests/src/vc_test_util.cpp b/tests/src/vc_test_util.cpp index b150f73..ed836b5 100644 --- a/tests/src/vc_test_util.cpp +++ b/tests/src/vc_test_util.cpp @@ -25,7 +25,7 @@ VcTestUtility::VcTestUtility() { mCurrentState = VC_STATE_NONE; mCurrentServiceState = VC_SERVICE_STATE_NONE; - mErrorOccured = false; + mErrorOccurred = false; mResultReceived = false; mLanguageChanged = false; @@ -60,7 +60,7 @@ void VcTestUtility::ServiceStateChangedCallback(vc_service_state_e previous, vc_ void VcTestUtility::ErrorCallback(vc_error_e reason, void *user_data) { auto instance = reinterpret_cast(user_data); - instance->mErrorOccured = true; + instance->mErrorOccurred = true; } void VcTestUtility::ResultCallback(vc_result_event_e event, vc_cmd_list_h vc_cmd_list, const char* result, void *user_data) @@ -99,7 +99,7 @@ bool VcTestUtility::IsStateChanged(vc_state_e targetState, int duration) return target == instance->mCurrentState; }, this, targetState); - return VcCommonTestUtility::WaitCondtion(stateChecker, duration); + return VcCommonTestUtility::WaitCondition(stateChecker, duration); } bool VcTestUtility::IsServiceStateChanged(vc_service_state_e targetState, int duration) @@ -108,16 +108,16 @@ bool VcTestUtility::IsServiceStateChanged(vc_service_state_e targetState, int du return target == instance->mCurrentServiceState; }, this, targetState); - return VcCommonTestUtility::WaitCondtion(serviceStateChecker, duration); + return VcCommonTestUtility::WaitCondition(serviceStateChecker, duration); } bool VcTestUtility::IsErrorOccurring(int duration) { auto errorChecker = std::bind([](VcTestUtility *instance) { - return instance->mErrorOccured; + return instance->mErrorOccurred; }, this); - return VcCommonTestUtility::WaitCondtion(errorChecker, duration); + return VcCommonTestUtility::WaitCondition(errorChecker, duration); } bool VcTestUtility::IsResultReceived(int duration) @@ -126,7 +126,7 @@ bool VcTestUtility::IsResultReceived(int duration) return instance->mResultReceived; }, this); - return VcCommonTestUtility::WaitCondtion(resultChecker, duration); + return VcCommonTestUtility::WaitCondition(resultChecker, duration); } bool VcTestUtility::IsLanguageChanged(int duration) @@ -135,7 +135,7 @@ bool VcTestUtility::IsLanguageChanged(int duration) return instance->mLanguageChanged; }, this); - return VcCommonTestUtility::WaitCondtion(resultChecker, duration); + return VcCommonTestUtility::WaitCondition(resultChecker, duration); } bool VcTestUtility::Prepare() diff --git a/tests/src/vc_test_util.h b/tests/src/vc_test_util.h index 4de8dc8..7ca3e5f 100644 --- a/tests/src/vc_test_util.h +++ b/tests/src/vc_test_util.h @@ -51,7 +51,7 @@ public: vc_state_e mCurrentState; vc_service_state_e mCurrentServiceState; - bool mErrorOccured; + bool mErrorOccurred; bool mResultReceived; bool mLanguageChanged; -- 2.7.4 From c48f4b2c52de7f8e34af4baa657aee8e3c7f7987 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Thu, 3 Aug 2023 11:10:37 +0900 Subject: [PATCH 02/16] Update version (1.80.2) Change-Id: I4525a0a5222338f3e15717559a0c4a4da1611fb7 Signed-off-by: Suyeon Hwang --- packaging/voice-control.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index ff9c2fb..0cf4dbf 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -1,6 +1,6 @@ Name: voice-control Summary: Voice control client library and daemon -Version: 1.80.1 +Version: 1.80.2 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Apache-2.0 -- 2.7.4 From ae4e8885a5d8a5b3e372092eb5b40349c7cee250 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Mon, 28 Aug 2023 20:23:39 +0900 Subject: [PATCH 03/16] Connect to widget client from server by on-demand - Issue: By the change of IPC to TIDL, app can receive unknown app launch request. - Solution: This patch postpones the server-to-client connection. TIDL does not support bi-directional call, so voice control widget client has stub implementation for receiving some special message from the server. However, this implementation causes unknown app launch requests for connection. Through this change, server will not connect to client immediately when the client requests to connect. It will try to connect when it actually needs to send some message to client. Change-Id: Ie3f13e0a58d80a973715c4c86e71ffa14722de3e Signed-off-by: Suyeon Hwang --- server/vcd_tidl.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index bef79d8..22dcb6f 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -108,14 +108,18 @@ static void __request_tidl_connect(vcd_client_type_e type, int pid) return; } - if (widget_tidl_info->connection_requesting) { + if (widget_tidl_info->connected) { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] widget is already connected"); return; } - ret = rpc_port_proxy_vcd_widget_proxy_vcd_widget_connect(widget_tidl_info->rpc_h); + if (widget_tidl_info->connection_requesting) { + return; + } + ret = rpc_port_proxy_vcd_widget_proxy_vcd_widget_connect_sync(widget_tidl_info->rpc_h); if (0 == ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); widget_tidl_info->connection_requesting = true; } type_str = "widget"; @@ -1541,8 +1545,6 @@ static void __vc_widget_register_cb_cb(rpc_port_stub_vcd_widget_stub_vc_widget_ pthread_mutex_unlock(&g_widget_tidl_info_mutex); - __request_tidl_connect(VCD_CLIENT_TYPE_WIDGET, pid); - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC WIDGET REGISTER CALLBACK DONE"); } @@ -2722,12 +2724,14 @@ int vcdc_send_asr_result(int pid, int event, const char* asr_result, int cmd_typ SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Send asr result"); widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info(pid); - if (NULL == widget_tidl_info) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get tidl info"); return VC_ERROR_OPERATION_FAILED; } + // FIXME: This is temproray fix for avoiding app launch in client side. + __request_tidl_connect(VCD_CLIENT_TYPE_WIDGET, pid); + if (!widget_tidl_info->connected) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Not Connected"); return VC_ERROR_OPERATION_FAILED; -- 2.7.4 From 94d67dea40ec3c25a46ae18a5d5ae8593d3bdcf7 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Wed, 6 Sep 2023 12:03:23 +0900 Subject: [PATCH 04/16] Update version (1.80.3) Change-Id: I13c7aa078b5985a1c0a0653899b7362d185f9b5e Signed-off-by: Suyeon Hwang --- packaging/voice-control.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 0cf4dbf..4d9a7cf 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -1,6 +1,6 @@ Name: voice-control Summary: Voice control client library and daemon -Version: 1.80.2 +Version: 1.80.3 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Apache-2.0 -- 2.7.4 From 3230e822a26d2f26a9b9d2524c1194248656cb71 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Tue, 7 Nov 2023 17:57:35 +0900 Subject: [PATCH 05/16] Except system volume from ducking - Requirement: In some uses cases, the system type audio stream should play. - Solution: This patch removes the code for ducking the system type volume. Through this change, voice control no longer reduces the system type volume. Change-Id: Ia1ec372b40301fbb8b683418943963d2266033be Signed-off-by: Suyeon Hwang --- client/vc_mgr_ducking.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/client/vc_mgr_ducking.cpp b/client/vc_mgr_ducking.cpp index bbec1d7..810997a 100644 --- a/client/vc_mgr_ducking.cpp +++ b/client/vc_mgr_ducking.cpp @@ -157,10 +157,6 @@ int vc_mgr_ducking_activate(double ratio) if (SOUND_MANAGER_ERROR_NONE != ret) return ret; - ret = activate_ducking_sound_stream(SOUND_STREAM_TYPE_SYSTEM, g_system_stream_h, ratio); - if (SOUND_MANAGER_ERROR_NONE != ret) - return ret; - ret = activate_ducking_sound_stream(SOUND_STREAM_TYPE_NOTIFICATION, g_notification_stream_h, ratio); if (SOUND_MANAGER_ERROR_NONE != ret) return ret; @@ -201,10 +197,6 @@ int vc_mgr_ducking_deactivate(void) if (SOUND_MANAGER_ERROR_NONE != ret) return ret; - ret = deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_SYSTEM, g_system_stream_h); - if (SOUND_MANAGER_ERROR_NONE != ret) - return ret; - ret = deactivate_ducking_sound_stream(SOUND_STREAM_TYPE_NOTIFICATION, g_notification_stream_h); if (SOUND_MANAGER_ERROR_NONE != ret) return ret; -- 2.7.4 From 4595061d714ad062ca890dd78b9c54275bdf5cb1 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Tue, 7 Nov 2023 18:00:57 +0900 Subject: [PATCH 06/16] Update version (1.80.4) Change-Id: Ia5a3bb7cd2edc9286b2ce726898aaffb1326331a Signed-off-by: Suyeon Hwang --- packaging/voice-control.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 4d9a7cf..4168fb4 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -1,6 +1,6 @@ Name: voice-control Summary: Voice control client library and daemon -Version: 1.80.3 +Version: 1.80.4 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Apache-2.0 -- 2.7.4 From b1a3e5227b6b66768248d79cfe67baff5ed614a9 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Wed, 6 Dec 2023 11:31:01 +0900 Subject: [PATCH 07/16] Update since_tizen in header files Change-Id: Ibff82d907547295702a0b1167ca29f58bbd4eba5 Signed-off-by: sooyeon --- client/vc.c | 2 +- common/vc_command.h | 4 +- include/vce.h | 130 ++++++++++++++++----------------- include/voice_control.h | 44 +++++------ include/voice_control_command.h | 40 +++++----- include/voice_control_command_expand.h | 6 +- include/voice_control_common.h | 20 ++--- include/voice_control_setting.h | 4 +- include/voice_control_widget.h | 2 +- 9 files changed, 126 insertions(+), 126 deletions(-) diff --git a/client/vc.c b/client/vc.c index 6695e1a..c514b81 100644 --- a/client/vc.c +++ b/client/vc.c @@ -1042,7 +1042,7 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) //LCOV_EXCL_START /** * @brief Checks whether the command format is supported. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif +* @since_tizen 2.4 * * @param[in] format The command format * @param[out] support The result status @c true = supported, @c false = not supported diff --git a/common/vc_command.h b/common/vc_command.h index b772774..4e2b583 100644 --- a/common/vc_command.h +++ b/common/vc_command.h @@ -62,7 +62,7 @@ typedef struct { /** * @brief Enumerations of command type. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif +* @since_tizen 2.4 */ typedef enum { VC_COMMAND_TYPE_NONE = 0, /**< No command position */ @@ -91,7 +91,7 @@ int vc_cmd_print_list(vc_cmd_list_h vc_cmd_list); /** * @brief Remove all commands from command list. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif +* @since_tizen 2.4 * * @param[in] vc_cmd_list The command list handle * @param[in] free_command The command free option @c true = release each commands in list, diff --git a/include/vce.h b/include/vce.h index 1f4036e..6f798b6 100644 --- a/include/vce.h +++ b/include/vce.h @@ -31,7 +31,7 @@ extern "C" { /** * @brief Enumerations of error codes. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 */ typedef enum { VCE_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ @@ -51,7 +51,7 @@ typedef enum { /** * @brief Enumerations of audio type. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 */ typedef enum { VCE_AUDIO_TYPE_PCM_S16_LE = 0, /**< Signed 16bit audio type, Little endian */ @@ -60,7 +60,7 @@ typedef enum { /** * @brief Enumerations of callback event. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 */ typedef enum { VCE_RESULT_EVENT_SUCCESS = 0, /**< Event when the recognition full result is ready */ @@ -70,7 +70,7 @@ typedef enum { /** * @brief Enumerations of command type. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 */ typedef enum { VCE_COMMAND_FORMAT_FIXED = 0, /**< Fixed command */ @@ -84,7 +84,7 @@ typedef enum { /** * @brief Enumerations of speech detect. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 */ typedef enum { VCE_SPEECH_DETECT_NONE = 0, /**< No event */ @@ -94,7 +94,7 @@ typedef enum { /** * @brief Enumerations of ASR result events. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 */ typedef enum { VCE_ASR_RESULT_EVENT_FINAL_RESULT = 0, /**< Event when the ASR result is last data or ASR result is only one result */ @@ -104,7 +104,7 @@ typedef enum { /** * @brief Enumerations of audio channels. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 */ typedef enum { VCE_AUDIO_CHANNEL_MONO = 0, /**< 1 channel, mono */ @@ -113,7 +113,7 @@ typedef enum { /** * @brief Enumeration for TTS feedback events. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 */ typedef enum { VCE_FEEDBACK_EVENT_FAIL = -1, /**< Failed */ @@ -124,74 +124,74 @@ typedef enum { /** * @brief A structure of handle for VC command. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 */ typedef struct vce_cmd_s* vce_cmd_h; /** * @brief Definition for foreground command type. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 */ #define VCE_COMMAND_TYPE_FOREGROUND 1 /** * @brief Definition for background command type. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 */ #define VCE_COMMAND_TYPE_BACKGROUND 2 /** * @brief Definition for widget command type. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 */ #define VCE_COMMAND_TYPE_WIDGET 3 /** * @brief Definition for system command type. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 */ #define VCE_COMMAND_TYPE_SYSTEM 4 /** * @brief Definition for system background command type. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 */ #define VCE_COMMAND_TYPE_SYSTEM_BACKGROUND 5 /** * @brief Definitions for exclusive command type. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 */ #define VCE_COMMAND_TYPE_EXCLUSIVE 6 /** * @brief Definition of bluetooth audio id. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 */ #define VCE_AUDIO_ID_BLUETOOTH "VC_AUDIO_ID_BLUETOOTH" /**< Bluetooth audio id */ /** * @brief Definition of Wi-Fi audio id. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 */ #define VCE_AUDIO_ID_WIFI "VC_AUDIO_ID_WIFI" /**< Wi-Fi audio id */ /** * @brief Definition for none message. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 */ #define VC_RESULT_MESSAGE_NONE "vc.result.message.none" /** * @brief Definition for failed recognition because the speech is too loud to listen. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 */ #define VC_RESULT_MESSAGE_ERROR_TOO_LOUD "vc.result.message.error.too.loud" /** * @brief Called when VC engine informs the engine service user about whole supported languages. * @details This callback function is implemented by the engine service user. Therefore, the engine developer does NOT have to implement this callback function. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks This callback function is called by vce_foreach_supported_languages_cb() to retrieve the whole supported language list. * The @a user_data must be transferred from vce_foreach_supported_languages_cb(). * The @a language can be used only in the callback. To use outside, make a copy. @@ -206,7 +206,7 @@ typedef bool (*vce_supported_language_cb)(const char* language, void* user_data) /** * @brief Called when the engine service user initializes Voice Control (VC) engine. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks This callback function is mandatory and must be registered using vce_main(). * @return 0 on success, otherwise a negative error value * @retval #VCE_ERROR_NONE Successful @@ -219,7 +219,7 @@ typedef int (*vce_initialize_cb)(void); /** * @brief Called when the engine service user deinitializes VC engine. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks This callback function is mandatory and must be registered using vce_main(). * @return 0 on success, otherwise a negative error value * @retval #VCE_ERROR_NONE Successful @@ -230,7 +230,7 @@ typedef int (*vce_deinitialize_cb)(void); /** * @brief Called when the engine service user requests the recording format of VC engine. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks This callback function is mandatory and must be registered using vce_main(). * The @a audio_id can be used only in the callback. To use outside, make a copy. * The @a types is managed by the platform and will be released when this callback function is completed. @@ -248,7 +248,7 @@ typedef int (*vce_get_recording_format_cb)(const char* audio_id, vce_audio_type_ /** * @brief Called when the engine service user retrieves all supported languages of VC engine. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks This callback function is mandatory and must be registered using vce_main(). * @param[in] callback a callback function * @param[in] user_data The user data to be passed to the callback function @@ -264,7 +264,7 @@ typedef int (*vce_foreach_supported_languages_cb)(vce_supported_language_cb call /** * @brief Called when the engine service user checks whether a language is supported or not. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks This callback function is mandatory and must be registered using vce_main(). * The @a language can be used only in the callback. To use outside, make a copy. * @param[in] language A language @@ -274,7 +274,7 @@ typedef bool (*vce_is_language_supported_cb)(const char* language); /** * @brief Called when the engine service user sets language. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks The @a language can be used only in the callback. To use outside, make a copy. * @param[in] language A language. * @return 0 on success, otherwise a negative error value @@ -287,7 +287,7 @@ typedef int (*vce_set_language_cb)(const char* language); /** * @brief Called when the engine service user sets command list before recognition. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks This function should set commands via vcd_foreach_command(). * The @a vc_command should not be released. * The @a vc_command can be used only in the callback. To use outside, make a copy. @@ -308,7 +308,7 @@ typedef int (*vce_set_commands_cb)(vce_cmd_h vc_command); /** * @brief Called when the engine service user unsets command list for reset. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @return 0 on success, otherwise a negative error value * @retval #VCE_ERROR_NONE Successful * @retval #VCE_ERROR_INVALID_PARAMETER Invalid parameter @@ -321,7 +321,7 @@ typedef int (*vce_unset_commands_cb)(void); /** * @brief Called when the engine service user starts recognition. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks This callback function is mandatory and must be registered using vce_main(). * @param[in] stop_by_silence Silence detection option. * @c true to detect the silence, @@ -342,7 +342,7 @@ typedef int (*vce_start_cb)(bool stop_by_silence); /** * @brief Called when the engine service user sets recording data for speech recognition from recorder. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks This function should be returned immediately after recording data copy. * The @a data can be used only in the callback. To use outside, make a copy. * The @a speech_detected should not be released. This is managed by the platform. @@ -363,7 +363,7 @@ typedef int(*vce_set_recording_data_cb)(const void* data, unsigned int length, v /** * @brief Called when the engine service user stops to get the result of recognition. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @return 0 on success, otherwise a negative error value * @retval #VCE_ERROR_NONE Successful * @retval #VCE_ERROR_INVALID_STATE Invalid state @@ -379,7 +379,7 @@ typedef int (*vce_stop_cb)(void); /** * @brief Called when the engine service user cancels the recognition process. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @return 0 on success, otherwise a negative error value. * @retval #VCE_ERROR_NONE Successful. * @retval #VCE_ERROR_INVALID_STATE Invalid state. @@ -391,7 +391,7 @@ typedef int (*vce_cancel_cb)(void); /** * @brief Called when the engine service user sets audio recording type. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks The @a audio_type can be used only in the callback. To use outside, make a copy. * @param[in] audio_type Current audio type (e.g. #VCE_AUDIO_ID_BLUETOOTH or #VCE_AUDIO_ID_WIFI) * @return 0 on success, otherwise a negative error value. @@ -402,7 +402,7 @@ typedef int (*vce_set_audio_type_cb)(const char* audio_type); /** * @brief Called when the engine service user sets app id which is want to ask server dialog. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks The @a app_id and @a credential can be used only in the callback. To use outside, make a copy. * @param[in] app_id App id which is to want to ask server dialog. * @param[in] credential Credential key. @@ -415,7 +415,7 @@ typedef int (*vce_set_server_dialog_cb)(const char* app_id, const char* credenti /** * @brief Called when the engine service user sets domain (agent or device type). - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks The @a domain can be used only in the callback. To use outside, make a copy. * @param[in] domain Agent (e.g. "music", "news", etc) or device type (e.g. "tv", "mobile", etc) corresponding to the command * @return 0 on success, otherwise a negative error value. @@ -426,7 +426,7 @@ typedef int (*vce_set_domain_cb)(const char* domain); /** * @brief Called when the engine service user requests essential value from NLU result. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks The @a key can be used only in the callback. To use outside, make a copy. * The @a value is managed by the platform and will be released when this callback function is completed. * @param[in] key NLU base info key. @@ -439,7 +439,7 @@ typedef int (*vce_nlu_base_info_requested_cb)(const char* key, char** value); /** * @brief Called when client gets the specific engine's request from the engine service user. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks The @a engine_app_id is managed by the platform and will be released when this callback function is completed. * The @a event is managed by the platform and will be released when this callback function is completed. * The @a request is managed by the platform and will be released when this callback function is completed. @@ -462,7 +462,7 @@ typedef int (*vce_specific_engine_request_cb)(const char* engine_app_id, const c /** * @brief Called when the engine service user sets private data between app and engine. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks The @a key, @a data can be used only in the callback. To use outside, make a copy. * @param[in] key Private key. * @param[in] data Private data. @@ -474,7 +474,7 @@ typedef int (*vce_private_data_set_cb)(const char* key, const char* data); /** * @brief Called when the engine service user requests private data between app and engine. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks The @a key can be used only in the callback. To use outside, make a copy. * The @a data is managed by the platform and will be released when this callback function is completed. * @param[in] key Private key. @@ -487,7 +487,7 @@ typedef int (*vce_private_data_requested_cb)(const char* key, char** data); /** * @brief Called when the engine service user requests process text. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks The @a text can be used only in the callback. To use outside, make a copy. * @param[in] text Requested text * @return 0 on success, otherwise a negative error value. @@ -498,7 +498,7 @@ typedef int (*vce_process_text_cb)(const char* text); /** * @brief Called when the engine service user requests list event. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks The @a event can be used only in the callback. To use outside, make a copy. * @param[in] event Requested list event * @return 0 on success, otherwise a negative error value. @@ -509,7 +509,7 @@ typedef int (*vce_process_list_event_cb)(const char* event); /** * @brief Called when the engine service user requests haptic event. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks The @a event can be used only in the callback. To use outside, make a copy. * @param[in] event Requested haptic event * @return 0 on success, otherwise a negative error value. @@ -520,7 +520,7 @@ typedef int (*vce_process_haptic_event_cb)(const char* event); /** * @brief Called when the engine service user requests the base information of VC engine. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks This callback function is mandatory and must be registered using vce_main(). * The @a engine_uuid is managed by the platform and will be released when this callback function is completed. * The @a engine_name is managed by the platform and will be released when this callback function is completed. @@ -542,7 +542,7 @@ typedef int (*vce_get_info_cb)(char** engine_uuid, char** engine_name, char** en /** * @brief Called to retrieve the commands. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks The @a command, @a param can be used only in the callback. To use outside, make a copy. * @param[in] id command id * @param[in] type command type @@ -627,7 +627,7 @@ typedef int (*vce_tts_audio_format_request_cb)(int* rate, int* channel, int* aud /** * @brief A structure for the VC engine functions. * @details This structure contains essential callback functions for operating VC engine. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks You must register all callbacks except optional callbacks for operating VC engine.\n * The following callbacks are optional callbacks : \n * - vce_private_data_set_cb() \n @@ -683,7 +683,7 @@ typedef struct { /** * @brief Starts the main function for Voice Control (VC) engine. * @details This function is the main function for operating VC engine. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @privlevel public * @privilege %http://tizen.org/privilege/recorder \n * %http://tizen.org/privilege/appmanager.launch (Since 7.0) \n @@ -796,7 +796,7 @@ int vce_main(int argc, char** argv, vce_request_callback_s* callback); /** * @brief Sends the results to the engine service user. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @privlevel public * @privilege %http://tizen.org/privilege/appmanager.launch (Since 7.0) \n * %http://tizen.org/privilege/datasharing (Since 7.0) @@ -827,7 +827,7 @@ int vce_send_result(vce_result_event_e event, int* result_id, int count, const c /** * @brief Sends the ASR result to the engine service user. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @privlevel public * @privilege %http://tizen.org/privilege/appmanager.launch (Since 7.0) \n * %http://tizen.org/privilege/datasharing (Since 7.0) @@ -850,7 +850,7 @@ int vce_send_asr_result(vce_asr_result_event_e event, const char* asr_result, vo /** * @brief Sends the NLG (Natural Language Generation) result to the engine service user. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @privlevel public * @privilege %http://tizen.org/privilege/appmanager.launch (Since 7.0) \n * %http://tizen.org/privilege/datasharing (Since 7.0) @@ -872,7 +872,7 @@ int vce_send_nlg_result(const char* nlg_result, void* user_data); /** * @brief Sends the specific engine result to the engine service user. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @privlevel public * @privilege %http://tizen.org/privilege/appmanager.launch (Since 7.0) \n * %http://tizen.org/privilege/datasharing (Since 7.0) @@ -910,7 +910,7 @@ int vce_send_specific_engine_result(const char* engine_app_id, const char* event * #VCE_ERROR_PERMISSION_DENIED, \n * #VCE_ERROR_NOT_SUPPORTED_FEATURE \n * #VCE_ERROR_TTS_FAILED. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @privlevel public * @privilege %http://tizen.org/privilege/appmanager.launch (Since 7.0) \n * %http://tizen.org/privilege/datasharing (Since 7.0) @@ -932,7 +932,7 @@ int vce_send_error(vce_error_e error, const char* msg, void* user_data); /** * @brief Sets a callback function for setting the private data to the engine service. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @remarks The vce_private_data_set_cb() function is called when the engine service user sets the private data to the engine service. @@ -952,7 +952,7 @@ int vce_set_private_data_set_cb(vce_private_data_set_cb callback_func); /** * @brief Sets a callback function for requesting the private data to the engine service. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @remarks The vce_private_data_requested_cb() function is called when the engine service user requests the private data to the engine service. @@ -970,7 +970,7 @@ int vce_set_private_data_requested_cb(vce_private_data_requested_cb callback_fun /** * @brief Sets a callback function for requesting the NLU base information to the engine service. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @remarks The vce_nlu_base_info_requested_cb() function is called when the engine service user requests the NLU base information to the engine service. * @param[in] callback_func vce_nlu_base_info_requested event callback function * @return @c 0 on success, otherwise a negative error value @@ -985,7 +985,7 @@ int vce_set_nlu_base_info_requested_cb(vce_nlu_base_info_requested_cb callback_f /** * @brief Sets a callback function for getting the engine service request. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * * @param[in] callback_func Callback function to register * @@ -1000,7 +1000,7 @@ int vce_set_specific_engine_request_cb(vce_specific_engine_request_cb callback_f /** * @brief Unsets the engine service request callback function. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * * @return 0 on success, otherwise a negative error value * @retval #VCE_ERROR_NONE Successful @@ -1012,7 +1012,7 @@ int vce_unset_specific_engine_request_cb(void); /** * @brief Retrieves all commands using callback function. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * * @param[in] vce_command The handle to be passed to the vce_set_commands_cb() function * @param[in] callback The callback function to invoke @@ -1032,7 +1032,7 @@ int vce_get_foreach_command(vce_cmd_h vce_command, vce_command_cb callback, void /** * @brief Gets command length. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * * @param[in] vce_command The handle to be passed to the vce_set_commands_cb() function * @param[out] count The command count value @@ -1048,7 +1048,7 @@ int vce_get_command_count(vce_cmd_h vce_command, int* count); /** * @brief Gets current audio type. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @remarks The @a audio_type must be released using free() when it is no longer required. @@ -1064,7 +1064,7 @@ int vce_get_audio_type(char** audio_type); /** * @brief Sets private data to a voice manager client. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @privlevel public * @privilege %http://tizen.org/privilege/recorder \n * %http://tizen.org/privilege/appmanager.launch (Since 7.0) \n @@ -1086,7 +1086,7 @@ int vce_set_private_data(const char* key, const char* data); /** * @brief Gets private data from a voice manager client. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @privlevel public * @privilege %http://tizen.org/privilege/recorder \n * %http://tizen.org/privilege/appmanager.launch (Since 7.0) \n @@ -1109,7 +1109,7 @@ int vce_get_private_data(const char* key, char** data); /** * @brief Starts recording voice. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @privlevel public * @privilege %http://tizen.org/privilege/recorder \n * %http://tizen.org/privilege/appmanager.launch (Since 7.0) \n @@ -1127,7 +1127,7 @@ int vce_start_recording(void); /** * @brief Stops recording voice. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @@ -1141,7 +1141,7 @@ int vce_stop_recording(void); /** * @brief Sends audio formats necessary for playing TTS feedback. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @privlevel public * @privilege %http://tizen.org/privilege/appmanager.launch (Since 7.0) \n * %http://tizen.org/privilege/datasharing (Since 7.0) @@ -1163,7 +1163,7 @@ int vce_send_feedback_audio_format(int rate, vce_audio_channel_e channel, vce_au /** * @brief Sends audio streaming necessary for playing TTS feedback. - * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif + * @since_tizen 4.0 * @privlevel public * @privilege %http://tizen.org/privilege/appmanager.launch (Since 7.0) \n * %http://tizen.org/privilege/datasharing (Since 7.0) diff --git a/include/voice_control.h b/include/voice_control.h index b4939e9..64973c8 100644 --- a/include/voice_control.h +++ b/include/voice_control.h @@ -55,14 +55,14 @@ extern "C" /** * @brief Definition for foreground command type. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 */ #define VC_COMMAND_TYPE_FOREGROUND 1 /** * @brief Definition for background command type. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 */ #define VC_COMMAND_TYPE_BACKGROUND 2 @@ -83,7 +83,7 @@ extern "C" /** * @brief Initializes voice control. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @remarks If the function succeeds, vc must be released with vc_deinitialize(). @@ -102,7 +102,7 @@ int vc_initialize(void); /** * @brief Deinitializes voice control. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @return @c 0 on success, @@ -119,7 +119,7 @@ int vc_deinitialize(void); /** * @brief Connects the voice control service. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @return @c 0 on success, @@ -138,7 +138,7 @@ int vc_prepare(void); /** * @brief Disconnects the voice control service. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @return @c 0 on success, @@ -156,7 +156,7 @@ int vc_unprepare(void); /** * @brief Retrieves all supported languages using callback function. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @param[in] callback Callback function to invoke @@ -179,7 +179,7 @@ int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user /** * @brief Gets current language. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @remarks If the function succeeds, @a language must be released with free() by you when you no longer need it. @@ -203,7 +203,7 @@ int vc_get_current_language(char** language); /** * @brief Gets current state of voice control client. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @param[out] state The current state @@ -221,7 +221,7 @@ int vc_get_state(vc_state_e* state); /** * @brief Gets current state of voice control service. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @param[out] state The current state @@ -363,7 +363,7 @@ int vc_request_dialog(const char* disp_text, const char* utt_text, bool auto_sta /** * @brief Sets command list. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @remarks The command type is valid for #VC_COMMAND_TYPE_FOREGROUND or #VC_COMMAND_TYPE_BACKGROUND. @@ -385,7 +385,7 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type); /** * @brief Unsets command list. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @param[in] type Command type @@ -424,7 +424,7 @@ int vc_get_result(vc_result_cb callback, void* user_data); /** * @brief Sets a callback function for getting recognition result. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @param[in] callback Callback function to register @@ -445,7 +445,7 @@ int vc_set_result_cb(vc_result_cb callback, void* user_data); /** * @brief Unsets the callback function. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @return @c 0 on success, @@ -462,7 +462,7 @@ int vc_unset_result_cb(void); /** * @brief Sets a callback function to be called when service state is changed. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @param[in] callback Callback function to register @@ -483,7 +483,7 @@ int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* /** * @brief Unsets the callback function. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @return @c 0 on success, @@ -500,7 +500,7 @@ int vc_unset_service_state_changed_cb(void); /** * @brief Sets a callback function to be called when state is changed. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @param[in] callback Callback function to register @@ -521,7 +521,7 @@ int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data); /** * @brief Unsets the callback function. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @return @c 0 on success, @@ -538,7 +538,7 @@ int vc_unset_state_changed_cb(void); /** * @brief Sets a callback function to be called when current language is changed. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @param[in] callback Callback function to register @@ -559,7 +559,7 @@ int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, /** * @brief Unsets the callback function. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @return @c 0 on success, @@ -576,7 +576,7 @@ int vc_unset_current_language_changed_cb(void); /** * @brief Sets a callback function to be called when an error occurred. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @param[in] callback Callback function to register @@ -597,7 +597,7 @@ int vc_set_error_cb(vc_error_cb callback, void* user_data); /** * @brief Unsets the callback function. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @privlevel public * @privilege %http://tizen.org/privilege/recorder * @return @c 0 on success, diff --git a/include/voice_control_command.h b/include/voice_control_command.h index e1f64af..cc09250 100644 --- a/include/voice_control_command.h +++ b/include/voice_control_command.h @@ -73,21 +73,21 @@ extern "C" /** * @brief The voice command handle. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 */ typedef struct vc_cmd_s* vc_cmd_h; /** * @brief The voice command list handle. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 */ typedef struct vc_cmd_list_s* vc_cmd_list_h; /** * @brief Called to retrieve The commands in list. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @remarks @a vc_command should not be released. It is managed by the framework and will be released when invoking this callback is finished. * @param[in] vc_command The command handle * @param[in] user_data The user data passed from the foreach function @@ -101,7 +101,7 @@ typedef bool (*vc_cmd_list_cb)(vc_cmd_h vc_command, void* user_data); /** * @brief Creates a handle for command list. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @remarks If the function succeeds, @a vc_cmd_list must be released with vc_cmd_list_destroy(). * @param[out] vc_cmd_list The command list handle * @return @c 0 on success, @@ -117,7 +117,7 @@ int vc_cmd_list_create(vc_cmd_list_h* vc_cmd_list); /** * @brief Destroys the handle for command list. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @param[in] vc_cmd_list The command list handle * @param[in] free_command The command free option @c true = release each commands in list, * @c false = remove command from list @@ -133,7 +133,7 @@ int vc_cmd_list_destroy(vc_cmd_list_h vc_cmd_list, bool free_command); /** * @brief Gets command count of list. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @param[in] vc_cmd_list The command list handle * @param[out] count The count * @return @c 0 on success, @@ -147,7 +147,7 @@ int vc_cmd_list_get_count(vc_cmd_list_h vc_cmd_list, int* count); /** * @brief Adds command to command list. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @param[in] vc_cmd_list The command list handle * @param[in] vc_command The command handle * @return @c 0 on success, @@ -162,7 +162,7 @@ int vc_cmd_list_add(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command); /** * @brief Removes command from command list. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @param[in] vc_cmd_list The command list handle * @param[in] vc_command The command handle * @return @c 0 on success, @@ -177,7 +177,7 @@ int vc_cmd_list_remove(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command); /** * @brief Retrieves all commands of command list using callback function. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @param[in] vc_cmd_list The command list handle * @param[in] callback Callback function to invoke * @param[in] user_data The user data to be passed to the callback function @@ -194,7 +194,7 @@ int vc_cmd_list_foreach_commands(vc_cmd_list_h vc_cmd_list, vc_cmd_list_cb callb /** * @brief Moves index to first command. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @param[in] vc_cmd_list The command list handle * @return @c 0 on success, * otherwise a negative error value @@ -209,7 +209,7 @@ int vc_cmd_list_first(vc_cmd_list_h vc_cmd_list); /** * @brief Moves index to last command. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @param[in] vc_cmd_list The command list handle * @return @c 0 on success, * otherwise a negative error value @@ -224,7 +224,7 @@ int vc_cmd_list_last(vc_cmd_list_h vc_cmd_list); /** * @brief Moves index to next command. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @param[in] vc_cmd_list The command list handle * @return @c 0 on success, * otherwise a negative error value @@ -240,7 +240,7 @@ int vc_cmd_list_next(vc_cmd_list_h vc_cmd_list); /** * @brief Moves index to previous command. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @param[in] vc_cmd_list The command list handle * @return @c 0 on success, * otherwise a negative error value @@ -256,7 +256,7 @@ int vc_cmd_list_prev(vc_cmd_list_h vc_cmd_list); /** * @brief Gets current command from command list by index. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @remarks @a vc_command should be released after removing it from @a vc_cmd_list with vc_cmd_list_remove(). * @param[in] vc_cmd_list The command list handle * @param[out] vc_command The command handle @@ -276,7 +276,7 @@ int vc_cmd_list_get_current(vc_cmd_list_h vc_cmd_list, vc_cmd_h* vc_command); /** * @brief Creates a handle for command. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @remarks If the function succeeds, @a vc_command must be released with vc_cmd_destroy() or vc_cmd_list_destroy(). * You should set command and type if command is valid. * The command format is set to #VC_COMMAND_FORMAT_FIXED by default and can be changed with vc_cmd_set_format(). @@ -294,7 +294,7 @@ int vc_cmd_create(vc_cmd_h* vc_command); /** * @brief Destroys the handle. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @param[in] vc_command The command handle * @return @c 0 on success, * otherwise a negative error value @@ -308,7 +308,7 @@ int vc_cmd_destroy(vc_cmd_h vc_command); /** * @brief Sets command or action. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @param[in] vc_command The command handle * @param[in] command The command or action text * @return @c 0 on success, @@ -323,7 +323,7 @@ int vc_cmd_set_command(vc_cmd_h vc_command, const char* command); /** * @brief Gets command. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @remarks If the function succeeds, @a command must be released with free() by you if they are not NULL. * @param[in] vc_command The command handle * @param[out] command The command text @@ -356,7 +356,7 @@ int vc_cmd_get_unfixed_command(vc_cmd_h vc_command, char** command); /** * @brief Sets command type. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @remarks If you do not set the command type, the default value is @c -1. * You should set type if command is valid * @param[in] vc_command The command handle @@ -373,7 +373,7 @@ int vc_cmd_set_type(vc_cmd_h vc_command, int type); /** * @brief Gets command type. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @param[in] vc_command The command handle * @param[out] type The command type * @return @c 0 on success, diff --git a/include/voice_control_command_expand.h b/include/voice_control_command_expand.h index ca353e7..2b00752 100644 --- a/include/voice_control_command_expand.h +++ b/include/voice_control_command_expand.h @@ -50,7 +50,7 @@ typedef enum { /** * @brief Sets command domain -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif +* @since_tizen 2.4 * * @param[in] vc_command The command handle * @param[in] domain The domain @@ -67,7 +67,7 @@ int vc_cmd_set_domain(vc_cmd_h vc_command, int domain); /** * @brief Gets command domain. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif +* @since_tizen 2.4 * * @param[in] vc_command The command handle * @param[out] domain The domain @@ -84,7 +84,7 @@ int vc_cmd_get_domain(vc_cmd_h vc_command, int* domain); /** * @brief Remove all commands from command list. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif +* @since_tizen 2.4 * * @param[in] vc_cmd_list The command list handle * @param[in] free_command The command free option @c true = release each commands in list, diff --git a/include/voice_control_common.h b/include/voice_control_common.h index 400dce9..a2b4c53 100644 --- a/include/voice_control_common.h +++ b/include/voice_control_common.h @@ -35,7 +35,7 @@ extern "C" /** * @brief Enumeration for error codes. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 */ typedef enum { VC_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ @@ -64,7 +64,7 @@ typedef enum { /** * @brief Enumeration for result event. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 */ typedef enum { VC_RESULT_EVENT_RESULT_SUCCESS = 0, /**< Normal result */ @@ -74,7 +74,7 @@ typedef enum { /** * @brief Enumeration for service state. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 */ typedef enum { VC_SERVICE_STATE_NONE = 0, /**< 'None' state */ @@ -86,7 +86,7 @@ typedef enum { /** * @brief Enumeration for client state. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 */ typedef enum { VC_STATE_NONE = 0, /**< 'None' state */ @@ -147,7 +147,7 @@ typedef enum { /** * @brief Called when client gets the recognition result. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @remarks If the duplicated commands are recognized, the event(e.g. #VC_RESULT_EVENT_REJECTED) of command may be rejected * for selecting command as priority. If you set similar or same commands or the recognized results are multi-results, * vc_cmd_list has the multi commands. @@ -163,7 +163,7 @@ typedef void (*vc_result_cb)(vc_result_event_e event, vc_cmd_list_h vc_cmd_list, /** * @brief Called when default language is changed. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @param[in] previous Previous language * @param[in] current Current language * @param[in] user_data The user data passed from the callback registration function @@ -175,7 +175,7 @@ typedef void (*vc_current_language_changed_cb)(const char* previous, const char* /** * @brief Called to retrieve supported language. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @param[in] language A language is specified as an ISO 3166 alpha-2 two letter country-code * followed by ISO 639-1 for the two-letter language code. * For example, "ko_KR" for Korean, "en_US" for American English @@ -189,7 +189,7 @@ typedef bool (*vc_supported_language_cb)(const char* language, void* user_data); /** * @brief Called when the state of voice control client is changed. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @param[in] previous A previous state * @param[in] current A current state * @param[in] user_data The user data passed from the callback registration function @@ -201,7 +201,7 @@ typedef void (*vc_state_changed_cb)(vc_state_e previous, vc_state_e current, voi /** * @brief Called when the state of voice control service is changed. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @param[in] previous A previous state * @param[in] current A current state * @param[in] user_data The user data passed from the callback registration function @@ -213,7 +213,7 @@ typedef void (*vc_service_state_changed_cb)(vc_service_state_e previous, vc_serv /** * @brief Called when error occurred. - * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif + * @since_tizen 2.4 * @param[in] reason The error type (e.g. #VC_ERROR_OUT_OF_MEMORY, #VC_ERROR_TIMED_OUT) * @param[in] user_data The user data passed from the callback registration function * @pre An application registers this callback to detect error. diff --git a/include/voice_control_setting.h b/include/voice_control_setting.h index 89ae6fa..89b9bd7 100644 --- a/include/voice_control_setting.h +++ b/include/voice_control_setting.h @@ -79,7 +79,7 @@ typedef void (*vc_setting_engine_changed_cb)(const char* engine_id, void *user_d /** * @brief Called to retrieve supported language. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif +* @since_tizen 2.4 * * @param[in] language A language is specified as an ISO 3166 alpha-2 two letter country-code \n * followed by ISO 639-1 for the two-letter language code. \n @@ -94,7 +94,7 @@ typedef bool(*vc_setting_supported_language_cb)(const char* language, void* user /** * @brief Called when default language is changed. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif +* @since_tizen 2.4 * * @param[in] previous Previous language * @param[in] current Current language diff --git a/include/voice_control_widget.h b/include/voice_control_widget.h index 93c3e4c..8766f6b 100644 --- a/include/voice_control_widget.h +++ b/include/voice_control_widget.h @@ -37,7 +37,7 @@ extern "C" /** * @brief Definitions for widget command type. -* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif +* @since_tizen 2.4 */ #define VC_COMMAND_TYPE_WIDGET 3 -- 2.7.4 From 05f9bb0660241a9c81287bb13320d8afc51fc7ca Mon Sep 17 00:00:00 2001 From: Sejun Park Date: Mon, 18 Dec 2023 17:56:50 +0900 Subject: [PATCH 08/16] fix the restore logic when db file is damaged Change-Id: Ifabc36db0e6be49c8ee234269258e1617b827bd3 --- common/vc_cmd_db.c | 108 +++++++++++++++-------------------------------------- 1 file changed, 31 insertions(+), 77 deletions(-) diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index dff7ec0..6250dfb 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -72,6 +72,7 @@ static int __vc_db_begin_transaction(sqlite3* db_handle); static int __vc_db_create_table(sqlite3* db_handle, const char* table); static int __vc_db_rollback_transaction(sqlite3* db_handle); static int __vc_db_commit_transaction(sqlite3* db_handle); +static int __vc_db_restore_table(sqlite3* db_handle, const char* table); int __vc_db_reset_handle(void) @@ -1528,6 +1529,24 @@ static int __vc_db_open_db_for_daemon(const char* path, sqlite3** db_handle) return VC_DB_ERROR_OPERATION_FAILED; } + ret = sqlite3_exec(*db_handle, "PRAGMA integrity_check", 0, 0, 0); + if (SQLITE_OK != ret) { + SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to open DB for daemon"); + + ret = db_util_close(*db_handle); + if (ret != SQLITE_OK) { + SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to close db, ret %d: %s for daemon", ret, sqlite3_errmsg(*db_handle)); + } + *db_handle = NULL; + + if (0 != remove(path)) { + SLOG(LOG_ERROR, vc_db_tag(), "[Error] remove file(%s) is failed for daemon", path); + g_db_cnt = (g_db_cnt + 1) % 1000; + snprintf((char *)path, _POSIX_PATH_MAX, "%s/.vc_info_%d.db", VC_RUNTIME_INFO_ROOT, g_db_cnt); + } + return VC_DB_ERROR_OPERATION_FAILED; + } + if (!stat.st_size) { __vc_db_begin_transaction(*db_handle); @@ -1544,6 +1563,18 @@ static int __vc_db_open_db_for_daemon(const char* path, sqlite3** db_handle) __vc_db_rollback_transaction(*db_handle); return VC_DB_ERROR_OPERATION_FAILED; } + ret = __vc_db_restore_table(*db_handle, VC_INFO_TABLE); + if (0 != ret) { + SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to create table (%s), %d", VC_INFO_TABLE, ret); + __vc_db_rollback_transaction(*db_handle); + return VC_DB_ERROR_OPERATION_FAILED; + } + ret = __vc_db_restore_table(*db_handle, VC_RESULT_TABLE); + if (0 != ret) { + SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to create table (%s), %d", VC_RESULT_TABLE, ret); + __vc_db_rollback_transaction(*db_handle); + return VC_DB_ERROR_OPERATION_FAILED; + } __vc_db_commit_transaction(*db_handle); } @@ -1603,47 +1634,6 @@ static bool __vc_db_connect_db_for_daemon(const char* path, sqlite3** db_handle) return is_connect; } -static int __vc_db_integrity_check_cb(void *NotUsed, int argc, char **argv, char **azColName) -{ - SLOG(LOG_INFO, vc_db_tag(), "integrity check cb is called"); - - int ret; - char *check_str = "ok"; - if (0 != strncmp(argv[0], check_str, strlen(check_str))) { - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Doesn't have integrity(%s), retry to connect after removing", argv[0]); - if (0 != remove(g_path)) { - SLOG(LOG_ERROR, vc_db_tag(), "[Error] remove file(%s) is failed for daemon", g_path); - g_db_cnt = (g_db_cnt + 1) % 1000; - snprintf(g_path, _POSIX_PATH_MAX, "%s/.vc_info_%d.db", VC_RUNTIME_INFO_ROOT, g_db_cnt); - } - bool is_connect = __vc_db_connect_db_for_daemon(g_path, &g_db_handle); - if (true == is_connect) { - SLOG(LOG_ERROR, vc_db_tag(), "[INFO] Success to connect main DB for daemon"); - ret = __vc_db_restore_table(g_db_handle, VC_INFO_TABLE); - if (0 != ret) { - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to create table (%s)", VC_INFO_TABLE); - } - ret = __vc_db_restore_table(g_db_handle, VC_RESULT_TABLE); - if (0 != ret) { - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to create table (%s)", VC_RESULT_TABLE); - } - is_connect = __vc_db_connect_db_for_daemon(g_backup_path, &g_db_backup_handle); - if (true == is_connect) { - SLOG(LOG_ERROR, vc_db_tag(), "[INFO] Success to connect backup DB for daemon"); - if (0 != vc_db_restore_command()) { - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to restore command"); - } - } - } else { - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to connect main DB for daemon"); - return VC_DB_ERROR_OPERATION_FAILED; - } - } - - SLOG(LOG_INFO, vc_db_tag(), "db integrity result : %s", argv[0]); - return VC_DB_ERROR_NONE; -} - int vc_db_initialize_for_daemon(void) { SLOG(LOG_INFO, vc_db_tag(), "DB on initialization for daemon"); @@ -1683,42 +1673,6 @@ int vc_db_initialize_for_daemon(void) return VC_DB_ERROR_OPERATION_FAILED; } } - - int ret = sqlite3_exec(g_db_handle, "pragma integrity_check", __vc_db_integrity_check_cb, NULL, NULL); - if (SQLITE_CORRUPT == ret) { - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to open DB for daemon"); - - ret = db_util_close(g_db_handle); - if (ret != SQLITE_OK) { - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to close db, ret %d: %s for daemon", ret, sqlite3_errmsg(g_db_handle)); - } - g_db_handle = NULL; - - if (0 != remove(g_path)) { - SLOG(LOG_ERROR, vc_db_tag(), "[Error] remove file(%s) is failed for daemon", g_path); - g_db_cnt = (g_db_cnt + 1) % 1000; - snprintf(g_path, _POSIX_PATH_MAX, "%s/.vc_info_%d.db", VC_RUNTIME_INFO_ROOT, g_db_cnt); - } - is_connect = __vc_db_connect_db_for_daemon(g_path, &g_db_handle); - if (true == is_connect) { - SLOG(LOG_ERROR, vc_db_tag(), "[INFO] Success to connect main DB for daemon"); - is_connect = __vc_db_connect_db_for_daemon(g_backup_path, &g_db_backup_handle); - if (true == is_connect) { - SLOG(LOG_ERROR, vc_db_tag(), "[INFO] Success to connect backup DB for daemon"); - if (0 != vc_db_restore_command()) { - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to restore command for daemon"); - } - } - } else { - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to connect main DB for daemon"); - return VC_DB_ERROR_OPERATION_FAILED; - } - - g_ref_cnt++; - SLOG(LOG_INFO, vc_db_tag(), "[SUCCESS] DB initialization after restore for daemon"); - return VC_DB_ERROR_NONE; - } - is_connect = __vc_db_connect_db_for_daemon(g_backup_path, &g_db_backup_handle); if (false == is_connect) { SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to open backup DB, retry to connect after removing file for daemon"); -- 2.7.4 From 72ee059f3047a279e13e1eb88d5898841e200ba4 Mon Sep 17 00:00:00 2001 From: dyamy-lee Date: Wed, 7 Feb 2024 11:18:21 +0900 Subject: [PATCH 09/16] consider memory leak issue There is no case about d_default_lang is not null. However, it couldn't suere that if the function's logic is changed. So, this added the free(0 for considering if d_default_lang is not null case Change-Id: Ie4c650bcd062b3045f6ecc1ffe3e9eee26d0ff0a --- server/vcd_engine_agent.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/vcd_engine_agent.c b/server/vcd_engine_agent.c index c000e7b..480b53b 100644 --- a/server/vcd_engine_agent.c +++ b/server/vcd_engine_agent.c @@ -113,6 +113,9 @@ int vcd_engine_agent_init() if (0 != vcd_config_get_default_language(&g_default_lang)) { SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] There is No default voice in config"); /* Set default voice */ + if (g_default_lang) { + free(g_default_lang); + } g_default_lang = strdup(VC_BASE_LANGUAGE); if (NULL == g_default_lang) { SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent] Fail to allocate memory"); -- 2.7.4 From 4d607ac186cf88b04072085366aba6243bd66511 Mon Sep 17 00:00:00 2001 From: dyamy-lee Date: Wed, 7 Feb 2024 12:27:40 +0900 Subject: [PATCH 10/16] added null check after calling strdup If there is no enough memory, strdup() can return null because of out of memory. For preventing it, this patch added null check Change-Id: I346b57d6dc28c03aa50c34315b05520401150edc --- client/vc_setting_tidl.c | 13 ++++++++++--- client/vc_tidl.c | 13 ++++++++++--- server/vcd_tidl.c | 8 ++++++-- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/client/vc_setting_tidl.c b/client/vc_setting_tidl.c index 686652f..9808020 100644 --- a/client/vc_setting_tidl.c +++ b/client/vc_setting_tidl.c @@ -69,11 +69,14 @@ static char* __get_engine_appid(void) engine_name = strdup("org.tizen.vc-engine-default"); } - char* appid = strdup(engine_name); + if (NULL == engine_name) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Out of memory"); + return NULL; + } - SLOG(LOG_INFO, TAG_VCC, "[INFO] VC engine appid(%s)", appid); + char* appid = engine_name; - free(engine_name); + SLOG(LOG_INFO, TAG_VCC, "[INFO] VC engine appid(%s)", appid); return appid; } @@ -223,6 +226,10 @@ int vc_setting_tidl_open_connection() int pid = getpid(); char* engine_appid = __get_engine_appid(); + if (NULL == engine_appid) { + SLOG(LOG_ERROR, TAG_VCC, "[TIDL ERROR] Fail to get engine appid"); + return VC_ERROR_OUT_OF_MEMORY; + } info->rpc_h = __create_rpc_port(pid, engine_appid); if (NULL == info->rpc_h) { diff --git a/client/vc_tidl.c b/client/vc_tidl.c index aad0435..5985b3e 100644 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -78,11 +78,14 @@ static char* __get_engine_appid(void) engine_name = strdup("org.tizen.vc-engine-default"); } - char* appid = strdup(engine_name); + if (NULL == engine_name) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Out of memory"); + return NULL; + } - SLOG(LOG_INFO, TAG_VCC, "[INFO] VC engine appid(%s)", appid); + char* appid = engine_name; - free(engine_name); + SLOG(LOG_INFO, TAG_VCC, "[INFO] VC engine appid(%s)", appid); return appid; } @@ -370,6 +373,10 @@ int vc_tidl_open_connection() int pid = getpid(); info->pid = pid; info->engine_appid = __get_engine_appid(); + if (NULL == info->engine_appid) { + SLOG(LOG_ERROR, TAG_VCC, "[TIDL ERROR] Fail to get engine appid"); + return VC_ERROR_OUT_OF_MEMORY; + } info->rpc_h = __create_rpc_port(pid, info->engine_appid); if (NULL == info->rpc_h) { diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index 22dcb6f..fcdf952 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -1099,8 +1099,12 @@ static int __vc_mgr_get_private_data_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_conte temp_data = strdup("#NULL"); } - *data = strdup(temp_data); - free(temp_data); + if (NULL == temp_data) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Out of memory"); + return VC_ERROR_OUT_OF_MEMORY; + } + + *data = temp_data; SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr get private data : pid(%d), key(%s)", pid, key); -- 2.7.4 From bcb6f54ed604941d4e084711b050a10a95070bc3 Mon Sep 17 00:00:00 2001 From: dyamy-lee Date: Wed, 7 Feb 2024 13:56:22 +0900 Subject: [PATCH 11/16] used snprintf instead of strncat Actually, getcwd() returns value when it doesn't have error case like sizeof() <= strlen(). However, using snprintf() looks more safe. So, it was changed. Change-Id: Id091e366801cc98d80ce3c2281a40d0f954e234f --- common/vc_info_parser.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/vc_info_parser.c b/common/vc_info_parser.c index 3e7ee27..3ff0b6f 100644 --- a/common/vc_info_parser.c +++ b/common/vc_info_parser.c @@ -375,10 +375,10 @@ static int __is_symbolic_link(const char* path, bool* is_symbolic) SLOG(LOG_DEBUG, vc_info_tag(), "[DEBUG] %s is real file, not symbolic link", path); *is_symbolic = false; } else { + char current_working_directory[PATH_MAX]; char temp_path[PATH_MAX]; - if (getcwd(temp_path, PATH_MAX)) { - strncat(temp_path, "/", sizeof(temp_path) - strlen(temp_path) - 1); - strncat(temp_path, path, sizeof(temp_path) - strlen(temp_path) - 1); + if (getcwd(current_working_directory, PATH_MAX)) { + snprintf(temp_path, PATH_MAX, "%s/%s", current_working_directory, path); if (strncmp(temp_path, real_path, strlen(temp_path) + 1) == 0) { SLOG(LOG_DEBUG, vc_info_tag(), "[DEBUG] %s is real file, not symbolic link", path); *is_symbolic = false; -- 2.7.4 From ea3138c02b0371bd25041b54c3598b6b948803f8 Mon Sep 17 00:00:00 2001 From: dyamy-lee Date: Tue, 13 Feb 2024 10:34:11 +0900 Subject: [PATCH 12/16] fix build error about snprintf The output may be truncated before the last format character. So, it checked length before using snprintf Change-Id: Iad722db28a5fd443df33988adbb4b755aa5afaa3 --- common/vc_info_parser.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/common/vc_info_parser.c b/common/vc_info_parser.c index 3ff0b6f..25e28ce 100644 --- a/common/vc_info_parser.c +++ b/common/vc_info_parser.c @@ -378,10 +378,12 @@ static int __is_symbolic_link(const char* path, bool* is_symbolic) char current_working_directory[PATH_MAX]; char temp_path[PATH_MAX]; if (getcwd(current_working_directory, PATH_MAX)) { - snprintf(temp_path, PATH_MAX, "%s/%s", current_working_directory, path); - if (strncmp(temp_path, real_path, strlen(temp_path) + 1) == 0) { - SLOG(LOG_DEBUG, vc_info_tag(), "[DEBUG] %s is real file, not symbolic link", path); - *is_symbolic = false; + if (strlen(current_working_directory) + strlen(path) <= PATH_MAX) { + snprintf(temp_path, PATH_MAX, "%s/%s", current_working_directory, path); + if (strncmp(temp_path, real_path, strlen(temp_path) + 1) == 0) { + SLOG(LOG_DEBUG, vc_info_tag(), "[DEBUG] %s is real file, not symbolic link", path); + *is_symbolic = false; + } } } } -- 2.7.4 From 57420d7f5c5ae9a2e4fb903b1e9b924b389a9317 Mon Sep 17 00:00:00 2001 From: dyamy-lee Date: Tue, 13 Feb 2024 15:22:37 +0900 Subject: [PATCH 13/16] change the location of mutex Before calling global variable, it calls mutex lock first. Some cases missed that, so it changed. And, in that case, it doesn't have to check the variable value again. So, it removed that checking condition. Change-Id: I6e585eaad94567ef629ff878d341cf1189d648ab --- client/vc.c | 104 ++++++++++++++++++++++++------------------------- client/vc_mgr.c | 74 +++++++++++++++++------------------ client/vc_mgr_data.cpp | 4 +- common/vc_command.c | 50 ++++++++++++------------ server/vce.c | 89 +++++++++++++++++++++--------------------- 5 files changed, 160 insertions(+), 161 deletions(-) diff --git a/client/vc.c b/client/vc.c index c514b81..39bd7aa 100644 --- a/client/vc.c +++ b/client/vc.c @@ -152,39 +152,39 @@ static void __check_privilege_deinitialize() static int __vc_check_privilege() { - if (true == g_privilege_allowed) - return VC_ERROR_NONE; - pthread_mutex_lock(&g_cynara_mutex); - if (false == g_privilege_allowed) { - bool ret = true; - ret = __check_privilege_initialize(); - if (false == ret) { - //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] privilege initialize is failed"); - pthread_mutex_unlock(&g_cynara_mutex); - return VC_ERROR_PERMISSION_DENIED; - //LCOV_EXCL_STOP - } + if (true == g_privilege_allowed) { + pthread_mutex_unlock(&g_cynara_mutex); + return VC_ERROR_NONE; + } - char uid[32]; - snprintf(uid, 32, "%d", getuid()); - ret = true; - ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER); - if (false == ret) { - //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCC, "[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 - } + bool ret = true; + ret = __check_privilege_initialize(); + if (false == ret) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] privilege initialize is failed"); + pthread_mutex_unlock(&g_cynara_mutex); + return VC_ERROR_PERMISSION_DENIED; + //LCOV_EXCL_STOP + } + char uid[32]; + snprintf(uid, 32, "%d", getuid()); + ret = true; + ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER); + if (false == ret) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCC, "[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 } + __check_privilege_deinitialize(); + g_privilege_allowed = true; pthread_mutex_unlock(&g_cynara_mutex); return VC_ERROR_NONE; @@ -204,39 +204,39 @@ int __check_feature_privilege() int __vc_tts_check_privilege() { - if (true == g_vc_tts_privilege_allowed) - return VC_ERROR_NONE; - pthread_mutex_lock(&g_cynara_mutex); - if (false == g_vc_tts_privilege_allowed) { - bool ret = true; - ret = __check_privilege_initialize(); - if (false == ret) { - //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] privilege initialize is failed"); - pthread_mutex_unlock(&g_cynara_mutex); - return VC_ERROR_PERMISSION_DENIED; - //LCOV_EXCL_STOP - } + if (true == g_vc_tts_privilege_allowed) { + pthread_mutex_unlock(&g_cynara_mutex); + return VC_ERROR_NONE; + } - char uid[32]; - snprintf(uid, 32, "%d", getuid()); - ret = true; - ret = __check_privilege(uid, VC_TTS_PRIVILEGE); - if (false == ret) { - //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Permission is denied(%s)(%s)", VC_TTS_PRIVILEGE, uid); - __check_privilege_deinitialize(); - g_vc_tts_privilege_allowed = false; - pthread_mutex_unlock(&g_cynara_mutex); - return VC_ERROR_PERMISSION_DENIED; - //LCOV_EXCL_STOP - } + bool ret = true; + ret = __check_privilege_initialize(); + if (false == ret) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] privilege initialize is failed"); + pthread_mutex_unlock(&g_cynara_mutex); + return VC_ERROR_PERMISSION_DENIED; + //LCOV_EXCL_STOP + } + char uid[32]; + snprintf(uid, 32, "%d", getuid()); + ret = true; + ret = __check_privilege(uid, VC_TTS_PRIVILEGE); + if (false == ret) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Permission is denied(%s)(%s)", VC_TTS_PRIVILEGE, uid); __check_privilege_deinitialize(); + g_vc_tts_privilege_allowed = false; + pthread_mutex_unlock(&g_cynara_mutex); + return VC_ERROR_PERMISSION_DENIED; + //LCOV_EXCL_STOP } + __check_privilege_deinitialize(); + g_vc_tts_privilege_allowed = true; pthread_mutex_unlock(&g_cynara_mutex); return VC_ERROR_NONE; diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 73d5c6b..c0e5305 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -198,51 +198,51 @@ static void __check_privilege_deinitialize() static int __vc_mgr_check_privilege() { - if (true == g_privilege_allowed) - return VC_ERROR_NONE; - pthread_mutex_lock(&g_cynara_mutex); - if (false == g_privilege_allowed) { - 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 - } + if (true == g_privilege_allowed) { + pthread_mutex_unlock(&g_cynara_mutex); + return VC_ERROR_NONE; + } - char uid[32]; - snprintf(uid, 32, "%d", getuid()); - 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 - } + 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 + } - 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 - } + char uid[32]; + snprintf(uid, 32, "%d", getuid()); + 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(); + g_privilege_allowed = true; pthread_mutex_unlock(&g_cynara_mutex); return VC_ERROR_NONE; diff --git a/client/vc_mgr_data.cpp b/client/vc_mgr_data.cpp index 27c96a2..cdcffdc 100644 --- a/client/vc_mgr_data.cpp +++ b/client/vc_mgr_data.cpp @@ -96,10 +96,10 @@ int vc_mgr_data_get_feedback_data_size() int vc_mgr_data_clear_feedback_data(vc_feedback_data_s** data) { - SLOG(LOG_INFO, TAG_VCM, "[DATA] clear feedback data, empty(%d)", g_feedback_data.empty()); - pthread_mutex_lock(&g_feedback_data_mutex); + SLOG(LOG_INFO, TAG_VCM, "[DATA] clear feedback data, empty(%d)", g_feedback_data.empty()); + if (NULL != *data) { SLOG(LOG_INFO, TAG_VCM, "[DEBUG] pid(%d), utt_id(%d), data(%p) size(%d) rate(%d)", (*data)->pid, (*data)->utt_id, (*data)->data, (*data)->data_size, (*data)->rate); diff --git a/common/vc_command.c b/common/vc_command.c index edff3b4..2958d9d 100644 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -150,38 +150,38 @@ static void __check_privilege_deinitialize() static int __vc_cmd_check_privilege() { - if (true == g_privilege_allowed) - return VC_ERROR_NONE; - pthread_mutex_lock(&g_cynara_mutex); - if (false == g_privilege_allowed) { - bool ret = true; - ret = __check_privilege_initialize(); - if (false == ret) { - SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] privilege initialize is failed"); - g_privilege_allowed = false; - pthread_mutex_unlock(&g_cynara_mutex); - return VC_ERROR_PERMISSION_DENIED; - } + if (true == g_privilege_allowed) { + pthread_mutex_unlock(&g_cynara_mutex); + return VC_ERROR_NONE; + } - char uid[32]; - snprintf(uid, 32, "%d", getuid()); - ret = true; - ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER); - if (false == ret) { - //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCCMD, "[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 - } + bool ret = true; + ret = __check_privilege_initialize(); + if (false == ret) { + SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] privilege initialize is failed"); + g_privilege_allowed = false; + pthread_mutex_unlock(&g_cynara_mutex); + return VC_ERROR_PERMISSION_DENIED; + } + char uid[32]; + snprintf(uid, 32, "%d", getuid()); + ret = true; + ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER); + if (false == ret) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCCMD, "[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 } + __check_privilege_deinitialize(); + g_privilege_allowed = true; pthread_mutex_unlock(&g_cynara_mutex); return VC_ERROR_NONE; diff --git a/server/vce.c b/server/vce.c index 7daff10..d97cb86 100644 --- a/server/vce.c +++ b/server/vce.c @@ -113,60 +113,59 @@ static void __check_privilege_deinitialize() static int __vce_check_privilege() { - if (true == g_privilege_allowed) - return VC_ERROR_NONE; - pthread_mutex_lock(&g_cynara_mutex); - if (false == g_privilege_allowed) { - bool ret = true; - ret = __check_privilege_initialize(); - if (false == ret) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] privilege initialize is failed"); - pthread_mutex_unlock(&g_cynara_mutex); - return VCE_ERROR_PERMISSION_DENIED; - } - - char uid[32]; - snprintf(uid, 32, "%d", getuid()); - ret = true; - ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER); - if (false == ret) { - //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_RECORDER, uid); - __check_privilege_deinitialize(); - g_privilege_allowed = false; - pthread_mutex_unlock(&g_cynara_mutex); - return VCE_ERROR_PERMISSION_DENIED; - //LCOV_EXCL_STOP - } + if (true == g_privilege_allowed) { + pthread_mutex_unlock(&g_cynara_mutex); + return VC_ERROR_NONE; + } - ret = __check_privilege(uid, VC_PRIVILEGE_APPMGR_LAUNCH); - if (false == ret) { - //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_APPMGR_LAUNCH, uid); - __check_privilege_deinitialize(); - g_privilege_allowed = false; - pthread_mutex_unlock(&g_cynara_mutex); - return VCE_ERROR_PERMISSION_DENIED; - //LCOV_EXCL_STOP - } + bool ret = true; + ret = __check_privilege_initialize(); + if (false == ret) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] privilege initialize is failed"); + pthread_mutex_unlock(&g_cynara_mutex); + return VCE_ERROR_PERMISSION_DENIED; + } - ret = __check_privilege(uid, VC_PRIVILEGE_DATASHARING); - if (false == ret) { - //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_DATASHARING, uid); - __check_privilege_deinitialize(); - g_privilege_allowed = false; - pthread_mutex_unlock(&g_cynara_mutex); - return VCE_ERROR_PERMISSION_DENIED; - //LCOV_EXCL_STOP - } + char uid[32]; + snprintf(uid, 32, "%d", getuid()); + ret = true; + ret = __check_privilege(uid, VC_PRIVILEGE_RECORDER); + if (false == ret) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_RECORDER, uid); + __check_privilege_deinitialize(); + g_privilege_allowed = false; + pthread_mutex_unlock(&g_cynara_mutex); + return VCE_ERROR_PERMISSION_DENIED; + //LCOV_EXCL_STOP + } + ret = __check_privilege(uid, VC_PRIVILEGE_APPMGR_LAUNCH); + if (false == ret) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_APPMGR_LAUNCH, uid); __check_privilege_deinitialize(); + g_privilege_allowed = false; + pthread_mutex_unlock(&g_cynara_mutex); + return VCE_ERROR_PERMISSION_DENIED; + //LCOV_EXCL_STOP + } + ret = __check_privilege(uid, VC_PRIVILEGE_DATASHARING); + if (false == ret) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_DATASHARING, uid); + __check_privilege_deinitialize(); + g_privilege_allowed = false; + pthread_mutex_unlock(&g_cynara_mutex); + return VCE_ERROR_PERMISSION_DENIED; + //LCOV_EXCL_STOP } + __check_privilege_deinitialize(); + g_privilege_allowed = true; pthread_mutex_unlock(&g_cynara_mutex); return VCE_ERROR_NONE; -- 2.7.4 From 0c3e587feb13330de4ac28c6fda6c9017e9c4b46 Mon Sep 17 00:00:00 2001 From: dyamy-lee Date: Mon, 11 Mar 2024 16:13:45 +0900 Subject: [PATCH 14/16] re-fix build error about snprintf The variable's length is not proper. So, it changed to reduce size of the variable Change-Id: I82a2b505ae2f08418a8c552110bdf050e3f7cc8a --- common/vc_info_parser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/vc_info_parser.c b/common/vc_info_parser.c index 25e28ce..e0479cb 100644 --- a/common/vc_info_parser.c +++ b/common/vc_info_parser.c @@ -375,9 +375,9 @@ static int __is_symbolic_link(const char* path, bool* is_symbolic) SLOG(LOG_DEBUG, vc_info_tag(), "[DEBUG] %s is real file, not symbolic link", path); *is_symbolic = false; } else { - char current_working_directory[PATH_MAX]; + char current_working_directory[PATH_MAX/2]; char temp_path[PATH_MAX]; - if (getcwd(current_working_directory, PATH_MAX)) { + if (getcwd(current_working_directory, PATH_MAX/2)) { if (strlen(current_working_directory) + strlen(path) <= PATH_MAX) { snprintf(temp_path, PATH_MAX, "%s/%s", current_working_directory, path); if (strncmp(temp_path, real_path, strlen(temp_path) + 1) == 0) { -- 2.7.4 From 4c793dad4b8ee41aad2472004c50e4dbbb88e559 Mon Sep 17 00:00:00 2001 From: dyamy-lee Date: Mon, 11 Mar 2024 16:27:48 +0900 Subject: [PATCH 15/16] change the order of setting root element about xmlDoc When calling 'xmlDocSetRootElement', it removes 'root' in this inside logic. So, the 'root' which allocated from 'xmlNewNode' has possiblity of free in it. Therefore, this patch changed the order of calling this function after calling 'xmlDocSetRootElement'. Change-Id: I64c3dc5154bef464586c4a81df99961965259cbf --- engine-parser/src/vc-engine-parser.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engine-parser/src/vc-engine-parser.c b/engine-parser/src/vc-engine-parser.c index 44d0f8e..9ccc88d 100644 --- a/engine-parser/src/vc-engine-parser.c +++ b/engine-parser/src/vc-engine-parser.c @@ -353,6 +353,8 @@ static int __write_metadata_inxml(const char *pkgid, const char *appid, GList *l xmlNodePtr root = NULL; xmlNodePtr cur = NULL; + xmlDocSetRootElement(g_doc, root); + root = xmlNewNode(NULL, (const xmlChar*)VC_TAG_ENGINE_BASE); if (NULL == root) { @@ -360,7 +362,6 @@ static int __write_metadata_inxml(const char *pkgid, const char *appid, GList *l // xmlFreeDoc(g_doc); return -1; } - xmlDocSetRootElement(g_doc, root); iter = g_list_first(list); while (NULL != iter) { -- 2.7.4 From 07f6bccebf7218f1088b55290c4ef0c2a3bf9d13 Mon Sep 17 00:00:00 2001 From: dyamy-lee Date: Tue, 12 Mar 2024 17:03:29 +0900 Subject: [PATCH 16/16] Add NULL checking NULL_AFTER_DEREF Alarm needs checking NULL. So, it added null check before using db_handle variable. Change-Id: I40d4e166a86df23b3ffce6ba7f41c14ae3b443aa --- common/vc_cmd_db.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index 6250dfb..6afb62b 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -1529,6 +1529,11 @@ static int __vc_db_open_db_for_daemon(const char* path, sqlite3** db_handle) return VC_DB_ERROR_OPERATION_FAILED; } + if (*db_handle == NULL) { + SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to open db, path = %s, ret(%d)", path, ret); + return VC_DB_ERROR_OPERATION_FAILED; + } + ret = sqlite3_exec(*db_handle, "PRAGMA integrity_check", 0, 0, 0); if (SQLITE_OK != ret) { SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to open DB for daemon"); @@ -1579,17 +1584,16 @@ static int __vc_db_open_db_for_daemon(const char* path, sqlite3** db_handle) __vc_db_commit_transaction(*db_handle); } - if (*db_handle) { - char* err_msg = NULL; - static const char* sql = "PRAGMA journal_mode = WAL"; - int ret = sqlite3_exec(*db_handle, sql, NULL, NULL, &err_msg); - if (ret != SQLITE_OK) { - SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_exec returned %d: %s", ret, err_msg); - sqlite3_free(err_msg); - err_msg = NULL; - return VC_DB_ERROR_OPERATION_FAILED; - } + char* err_msg = NULL; + static const char* sql = "PRAGMA journal_mode = WAL"; + ret = sqlite3_exec(*db_handle, sql, NULL, NULL, &err_msg); + if (ret != SQLITE_OK) { + SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_exec returned %d: %s", ret, err_msg); + sqlite3_free(err_msg); + err_msg = NULL; + return VC_DB_ERROR_OPERATION_FAILED; } + return VC_DB_ERROR_NONE; } -- 2.7.4