Update required privileges for API review 51/214651/2
authorJi-hoon Lee <dalton.lee@samsung.com>
Wed, 25 Sep 2019 04:28:39 +0000 (13:28 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Thu, 26 Sep 2019 02:07:21 +0000 (11:07 +0900)
Change-Id: I97573fcdaa23aa53eafa83ec52ecee782dd14ad1

client/ma.c
client/ma_ui.c
common/ma_defs.h
include/multi_assistant.h

index d00c49f3a2d68b09392f635a12a9b45562811ae3..217ab1a5e6e38e9846e88073d5b8bbd0088056ab 100644 (file)
@@ -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
+}
index 53f4ab4cdf319d12fa66e7ea9151f074bb5cc46d..6937015b658b265bd9348d430f08c7ee34467208 100644 (file)
@@ -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();
index f5d59aa99c619ef199bcfa9f0f973a7d2b07d794..5d00bbf999b4f20b31d49a935436f005705d3687 100644 (file)
@@ -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")
index 6f6d8941fec6355113a81e5b874fdd8de8c35ef0..9d1103d0f37c69552e79398e1e1659ad23d0cfef 100644 (file)
@@ -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