From: Ji-hoon Lee Date: Wed, 25 Sep 2019 04:28:39 +0000 (+0900) Subject: Update required privileges for API review X-Git-Tag: submit/tizen/20191002.080047~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8408f6c436ffc87ee56394b271f6d29119f7956a;p=platform%2Fcore%2Fuifw%2Fmulti-assistant.git Update required privileges for API review Change-Id: I97573fcdaa23aa53eafa83ec52ecee782dd14ad1 --- diff --git a/client/ma.c b/client/ma.c index d00c49f..217ab1a 100644 --- a/client/ma.c +++ b/client/ma.c @@ -48,7 +48,8 @@ static ma_h g_ma = NULL; static int g_feature_enabled = -1; -static int g_privilege_allowed = -1; +static int g_recorder_privilege_allowed = -1; +static int g_volume_set_privilege_allowed = -1; static cynara *p_cynara = NULL; static void __ma_notify_state_changed(void* data); @@ -133,31 +134,59 @@ static void __check_privilege_deinitialize() p_cynara = NULL; } -static int __ma_check_privilege() +static int __ma_check_recorder_privilege() { char uid[16]; - if (0 == g_privilege_allowed) { + if (0 == g_recorder_privilege_allowed) { //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_MAC, "[ERROR] Permission is denied"); + SLOG(LOG_ERROR, TAG_MAC, "[ERROR] Permission for recording is denied"); return MA_ERROR_PERMISSION_DENIED; //LCOV_EXCL_STOP - } else if (-1 == g_privilege_allowed) { + } else if (-1 == g_recorder_privilege_allowed) { if (false == __check_privilege_initialize()) { SLOG(LOG_ERROR, TAG_MAC, "[ERROR] privilege initialize is failed"); //LCOV_EXCL_LINE return MA_ERROR_PERMISSION_DENIED; } snprintf(uid, 16, "%d", getuid()); - if (false == __check_privilege(uid, MA_PRIVILEGE)) { - SLOG(LOG_ERROR, TAG_MAC, "[ERROR] Permission is denied"); - g_privilege_allowed = 0; + if (false == __check_privilege(uid, MA_RECORDER_PRIVILEGE)) { + SLOG(LOG_ERROR, TAG_MAC, "[ERROR] Permission for recording is denied"); + g_recorder_privilege_allowed = 0; __check_privilege_deinitialize(); return MA_ERROR_PERMISSION_DENIED; } __check_privilege_deinitialize(); } - g_privilege_allowed = 1; + g_recorder_privilege_allowed = 1; + return MA_ERROR_NONE; +} + +static int __ma_check_volume_set_privilege() +{ + char uid[16]; + + if (0 == g_volume_set_privilege_allowed) { + //LCOV_EXCL_START + SLOG(LOG_ERROR, TAG_MAC, "[ERROR] Permission for volume set is denied"); + return MA_ERROR_PERMISSION_DENIED; + //LCOV_EXCL_STOP + } else if (-1 == g_volume_set_privilege_allowed) { + if (false == __check_privilege_initialize()) { + SLOG(LOG_ERROR, TAG_MAC, "[ERROR] privilege initialize is failed"); //LCOV_EXCL_LINE + return MA_ERROR_PERMISSION_DENIED; + } + snprintf(uid, 16, "%d", getuid()); + if (false == __check_privilege(uid, MA_VOLUME_SET_PRIVILEGE)) { + SLOG(LOG_ERROR, TAG_MAC, "[ERROR] Permission for volume set is denied"); + g_volume_set_privilege_allowed = 0; + __check_privilege_deinitialize(); + return MA_ERROR_PERMISSION_DENIED; + } + __check_privilege_deinitialize(); + } + + g_volume_set_privilege_allowed = 1; return MA_ERROR_NONE; } @@ -167,7 +196,7 @@ int ma_initialize(void) return MA_ERROR_NOT_SUPPORTED; } - if (0 != __ma_check_privilege()) { + if (0 != __ma_check_recorder_privilege()) { return MA_ERROR_PERMISSION_DENIED; } @@ -229,7 +258,7 @@ int ma_deinitialize(void) return MA_ERROR_NOT_SUPPORTED; } - if (0 != __ma_check_privilege()) { + if (0 != __ma_check_recorder_privilege()) { return MA_ERROR_PERMISSION_DENIED; } @@ -390,7 +419,7 @@ int ma_prepare(void) return MA_ERROR_NOT_SUPPORTED; } - if (0 != __ma_check_privilege()) { + if (0 != __ma_check_recorder_privilege()) { return MA_ERROR_PERMISSION_DENIED; } @@ -421,7 +450,7 @@ int ma_unprepare(void) return MA_ERROR_NOT_SUPPORTED; } - if (0 != __ma_check_privilege()) { + if (0 != __ma_check_recorder_privilege()) { return MA_ERROR_PERMISSION_DENIED; } @@ -645,7 +674,7 @@ int ma_get_state(ma_state_e* state) return MA_ERROR_NOT_SUPPORTED; } - if (0 != __ma_check_privilege()) { + if (0 != __ma_check_recorder_privilege()) { return MA_ERROR_PERMISSION_DENIED; } @@ -674,7 +703,7 @@ int ma_get_current_language(char** language) return MA_ERROR_NOT_SUPPORTED; } - if (0 != __ma_check_privilege()) { + if (0 != __ma_check_recorder_privilege()) { return MA_ERROR_PERMISSION_DENIED; } @@ -706,7 +735,7 @@ int ma_get_recording_audio_format(int *rate, ma_audio_channel_e *channel, ma_aud return MA_ERROR_NOT_SUPPORTED; } - if (0 != __ma_check_privilege()) { + if (0 != __ma_check_recorder_privilege()) { return MA_ERROR_PERMISSION_DENIED; } @@ -990,7 +1019,7 @@ int ma_send_asr_result(ma_asr_result_event_e event, const char* asr_result) return MA_ERROR_NOT_SUPPORTED; } - if (0 != __ma_check_privilege()) { + if (0 != __ma_check_recorder_privilege()) { return MA_ERROR_PERMISSION_DENIED; } @@ -1036,7 +1065,7 @@ int ma_send_result(const char* display_text, const char* utterance_text, const c return MA_ERROR_NOT_SUPPORTED; } - if (0 != __ma_check_privilege()) { + if (0 != __ma_check_recorder_privilege()) { return MA_ERROR_PERMISSION_DENIED; } @@ -1076,7 +1105,7 @@ int ma_send_recognition_result(ma_recognition_result_event_e result) return MA_ERROR_NOT_SUPPORTED; } - if (0 != __ma_check_privilege()) { + if (0 != __ma_check_recorder_privilege()) { return MA_ERROR_PERMISSION_DENIED; } @@ -1169,7 +1198,7 @@ int ma_start_receiving_audio_streaming_data(ma_audio_streaming_data_type_e type) return MA_ERROR_NOT_SUPPORTED; } - if (0 != __ma_check_privilege()) { + if (0 != __ma_check_recorder_privilege()) { return MA_ERROR_PERMISSION_DENIED; } @@ -1205,7 +1234,7 @@ int ma_stop_receiving_audio_streaming_data(ma_audio_streaming_data_type_e type) return MA_ERROR_NOT_SUPPORTED; } - if (0 != __ma_check_privilege()) { + if (0 != __ma_check_recorder_privilege()) { return MA_ERROR_PERMISSION_DENIED; } @@ -1241,7 +1270,7 @@ int ma_update_voice_feedback_state(ma_voice_feedback_state_e feedback_state) return MA_ERROR_NOT_SUPPORTED; } - if (0 != __ma_check_privilege()) { + if (0 != __ma_check_recorder_privilege()) { return MA_ERROR_PERMISSION_DENIED; } @@ -1277,7 +1306,7 @@ int ma_send_assistant_specific_command(const char* command) return MA_ERROR_NOT_SUPPORTED; } - if (0 != __ma_check_privilege()) { + if (0 != __ma_check_recorder_privilege()) { return MA_ERROR_PERMISSION_DENIED; } @@ -1455,10 +1484,6 @@ int ma_get_recording_audio_source_type(char** type) { return MA_ERROR_NOT_SUPPORTED; } - if (0 != __ma_check_privilege()) { - return MA_ERROR_PERMISSION_DENIED; - } - if (NULL == type) { SLOG(LOG_ERROR, TAG_MAC, "[ERROR] Invalid parameter"); return MA_ERROR_INVALID_PARAMETER; @@ -1511,7 +1536,7 @@ int ma_set_background_volume(double ratio) return MA_ERROR_NOT_SUPPORTED; } - if (0 != __ma_check_privilege()) { + if (0 != __ma_check_volume_set_privilege()) { return MA_ERROR_PERMISSION_DENIED; } @@ -1549,7 +1574,7 @@ int ma_set_preprocessing_allow_mode(ma_preprocessing_allow_mode_e mode, const ch return MA_ERROR_NOT_SUPPORTED; } - if (0 != __ma_check_privilege()) { + if (0 != __ma_check_recorder_privilege()) { return MA_ERROR_PERMISSION_DENIED; } @@ -1644,7 +1669,7 @@ int ma_send_preprocessing_result(bool is_success) return MA_ERROR_NOT_SUPPORTED; } - if (0 != __ma_check_privilege()) { + if (0 != __ma_check_recorder_privilege()) { return MA_ERROR_PERMISSION_DENIED; } @@ -1670,4 +1695,4 @@ int ma_send_preprocessing_result(bool is_success) SLOG(LOG_DEBUG, TAG_MAC, "[DEBUG] Success to send"); } return ret; -} \ No newline at end of file +} diff --git a/client/ma_ui.c b/client/ma_ui.c index 53f4ab4..6937015 100644 --- a/client/ma_ui.c +++ b/client/ma_ui.c @@ -139,7 +139,7 @@ static int __ma_ui_check_privilege() return MA_ERROR_PERMISSION_DENIED; } snprintf(uid, 16, "%d", getuid()); - if (false == __check_privilege(uid, MA_PRIVILEGE)) { + if (false == __check_privilege(uid, MA_RECORDER_PRIVILEGE)) { SLOG(LOG_ERROR, TAG_MAUI, "[ERROR] Permission is denied"); g_privilege_allowed = 0; __check_privilege_deinitialize(); diff --git a/common/ma_defs.h b/common/ma_defs.h index f5d59aa..5d00bbf 100644 --- a/common/ma_defs.h +++ b/common/ma_defs.h @@ -33,7 +33,8 @@ extern "C" #define MA_FEATURE_PATH "tizen.org/feature/multi_assistant" #define MA_MIC_FEATURE_PATH "tizen.org/feature/microphone" -#define MA_PRIVILEGE "http://tizen.org/privilege/recorder" +#define MA_RECORDER_PRIVILEGE "http://tizen.org/privilege/recorder" +#define MA_VOLUME_SET_PRIVILEGE "http://tizen.org/privilege/volume.set" #define MA_DEFAULT_BASE tzplatform_mkpath(tzplatform_getid("TZ_SYS_RO_SHARE"), "multiassistant/ma/1.0") #define MA_DEFAULT_CONFIG tzplatform_mkpath(tzplatform_getid("TZ_SYS_RO_SHARE"), "multiassistant/ma/1.0/ma-config.xml") diff --git a/include/multi_assistant.h b/include/multi_assistant.h index 6f6d894..9d1103d 100644 --- a/include/multi_assistant.h +++ b/include/multi_assistant.h @@ -531,7 +531,6 @@ int ma_assistant_info_get_enabled_status(ma_assistant_info_h handle, bool* statu * @brief Gets the recording audio source type. * @since_tizen 5.5 * @privlevel public - * @privilege %http://tizen.org/privilege/recorder * * @remarks You must release @a type using free(). * @param[out] type The audio source type @@ -539,7 +538,6 @@ int ma_assistant_info_get_enabled_status(ma_assistant_info_h handle, bool* statu * @return @c 0 on success, otherwise a negative error value * @retval #MA_ERROR_NONE Successful * @retval #MA_ERROR_NOT_SUPPORTED Not supported - * @retval #MA_ERROR_PERMISSION_DENIED Permission denied * @retval #MA_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MA_ERROR_INVALID_STATE Invalid state * @retval #MA_ERROR_OPERATION_FAILED Operation failed @@ -552,7 +550,7 @@ int ma_get_recording_audio_source_type(char** type); * @brief Sets the background volume. * @since_tizen 5.5 * @privlevel public - * @privilege %http://tizen.org/privilege/recorder + * @privilege %http://tizen.org/privilege/volume.set * * @remarks The @a ratio must be a value between 0.0 and 1.0 (inclusive). * @param[in] ratio The volume ratio to be set