Add the new API for getting voice_assistant_enabled 00/280600/1
authorInHong Han <inhong1.han@samsung.com>
Thu, 1 Sep 2022 06:02:34 +0000 (15:02 +0900)
committerInHong Han <inhong1.han@samsung.com>
Thu, 1 Sep 2022 06:02:34 +0000 (15:02 +0900)
Change-Id: I27045db93584f01af1b571851740bec969f32602

common/multi_assistant_settings.c
include/multi_assistant_settings.h

index 5847a9c937e9ecf4accbf663f5b42b1877247c90..fb1b1a3b29d12777cd1564398ff4e872933475af 100644 (file)
@@ -95,6 +95,41 @@ int ma_settings_change_voice_assistant(const char* app_id) {
        return res;
 }
 
+int ma_settings_get_voice_assistant_enabled(const char* app_id, bool *enabled) {
+       bool multiple = false;
+       int res = ma_settings_is_multiple_mode(&multiple);
+       if (MA_ERROR_NONE != res) return res;
+
+       if (!multiple) {
+               LOGE("Not supported");
+               return MA_ERROR_NOT_SUPPORTED;
+       }
+
+       if (!enabled || !app_id) {
+               LOGE("Invalid parameter");
+               return MA_ERROR_INVALID_PARAMETER;
+       }
+
+       char* enabled_assistants = vconf_get_str(ENABLED_ASSISTANT_URL);
+       if (vconf_get_ext_errno() != VCONF_OK) {
+               LOGE("Operation Failed");
+               return MA_ERROR_OPERATION_FAILED;
+       }
+
+       if (enabled_assistants) {
+               char* tmp = strstr(enabled_assistants, app_id);
+               *enabled = tmp ? true : false;
+       } else {
+               *enabled = false;
+       }
+
+       if (enabled_assistants) {
+               free(enabled_assistants);
+       }
+
+       return res;
+}
+
 int ma_settings_set_voice_assistant_enabled(const char* app_id, bool enabled) {
        bool multiple = false;
 
index 288b14eb937eb0c6572ed04f70cbb6dd78fd5e89..715612baa5c5008b9c37cc7967ee531eb94e55bb 100644 (file)
@@ -85,6 +85,22 @@ int ma_settings_get_current_voice_assistant(char** app_id);
  */
 int ma_settings_change_voice_assistant(const char* app_id);
 
+/**
+ * @brief Get whether the specific voice assistant should be enabled or not.
+ * @since_tizen 7.0
+ * @privlevel public
+ *
+ * @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_INVALID_PARAMETER Invalid parameter
+ * @retval #MA_ERROR_OPERATION_FAILED Operation failed
+ *
+ * @param[in] app_id The app id of the voice assistant
+ * @param[out] enabled The enabled state of the voice assistant
+ */
+int ma_settings_get_voice_assistant_enabled(const char* app_id, bool *enabled);
+
 /**
  * @brief En/Disable a specific voice assistant.
  * @since_tizen 5.5