Add the feature check logic in launching bt-service 25/215025/1
authorDoHyun Pyun <dh79.pyun@samsung.com>
Tue, 1 Oct 2019 05:24:34 +0000 (14:24 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Tue, 1 Oct 2019 05:24:34 +0000 (14:24 +0900)
Even if BT feature is false in TV profile, bt-service try to
enable BT HW. This patchset prevents this issue.

Change-Id: I571ec5f1bcb3de067ff5f09459be1597265a0e69
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
bt-service-adaptation/services/bt-service-main.c
include/bt-internal-types.h

index 3f846da..54c6dd3 100644 (file)
@@ -295,6 +295,11 @@ int main(void)
        struct sigaction sa;
        BT_INFO_C("### Starting the bt-service daemon");
 
+       if (!TIZEN_FEATURE_BT_SUPPORTED) {
+               BT_INFO_C("BT feature is not supported, terminate bt-service");
+               return 0;
+       }
+
        memset(&sa, 0, sizeof(sa));
        sa.sa_sigaction = __bt_sigterm_handler;
        sa.sa_flags = SA_SIGINFO;
index 7814056..35ec41a 100644 (file)
@@ -673,6 +673,8 @@ typedef struct {
 #define HEADED_PLUGIN_FILEPATH64 "/usr/lib64/bt-plugin-headed.so"
 #define FILEPATH_ARCH_64 "/usr/lib64"
 
+#define BT_FEATURE_COMMON "http://tizen.org/feature/network.bluetooth"
+
 struct bluetooth_headed_plugin_t {
        int (*bt_launch_dpmpopup) (char *mode);
        int (*bt_launch_system_popup)(int event_type,
@@ -721,6 +723,7 @@ extern bt_plugin_info_t *headed_plugin_info;
 
 /* Accessing system info */
 int system_info_get_platform_string(const char *key, char **value);
+bool system_info_get_platform_bool(const char *key, bool *value);
 
 void bluetooth_plugin_init();
 void bluetooth_plugin_deinit();
@@ -802,6 +805,15 @@ static inline tizen_model_t get_tizen_model(void)
        return model;
 }
 
+static inline bool get_tizen_feature_supported(char *feature)
+{
+       bool is_supported = false;
+
+       system_info_get_platform_bool(feature, &is_supported);
+
+       return is_supported ? true : false;
+}
+
 #define TIZEN_PROFILE_WEARABLE (get_tizen_profile() == _PROFILE_WEARABLE)
 #define TIZEN_PROFILE_IVI (get_tizen_profile() == _PROFILE_IVI)
 #define TIZEN_PROFILE_TV (get_tizen_profile() == _PROFILE_TV)
@@ -812,6 +824,7 @@ static inline tizen_model_t get_tizen_model(void)
 #define TIZEN_FEATURE_FLIGHTMODE_ENABLED (get_tizen_profile() & (_PROFILE_MOBILE | _PROFILE_WEARABLE))
 #define TIZEN_FEATURE_BT_USB_DONGLE (get_tizen_profile() & (_PROFILE_TV))
 #define TIZEN_FEATURE_BLUEZ_SPEAKER_REFERENCE ((get_tizen_model()) == _MODEL_RPI3 && (get_tizen_profile()) == _PROFILE_COMMON)
+#define TIZEN_FEATURE_BT_SUPPORTED (get_tizen_feature_supported(BT_FEATURE_COMMON) == true)
 
 #ifdef __cplusplus
 }