return MA_ERROR_NONE;
}
-int ma_initialize(void)
+static int __ma_validate_client(bool recorder_privilege, bool client_state, ma_state_e *state)
{
if (0 != __ma_get_feature_enabled()) {
return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
}
- if (0 != __ma_check_recorder_privilege()) {
- return MA_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ if (recorder_privilege) {
+ if (0 != __ma_check_recorder_privilege()) {
+ return MA_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+ }
+ }
+
+ if (client_state) {
+ if (false == ma_client_is_valid(g_ma)) {
+ MA_SLOGE("[ERROR] NOT initialized"); //LCOV_EXCL_LINE
+ return MA_ERROR_INVALID_STATE;
+ }
+
+ ma_state_e ma_state;
+ if (0 != ma_client_get_client_state(g_ma, &ma_state)) {
+ MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
+ return MA_ERROR_INVALID_STATE;
+ }
+ *state = ma_state;
}
+ return MA_ERROR_NONE;
+}
+
+int ma_initialize(void)
+{
+ int ret = MA_ERROR_NONE;
+ ret = __ma_validate_client(true, false, NULL);
+ if (MA_ERROR_NONE != ret) return ret;
+
MA_SLOGE("[Client DEBUG] Initialize"); //LCOV_EXCL_LINE
/* check handle */
int ma_deinitialize(void)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- if (0 != __ma_check_recorder_privilege()) {
- return MA_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
- }
-
MA_SLOGE("[Client DEBUG] Deinitialize"); //LCOV_EXCL_LINE
- if (false == ma_client_is_valid(g_ma)) {
- MA_SLOGE("[ERROR] NOT initialized"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- }
+ ret = __ma_validate_client(true, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
/* check state */
switch (state) {
int ma_prepare(void)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- if (0 != __ma_check_recorder_privilege()) {
- return MA_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
- }
-
MA_SLOGE("[Client DEBUG] Prepare"); //LCOV_EXCL_LINE
+ int ret = MA_ERROR_NONE;
ma_state_e state;
-
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ ret = __ma_validate_client(true, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
/* check state */
if (state != MA_STATE_INITIALIZED) {
int ma_unprepare(void)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- if (0 != __ma_check_recorder_privilege()) {
- return MA_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
- }
-
MA_SLOGE("[Client DEBUG] Unprepare"); //LCOV_EXCL_LINE
- MA_SLOGD("Deleting timer for retry_connection"); //LCOV_EXCL_LINE
- ecore_main_loop_thread_safe_call_async(delete_retry_connection_timer, NULL);
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
-
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
+ ret = __ma_validate_client(true, true, &state);
+ if (MA_ERROR_INVALID_STATE == ret) {
+ MA_SLOGD("Deleting timer for retry_connection"); //LCOV_EXCL_LINE
+ ecore_main_loop_thread_safe_call_async(delete_retry_connection_timer, NULL);
+ } else if (MA_ERROR_NONE != ret) {
+ return ret;
}
/* check state */
int ma_get_state(ma_state_e* state)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- if (0 != __ma_check_recorder_privilege()) {
- return MA_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Get current state"); //LCOV_EXCL_LINE
+ int ret = MA_ERROR_NONE;
+ ma_state_e tmp_state;
+ ret = __ma_validate_client(true, true, &tmp_state);
+ if (MA_ERROR_NONE != ret) return ret;
if (NULL == state) {
MA_SLOGE("[Client ERROR] Invalid parameter"); //LCOV_EXCL_LINE
return MA_ERROR_INVALID_PARAMETER;
}
-
- ma_state_e tmp_state;
- if (0 != ma_client_get_client_state(g_ma, &tmp_state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Get current state"); //LCOV_EXCL_LINE
*state = tmp_state;
int ma_get_current_language(char** language)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- if (0 != __ma_check_recorder_privilege()) {
- return MA_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
- }
+ int ret = MA_ERROR_NONE;
+ ret = __ma_validate_client(true, false, NULL);
+ if (MA_ERROR_NONE != ret) return ret;
MA_SLOGD("[Client DEBUG] Get current language"); //LCOV_EXCL_LINE
-
if (NULL == language) {
MA_SLOGE("[Client ERROR] Invalid parameter"); //LCOV_EXCL_LINE
return MA_ERROR_INVALID_PARAMETER;
}
- int ret = -1;
+ ret = -1;
/* ret = ma_config_mgr_get_default_language(language);
if (0 != ret) {
MA_SLOGE("[Client ERROR] Fail to get current language"); //LCOV_EXCL_LINE
int ma_get_recording_audio_format(int *rate, ma_audio_channel_e *channel, ma_audio_type_e *audio_type)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- if (0 != __ma_check_recorder_privilege()) {
- return MA_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_validate_client(true, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
if (NULL == rate || NULL == channel || NULL == audio_type) {
MA_SLOGE("[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
-
/* check state */
if (state != MA_STATE_READY) {
MA_SLOGE("[ERROR] Invalid State: Current state is not 'READY'"); //LCOV_EXCL_LINE
MA_SLOGI("[Client DEBUG] Get recording audio format"); //LCOV_EXCL_LINE
int count = 0;
- int ret = -1;
int pid = getpid();
+ ret = -1;
do {
ret = ma_dbus_get_recording_audio_format(pid, rate, channel, audio_type);
if (0 != ret) {
int ma_set_state_changed_cb(ma_state_changed_cb callback, void* user_data)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Set Multi-assistant client state changed cb"); //LCOV_EXCL_LINE
-
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
if (NULL == callback) {
MA_SLOGE("[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
-
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Set Multi-assistant client state changed cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
int ma_unset_state_changed_cb(void)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Unset Multi-assistant client state changed cb"); //LCOV_EXCL_LINE
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Unset Multi-assistant client state changed cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
int ma_set_error_cb(ma_error_cb callback, void* user_data)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Set Multi-assistant client error cb"); //LCOV_EXCL_LINE
-
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
if (NULL == callback) {
MA_SLOGE("[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
-
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Set Multi-assistant client error cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
int ma_unset_error_cb(void)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Unset Multi-assistant client error cb"); //LCOV_EXCL_LINE
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Unset Multi-assistant client error cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
int ma_set_language_changed_cb(ma_language_changed_cb callback, void* user_data)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Set Multi-assistant language changed cb"); //LCOV_EXCL_LINE
-
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
if (NULL == callback) {
MA_SLOGE("[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
-
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Set Multi-assistant language changed cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
int ma_unset_language_changed_cb(void)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Unset Multi-assistant language changed cb"); //LCOV_EXCL_LINE
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Unset Multi-assistant language changed cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
int ma_set_audio_streaming_cb(ma_audio_streaming_cb callback, void* user_data)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Set Multi-assistant audio streaming cb"); //LCOV_EXCL_LINE
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
if (NULL == callback) {
MA_SLOGE("[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
-
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Set Multi-assistant audio streaming cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
int ma_unset_audio_streaming_cb(void)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Unset Multi-assistant audio streaming cb"); //LCOV_EXCL_LINE
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Unset Multi-assistant audio streaming cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
int ma_send_asr_result(ma_asr_result_event_e event, const char* asr_result)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- if (0 != __ma_check_recorder_privilege()) {
- return MA_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_validate_client(true, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
if (event < MA_ASR_RESULT_EVENT_PARTIAL_RESULT || event > MA_ASR_RESULT_EVENT_ERROR) {
MA_SLOGE("[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
-
/* check state */
if (state != MA_STATE_READY) {
MA_SLOGE("[ERROR] Invalid State: Current state is not 'READY'"); //LCOV_EXCL_LINE
event, asr_result);
//LCOV_EXCL_STOP
- int ret = -1;
+ ret = -1;
int pid = getpid();
ret = ma_dbus_send_asr_result(pid, event, asr_result);
if (0 != ret) {
int ma_send_result(const char* display_text, const char* utterance_text, const char* result_json)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- if (0 != __ma_check_recorder_privilege()) {
- return MA_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
- }
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ ret = __ma_validate_client(true, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
/* check state */
if (state != MA_STATE_READY) {
MA_SLOGD("[Client DEBUG] Input parameter is NULL."); //LCOV_EXCL_LINE
}
- int ret = -1;
+ ret = -1;
int pid = getpid();
ret = ma_dbus_send_result(pid, display_text, utterance_text, result_json);
if (0 != ret) {
int ma_send_recognition_result(ma_recognition_result_event_e result)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- if (0 != __ma_check_recorder_privilege()) {
- return MA_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
- }
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ ret = __ma_validate_client(true, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
/* check state */
if (state != MA_STATE_READY) {
MA_SLOGE("[Client DEBUG] Send recognition result to the Multi-assistant : %d", result); //LCOV_EXCL_LINE
- int ret = -1;
+ ret = -1;
int pid = getpid();
ret = ma_dbus_send_recognition_result(pid, result);
if (0 != ret) {
int ma_set_active_state_changed_cb(ma_active_state_changed_cb callback, void* user_data)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Set Multi-assistant active state changed cb"); //LCOV_EXCL_LINE
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
if (NULL == callback) {
MA_SLOGE("[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
-
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Set Multi-assistant active state changed cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
int ma_unset_active_state_changed_cb(void)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Unset Multi-assistant active state changed cb"); //LCOV_EXCL_LINE
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Unset Multi-assistant active state changed cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
int ma_start_receiving_audio_streaming_data(ma_audio_streaming_data_type_e type)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- if (0 != __ma_check_recorder_privilege()) {
- return MA_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
- }
-
- ma_state_e state;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_validate_client(true, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
/* check state */
if (state != MA_STATE_READY) {
ma_client_set_preprocessing_result_received(g_ma, false);
#endif
- int ret = -1;
+ ret = -1;
int pid = getpid();
ret = ma_dbus_start_streaming_audio_data(pid, type);
if (0 != ret) {
int ma_stop_receiving_audio_streaming_data(ma_audio_streaming_data_type_e type)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- if (0 != __ma_check_recorder_privilege()) {
- return MA_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
- }
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ ret = __ma_validate_client(true, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
/* check state */
if (state != MA_STATE_READY) {
MA_SLOGE("[Client DEBUG] Send streaming stop request to the Multi-assistant : %d", type); //LCOV_EXCL_LINE
- int ret = -1;
+ ret = -1;
int pid = getpid();
ret = ma_dbus_stop_streaming_audio_data(pid, type);
if (0 != ret) {
int ma_update_voice_feedback_state(ma_voice_feedback_state_e feedback_state)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- if (0 != __ma_check_recorder_privilege()) {
- return MA_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
- }
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ ret = __ma_validate_client(true, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
/* check state */
if (state != MA_STATE_READY) {
MA_SLOGI("[Client DEBUG] Update voice feedback state to the Multi-assistant : %d", feedback_state); //LCOV_EXCL_LINE
- int ret = -1;
+ ret = -1;
int pid = getpid();
ret = ma_dbus_update_voice_feedback_state(pid, feedback_state);
if (0 != ret) {
int ma_send_assistant_specific_command(const char* command)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- if (0 != __ma_check_recorder_privilege()) {
- return MA_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
- }
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ ret = __ma_validate_client(true, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
/* check state */
if (state != MA_STATE_READY) {
MA_SLOGI("[Client DEBUG] Send assistant specific command to the Multi-assistant : %s", command); //LCOV_EXCL_LINE
- int ret = -1;
+ ret = -1;
int pid = getpid();
ret = ma_dbus_send_assistant_specific_command(pid, command);
if (0 != ret) {
int ma_set_wakeup_engine_command_cb(ma_wakeup_engine_command_cb callback, void* user_data)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Set Multi-assistant wakeup engine command cb"); //LCOV_EXCL_LINE
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
if (NULL == callback) {
MA_SLOGE("[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
-
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Set Multi-assistant wakeup engine command cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
int ma_unset_wakeup_engine_command_cb(void)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Unset Multi-assistant wakeup engine command cb"); //LCOV_EXCL_LINE
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Unset Multi-assistant wakeup engine command cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
}
int ma_get_recording_audio_source_type(char** type) {
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
if (NULL == type) {
MA_SLOGE("[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
-
/* check state */
if (state != MA_STATE_READY) {
MA_SLOGE("[ERROR] Invalid State: Current state is not 'READY'"); //LCOV_EXCL_LINE
MA_SLOGI("[Client DEBUG] Get recording audio source type"); //LCOV_EXCL_LINE
int count = 0;
- int ret = -1;
+ ret = -1;
int pid = getpid();
do {
ret = ma_dbus_get_recording_audio_source_type(pid, type);
{
MA_SLOGD("[Manager] Set preprocessing allow mode"); //LCOV_EXCL_LINE
- if (0 != __ma_get_feature_enabled()) {
- MA_SLOGD("@@@ [Manager] not supported"); //LCOV_EXCL_LINE
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- if (0 != __ma_check_recorder_privilege()) {
- return MA_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
- }
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- MA_SLOGD("@@@"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ ret = __ma_validate_client(true, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
/* check state */
if (state != MA_STATE_READY) {
/* change system volume */
int pid = getpid();
- int ret = ma_dbus_set_preprocessing_allow_mode(pid, mode, app_id);
+ ret = ma_dbus_set_preprocessing_allow_mode(pid, mode, app_id);
if (0 != ret) {
MA_SLOGW("[WARNING] retry to set preprocessing allow mode"); //LCOV_EXCL_LINE
} else {
int ma_set_preprocessing_information_changed_cb(ma_preprocessing_information_changed_cb callback, void* user_data)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Set Multi-assistant preprocessing information changed cb"); //LCOV_EXCL_LINE
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
if (NULL == callback) {
MA_SLOGE("[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
-
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Set Multi-assistant preprocessing information changed cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
int ma_unset_preprocessing_information_changed_cb(void)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Unset Multi-assistant preprocessing information changed cb"); //LCOV_EXCL_LINE
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Unset Multi-assistant preprocessing information changed cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
{
MA_SLOGD("[Manager] Send preprocessing result"); //LCOV_EXCL_LINE
- if (0 != __ma_get_feature_enabled()) {
- MA_SLOGD("@@@ [Manager] not supported"); //LCOV_EXCL_LINE
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- if (0 != __ma_check_recorder_privilege()) {
- return MA_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
- }
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- MA_SLOGD("@@@"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ ret = __ma_validate_client(true, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
if (state != MA_STATE_READY) {
MA_SLOGE("[ERROR] Invalid State: Current state is not 'READY', state(%d)", state); //LCOV_EXCL_LINE
/* Send preprocessing result */
int pid = getpid();
- int ret = ma_dbus_send_preprocessing_result(pid, is_success);
+ ret = ma_dbus_send_preprocessing_result(pid, is_success);
if (0 != ret) {
MA_SLOGW("[WARNING] retry to send preprocessing result"); //LCOV_EXCL_LINE
} else {
{
MA_SLOGD("[Manager] Set wake word audio require flag"); //LCOV_EXCL_LINE
- if (0 != __ma_get_feature_enabled()) {
- MA_SLOGD("@@@ [Manager] not supported"); //LCOV_EXCL_LINE
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- MA_SLOGD("@@@"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
if (state != MA_STATE_READY) {
MA_SLOGE("[ERROR] Invalid State: Current state is not 'READY', state(%d)", state); //LCOV_EXCL_LINE
/* Set wake word audio require flag */
int pid = getpid();
- int ret = ma_dbus_set_wake_word_audio_require_flag(pid, require);
+ ret = ma_dbus_set_wake_word_audio_require_flag(pid, require);
if (0 != ret) {
MA_SLOGW("[WARNING] retry to set wake word audio require flag"); //LCOV_EXCL_LINE
} else {
int ma_set_audio_streaming_data_section_changed_cb(ma_audio_streaming_data_section_changed_cb callback, void* user_data)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Set Multi-assistant audio streaming data section changed cb"); //LCOV_EXCL_LINE
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
if (NULL == callback) {
MA_SLOGE("[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
-
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Set Multi-assistant audio streaming data section changed cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
int ma_unset_audio_streaming_data_section_changed_cb(void)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Unset Multi-assistant audio streaming data section changed cb"); //LCOV_EXCL_LINE
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Unset Multi-assistant audio streaming data section changed cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
//LCOV_EXCL_START
int ma_set_preprocessing_result_received_cb(ma_preprocessing_result_received_cb callback, void* user_data)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Set Multi-assistant preprocessing result received cb"); //LCOV_EXCL_LINE
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
if (NULL == callback) {
MA_SLOGE("[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
-
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Set Multi-assistant preprocessing result received cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
int ma_unset_preprocessing_result_received_cb(void)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Unset Multi-assistant preprocessing result received cb"); //LCOV_EXCL_LINE
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Unset Multi-assistant preprocessing result received cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
{
MA_SLOGD("[Manager] Set assistant wakeup language"); //LCOV_EXCL_LINE
- if (0 != __ma_get_feature_enabled()) {
- MA_SLOGD("@@@ [Manager] not supported"); //LCOV_EXCL_LINE
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
if (NULL == language) {
MA_SLOGE("[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- MA_SLOGD("@@@"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
-
if (state != MA_STATE_READY) {
MA_SLOGE("[ERROR] Invalid State: Current state is not 'READY', state(%d)", state); //LCOV_EXCL_LINE
MA_SLOGD("@@@"); //LCOV_EXCL_LINE
/* Set assistant language */
int pid = getpid();
- int ret = ma_dbus_set_assistant_wakeup_language(pid, language);
+ ret = ma_dbus_set_assistant_wakeup_language(pid, language);
if (0 != ret) {
MA_SLOGW("[WARNING] Failed to set assistant wakeup language"); //LCOV_EXCL_LINE
} else {
int ma_set_service_state_changed_cb(ma_service_state_changed_cb callback, void* user_data)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Set Multi-assistant service state changed cb"); //LCOV_EXCL_LINE
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
if (NULL == callback) {
MA_SLOGE("[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
-
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Set Multi-assistant service state changed cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
int ma_unset_service_state_changed_cb(void)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Unset Multi-assistant service state changed cb"); //LCOV_EXCL_LINE
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Unset Multi-assistant service state changed cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
int ma_set_voice_key_status_changed_cb(ma_voice_key_status_changed_cb callback, void* user_data)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Set Multi-assistant voice key status changed cb"); //LCOV_EXCL_LINE
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
if (NULL == callback) {
MA_SLOGE("[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
-
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Set Multi-assistant voice key status changed cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
int ma_unset_voice_key_status_changed_cb(void)
{
- if (0 != __ma_get_feature_enabled()) {
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
-
- MA_SLOGD("[Client DEBUG] Unset Multi-assistant voice key status changed cb"); //LCOV_EXCL_LINE
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MA_SLOGD("[Client DEBUG] Unset Multi-assistant voice key status changed cb"); //LCOV_EXCL_LINE
/* check state */
if (state != MA_STATE_INITIALIZED) {
int ma_add_wake_word(const char* wake_word, const char *language) {
MA_SLOGD("[Manager] Add wake word"); //LCOV_EXCL_LINE
- if (0 != __ma_get_feature_enabled()) {
- MA_SLOGD("@@@ [Manager] not supported"); //LCOV_EXCL_LINE
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
if (NULL == wake_word || NULL == language) {
MA_SLOGE("[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- MA_SLOGD("@@@"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
-
if (state != MA_STATE_READY) {
MA_SLOGE("[ERROR] Invalid State: Current state is not 'READY', state(%d)", state); //LCOV_EXCL_LINE
MA_SLOGD("@@@"); //LCOV_EXCL_LINE
/* Add wake word */
int pid = getpid();
- int ret = ma_dbus_add_wake_word(pid, wake_word, language);
+ ret = ma_dbus_add_wake_word(pid, wake_word, language);
if (0 != ret) {
MA_SLOGW("[WARNING] Failed to add wake word"); //LCOV_EXCL_LINE
} else {
int ma_remove_wake_word(const char* wake_word, const char *language) {
MA_SLOGD("[Manager] Remove wake word"); //LCOV_EXCL_LINE
- if (0 != __ma_get_feature_enabled()) {
- MA_SLOGD("@@@ [Manager] not supported"); //LCOV_EXCL_LINE
- return MA_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
if (NULL == wake_word || NULL == language) {
MA_SLOGE("[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
- if (0 != ma_client_get_client_state(g_ma, &state)) {
- MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- MA_SLOGD("@@@"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
-
if (state != MA_STATE_READY) {
MA_SLOGE("[ERROR] Invalid State: Current state is not 'READY', state(%d)", state); //LCOV_EXCL_LINE
MA_SLOGD("@@@"); //LCOV_EXCL_LINE
/* Remove wake word */
int pid = getpid();
- int ret = ma_dbus_remove_wake_word(pid, wake_word, language);
+ ret = ma_dbus_remove_wake_word(pid, wake_word, language);
if (0 != ret) {
MA_SLOGW("[WARNING] Failed to remove wake word"); //LCOV_EXCL_LINE
} else {
return MA_ERROR_NONE;
}
-
-
-int ma_ui_initialize(void)
+static int __ma_ui_validate_client(bool privilege, bool client_state, ma_state_e *state)
{
if (0 != __ma_ui_get_feature_enabled()) {
MAUI_SLOGD("[UI] not supported");
return MA_ERROR_NOT_SUPPORTED;
}
- if (0 != __ma_ui_check_privilege()) {
- return MA_ERROR_PERMISSION_DENIED;
+ if (privilege) {
+ if (0 != __ma_ui_check_privilege()) {
+ return MA_ERROR_PERMISSION_DENIED;
+ }
}
- MAUI_SLOGE("[UI] Initialize");
+ if (client_state) {
+ if (false == ma_ui_client_is_valid(g_ma_ui)) {
+ MAUI_SLOGE("[ERROR] NOT initialized");
+ return MA_ERROR_INVALID_STATE;
+ }
+
+ ma_state_e ma_ui_state;
+ if (0 != ma_ui_client_get_client_state(g_ma_ui, &ma_ui_state)) {
+ MAUI_SLOGE("[UI ERROR] A handle is not available");
+ return MA_ERROR_INVALID_STATE;
+ }
+ *state = ma_ui_state;
+ }
+
+ return MA_ERROR_NONE;
+}
+
+int ma_ui_initialize(void)
+{
+ int ret = MA_ERROR_NONE;
+ ret = __ma_ui_validate_client(true, false, NULL);
+ if (MA_ERROR_NONE != ret) return ret;
+ MAUI_SLOGE("[UI] Initialize");
/* check handle */
if (true == ma_ui_client_is_valid(g_ma_ui)) {
int ma_ui_deinitialze(void)
{
- if (0 != __ma_ui_get_feature_enabled()) {
- MAUI_SLOGD("@@@ [UI] not supported");
- return MA_ERROR_NOT_SUPPORTED;
- }
-
- if (0 != __ma_ui_check_privilege()) {
- return MA_ERROR_PERMISSION_DENIED;
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_ui_validate_client(true, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
MAUI_SLOGE("@@@ [UI] Deinitialize");
- if (false == ma_ui_client_is_valid(g_ma_ui)) {
- MAUI_SLOGE("[ERROR] NOT initialized");
- return MA_ERROR_INVALID_STATE;
- }
-
- ma_state_e state;
- if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
- MAUI_SLOGE("[UI ERROR] A handle is not available");
- }
-
/* check state */
switch (state) {
case MA_STATE_READY:
int ma_ui_prepare(void)
{
- if (0 != __ma_ui_get_feature_enabled()) {
- MAUI_SLOGD("@@@ [UI] not supported");
- return MA_ERROR_NOT_SUPPORTED;
- }
-
- if (0 != __ma_ui_check_privilege()) {
- return MA_ERROR_PERMISSION_DENIED;
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_ui_validate_client(true, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
MAUI_SLOGD("[UI] Prepare");
- ma_state_e state;
- if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
- MAUI_SLOGE("[UI ERROR] A handle is not available");
- return MA_ERROR_INVALID_STATE;
- }
-
/* check state */
if (MA_STATE_INITIALIZED != state) {
MAUI_SLOGE("[UI ERROR] Invalid state: Current state is not 'Initialized' (%d)", state);
int ma_ui_unprepare(void)
{
- if (0 != __ma_ui_get_feature_enabled()) {
- MAUI_SLOGD("@@@ [UI] not supported");
- return MA_ERROR_NOT_SUPPORTED;
- }
-
- if (0 != __ma_ui_check_privilege()) {
- return MA_ERROR_PERMISSION_DENIED;
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_ui_validate_client(true, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
MAUI_SLOGD("[UI] Unprepare");
- ma_state_e state;
- if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
- MAUI_SLOGE("[UI ERROR] A handle is not available");
- return MA_ERROR_INVALID_STATE;
- }
-
/* check state */
if (MA_STATE_READY != state) {
MAUI_SLOGE("[UI ERROR] Invalid state: Current state is not 'READY' (%d)", state);
int ma_ui_get_state(ma_state_e* state)
{
- if (0 != __ma_ui_get_feature_enabled()) {
- MAUI_SLOGD("@@@ [UI] not supported");
- return MA_ERROR_NOT_SUPPORTED;
- }
-
- if (0 != __ma_ui_check_privilege()) {
- return MA_ERROR_PERMISSION_DENIED;
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e tmp_state;
+ ret = __ma_ui_validate_client(true, true, &tmp_state);
+ if (MA_ERROR_NONE != ret) return ret;
MAUI_SLOGD("[UI DEBUG] Get current state");
return MA_ERROR_INVALID_PARAMETER;
}
-
- ma_state_e tmp_state;
- if (0 != ma_ui_client_get_client_state(g_ma_ui, &tmp_state)) {
- MAUI_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
-
*state = tmp_state;
return MA_ERROR_NONE;
int ma_ui_foreach_assistant_info(ma_ui_assistant_info_cb callback, void* user_data)
{
- if (0 != __ma_ui_get_feature_enabled()) {
- MAUI_SLOGD("@@@ [UI] not supported");
- return MA_ERROR_NOT_SUPPORTED;
- }
-
- if (0 != __ma_ui_check_privilege()) {
- return MA_ERROR_PERMISSION_DENIED;
- }
+ int ret = MA_ERROR_NONE;
+ ret = __ma_ui_validate_client(true, false, NULL);
+ if (MA_ERROR_NONE != ret) return ret;
MAUI_SLOGD("[UI] Get foreach assistant info");
return MA_ERROR_INVALID_PARAMETER;
}
- int ret = -1;
+ ret = -1;
ret = ma_config_mgr_get_assistant_info(callback, user_data);
if (0 != ret) {
MAUI_SLOGE("[UI ERROR] Fail to get assistant info");
int ma_ui_set_default_assistant(const char* app_id)
{
- if (0 != __ma_ui_get_feature_enabled()) {
- MAUI_SLOGD("@@@ [UI] not supported");
- return MA_ERROR_NOT_SUPPORTED;
- }
-
- if (0 != __ma_ui_check_privilege()) {
- return MA_ERROR_PERMISSION_DENIED;
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_ui_validate_client(true, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
MAUI_SLOGD("[UI] Set a default assistant");
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
- if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
- MAUI_SLOGE("[UI ERROR] A handle is not available");
- return MA_ERROR_INVALID_STATE;
- }
-
/* check state */
if (MA_STATE_INITIALIZED!= state) {
MAUI_SLOGE("[UI ERROR] Invalid state: Current state is not 'Initialized' (%d)", state);
return MA_ERROR_INVALID_STATE;
}
- int ret = -1;
+ ret = -1;
/* ret = ma_config_mgr_set_default_assistant(app_id);
if (0 != ret) {
MAUI_SLOGE("[UI ERROR] Fail to set default assistant")_;
int ma_ui_change_assistant(const char* app_id)
{
- if (0 != __ma_ui_get_feature_enabled()) {
- MAUI_SLOGD("@@@ [UI] not supported");
- return MA_ERROR_NOT_SUPPORTED;
- }
-
- if (0 != __ma_ui_check_privilege()) {
- return MA_ERROR_PERMISSION_DENIED;
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_ui_validate_client(true, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
MAUI_SLOGD("[UI] Change a assistant");
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
- if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
- MAUI_SLOGE("[UI ERROR] A handle is not available");
- return MA_ERROR_INVALID_STATE;
- }
-
/* check state */
if (MA_STATE_READY != state) {
MAUI_SLOGE("[UI ERROR] Invalid state: Current state is not 'Initialized' (%d)", state);
return MA_ERROR_INVALID_STATE;
}
- int ret = -1;
+ ret = -1;
ma_ui_dbus_request_change_assistant(app_id);
/* ret = ma_config_mgr_change_assistant(app_id);
if (0 != ret) {
int ma_ui_set_state_changed_cb(ma_state_changed_cb callback, void* user_data)
{
- if (0 != __ma_ui_get_feature_enabled()) {
- MAUI_SLOGD("@@@ [UI] not supported");
- return MA_ERROR_NOT_SUPPORTED;
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_ui_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
MAUI_SLOGD("[Client DEBUG] Set Multi-assistant client state changed cb");
-
if (NULL == callback) {
MAUI_SLOGE("[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
-
- if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
- MAUI_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
-
/* check state */
if (state != MA_STATE_INITIALIZED) {
MAUI_SLOGE("[ERROR] Invalid State: Current state is not 'Initialized'"); //LCOV_EXCL_LINE
int ma_ui_unset_state_changed_cb(void)
{
- if (0 != __ma_ui_get_feature_enabled()) {
- MAUI_SLOGD("@@@ [UI] not supported");
- return MA_ERROR_NOT_SUPPORTED;
- }
-
- MAUI_SLOGD("[UI DEBUG] Unset Multi-assistant client state changed cb");
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
+ ret = __ma_ui_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
- if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
- MAUI_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MAUI_SLOGD("[UI DEBUG] Unset Multi-assistant client state changed cb");
/* check state */
if (state != MA_STATE_INITIALIZED) {
int ma_ui_set_error_cb(ma_error_cb callback, void* user_data)
{
- if (0 != __ma_ui_get_feature_enabled()) {
- MAUI_SLOGD("@@@ [UI] not supported");
- return MA_ERROR_NOT_SUPPORTED;
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_ui_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
MAUI_SLOGD("[Client DEBUG] Set Multi-assistant UI client error cb");
-
if (NULL == callback) {
MAUI_SLOGE("[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
-
- if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
- MAUI_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
-
/* check state */
if (state != MA_STATE_INITIALIZED) {
MAUI_SLOGE("[ERROR] Invalid State: Current state is not 'Initialized'"); //LCOV_EXCL_LINE
int ma_ui_unset_error_cb(void)
{
- if (0 != __ma_ui_get_feature_enabled()) {
- MAUI_SLOGD("@@@ [UI] not supported");
- return MA_ERROR_NOT_SUPPORTED;
- }
-
- MAUI_SLOGD("[UI DEBUG] Unset Multi-assistant UI client error cb");
-
+ int ret = MA_ERROR_NONE;
ma_state_e state;
+ ret = __ma_ui_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
- if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
- MAUI_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
- return MA_ERROR_INVALID_STATE;
- }
+ MAUI_SLOGD("[UI DEBUG] Unset Multi-assistant UI client error cb");
/* check state */
if (state != MA_STATE_INITIALIZED) {
int ma_ui_set_asr_result_cb(ma_ui_asr_result_cb callback, void* user_data)
{
- if (0 != __ma_ui_get_feature_enabled()) {
- MAUI_SLOGD("@@@ [UI] not supported");
- return MA_ERROR_NOT_SUPPORTED;
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_ui_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
MAUI_SLOGD("[UI] Set a ASR result callback");
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
- if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
- MAUI_SLOGE("[UI ERROR] A handle is not available");
- return MA_ERROR_INVALID_STATE;
- }
-
/* check state */
if (MA_STATE_INITIALIZED!= state) {
MAUI_SLOGE("[UI ERROR] Invalid state: Current state is not 'Initialized' (%d)", state);
int ma_ui_unset_asr_result_cb(void)
{
- if (0 != __ma_ui_get_feature_enabled()) {
- MAUI_SLOGD("@@@ [UI] not supported");
- return MA_ERROR_NOT_SUPPORTED;
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_ui_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
MAUI_SLOGD("[UI] Set a default assistant");
- ma_state_e state;
- if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
- MAUI_SLOGE("[UI ERROR] A handle is not available");
- return MA_ERROR_INVALID_STATE;
- }
-
/* check state */
if (MA_STATE_INITIALIZED!= state) {
MAUI_SLOGE("[UI ERROR] Invalid state: Current state is not 'Initialized' (%d)", state);
int ma_ui_set_result_cb(ma_ui_result_cb callback, void* user_data)
{
- if (0 != __ma_ui_get_feature_enabled()) {
- MAUI_SLOGD("@@@ [UI] not supported");
- return MA_ERROR_NOT_SUPPORTED;
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_ui_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
MAUI_SLOGD("[UI] Set a default assistant");
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
- if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
- MAUI_SLOGE("[UI ERROR] A handle is not available");
- return MA_ERROR_INVALID_STATE;
- }
-
/* check state */
if (MA_STATE_INITIALIZED!= state) {
MAUI_SLOGE("[UI ERROR] Invalid state: Current state is not 'Initialized' (%d)", state);
int ma_ui_unset_result_cb(void)
{
- if (0 != __ma_ui_get_feature_enabled()) {
- MAUI_SLOGD("@@@ [UI] not supported");
- return MA_ERROR_NOT_SUPPORTED;
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_ui_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
MAUI_SLOGD("[UI] Set a default assistant");
- ma_state_e state;
- if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
- MAUI_SLOGE("[UI ERROR] A handle is not available");
- return MA_ERROR_INVALID_STATE;
- }
-
/* check state */
if (MA_STATE_INITIALIZED!= state) {
MAUI_SLOGE("[UI ERROR] Invalid state: Current state is not 'Initialized' (%d)", state);
int ma_ui_set_change_assistant_cb(ma_ui_change_assistant_cb callback, void* user_data)
{
- if (0 != __ma_ui_get_feature_enabled()) {
- MAUI_SLOGD("@@@ [UI] not supported");
- return MA_ERROR_NOT_SUPPORTED;
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_ui_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
MAUI_SLOGD("[UI] Set a default assistant");
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
- if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
- MAUI_SLOGE("[UI ERROR] A handle is not available");
- return MA_ERROR_INVALID_STATE;
- }
-
/* check state */
if (MA_STATE_INITIALIZED!= state) {
MAUI_SLOGE("[UI ERROR] Invalid state: Current state is not 'Initialized' (%d)", state);
int ma_ui_unset_change_assistant_cb(void)
{
- if (0 != __ma_ui_get_feature_enabled()) {
- MAUI_SLOGD("@@@ [UI] not supported");
- return MA_ERROR_NOT_SUPPORTED;
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_ui_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
MAUI_SLOGD("[UI] Set a default assistant");
- ma_state_e state;
- if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
- MAUI_SLOGE("[UI ERROR] A handle is not available");
- return MA_ERROR_INVALID_STATE;
- }
-
/* check state */
if (MA_STATE_INITIALIZED!= state) {
MAUI_SLOGE("[UI ERROR] Invalid state: Current state is not 'Initialized' (%d)", state);
int ma_ui_set_recognition_result_cb(ma_ui_recognition_result_cb callback, void* user_data)
{
- if (0 != __ma_ui_get_feature_enabled()) {
- MAUI_SLOGD("@@@ [UI] not supported");
- return MA_ERROR_NOT_SUPPORTED;
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_ui_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
if (NULL == callback) {
MAUI_SLOGE("[UI ERROR] Invalid parameter");
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
- if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
- MAUI_SLOGE("[UI ERROR] A handle is not available");
- return MA_ERROR_INVALID_STATE;
- }
-
/* check state */
if (MA_STATE_INITIALIZED!= state) {
MAUI_SLOGE("[UI ERROR] Invalid state: Current state is not 'Initialized' (%d)", state);
int ma_ui_unset_recognition_result_cb(void)
{
- if (0 != __ma_ui_get_feature_enabled()) {
- MAUI_SLOGD("@@@ [UI] not supported");
- return MA_ERROR_NOT_SUPPORTED;
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_ui_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
MAUI_SLOGD("[UI] Set a default assistant");
- ma_state_e state;
- if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
- MAUI_SLOGE("[UI ERROR] A handle is not available");
- return MA_ERROR_INVALID_STATE;
- }
-
/* check state */
if (MA_STATE_INITIALIZED!= state) {
MAUI_SLOGE("[UI ERROR] Invalid state: Current state is not 'Initialized' (%d)", state);
int ma_ui_set_enable_common_ui_cb(ma_ui_enable_common_ui_cb callback, void* user_data)
{
- if (0 != __ma_ui_get_feature_enabled()) {
- MAUI_SLOGD("@@@ [UI] not supported");
- return MA_ERROR_NOT_SUPPORTED;
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_ui_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
if (NULL == callback) {
MAUI_SLOGE("[UI ERROR] Invalid parameter");
return MA_ERROR_INVALID_PARAMETER;
}
- ma_state_e state;
- if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
- MAUI_SLOGE("[UI ERROR] A handle is not available");
- return MA_ERROR_INVALID_STATE;
- }
-
/* check state */
if (MA_STATE_INITIALIZED != state) {
MAUI_SLOGE("[UI ERROR] Invalid state: Current state is not 'Initialized' (%d)", state);
int ma_ui_unset_enable_common_ui_cb(void)
{
- if (0 != __ma_ui_get_feature_enabled()) {
- MAUI_SLOGD("@@@ [UI] not supported");
- return MA_ERROR_NOT_SUPPORTED;
- }
+ int ret = MA_ERROR_NONE;
+ ma_state_e state;
+ ret = __ma_ui_validate_client(false, true, &state);
+ if (MA_ERROR_NONE != ret) return ret;
MAUI_SLOGD("[UI] Set a default assistant");
- ma_state_e state;
- if (0 != ma_ui_client_get_client_state(g_ma_ui, &state)) {
- MAUI_SLOGE("[UI ERROR] A handle is not available");
- return MA_ERROR_INVALID_STATE;
- }
-
/* check state */
if (MA_STATE_INITIALIZED != state) {
MAUI_SLOGE("[UI ERROR] Invalid state: Current state is not 'Initialized' (%d)", state);