Add feature check for vc_widget 62/167562/4
authorsungrae jo <seongrae.jo@samsung.com>
Thu, 18 Jan 2018 07:41:25 +0000 (16:41 +0900)
committersungrae jo <seongrae.jo@samsung.com>
Thu, 18 Jan 2018 08:34:34 +0000 (17:34 +0900)
Change-Id: I9e9d35dab9acfb7e81b83d2f59c89622102dd43a
Signed-off-by: sungrae jo <seongrae.jo@samsung.com>
client/vc_widget.c

index 4b4486f..6c9f29b 100644 (file)
@@ -15,6 +15,7 @@
 */
 
 #include <aul.h>
+#include <system_info.h>
 #include <Ecore_Wayland.h>
 #include "vc_cmd_db.h"
 #include "vc_command.h"
@@ -41,9 +42,41 @@ static Ecore_Timer* g_w_notify_result_timer = NULL;
 
 static int g_daemon_pid = 0;
 
+static int g_feature_enabled = -1;
+
 static Eina_Bool __vc_widget_notify_state_changed(void *data);
 static Eina_Bool __vc_widget_notify_error(void *data);
 
+static int __vc_widget_get_feature_enabled()
+{
+       if (0 == g_feature_enabled) {
+               SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Voice control feature NOT supported");
+               return VC_ERROR_NOT_SUPPORTED;
+       } else if (-1 == g_feature_enabled) {
+               bool vc_supported = false;
+               bool mic_supported = false;
+               if (0 == system_info_get_platform_bool(VC_FEATURE_PATH, &vc_supported)) {
+                       if (0 == system_info_get_platform_bool(VC_MIC_FEATURE_PATH, &mic_supported)) {
+                               if (false == vc_supported || false == mic_supported) {
+                                       SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Voice control feature NOT supported");
+                                       g_feature_enabled = 0;
+                                       return VC_ERROR_NOT_SUPPORTED;
+                               }
+
+                               g_feature_enabled = 1;
+                       } else {
+                               SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get feature value");
+                               return VC_ERROR_NOT_SUPPORTED;
+                       }
+               } else {
+                       SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get feature value");
+                       return VC_ERROR_NOT_SUPPORTED;
+               }
+       }
+
+       return 0;
+}
+
 const char* vc_tag()
 {
        return TAG_VCW;
@@ -118,6 +151,11 @@ int vc_widget_initialize(vc_h* vc_w)
 {
        SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Initialize");
 
+       if (0 != __vc_widget_get_feature_enabled()) {
+               SLOG(LOG_ERROR, TAG_VCW, "@@@ [Widget] not supported");
+               return VC_ERROR_NOT_SUPPORTED;
+       }
+
        if (NULL == vc_w) {
                SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL");
                return VC_ERROR_INVALID_PARAMETER;