main.conf: Split Kernel Experimental UUIDs from Experimental
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Tue, 14 Jun 2022 21:45:44 +0000 (14:45 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:54 +0000 (14:55 +0530)
This splits kernel experimental UUIDs from D-Bus Experimental interface
so they can be controlled indenpendetly.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/adapter.c
src/btd.h
src/main.c
src/main.conf

index e7867de..2afeef1 100644 (file)
@@ -15946,7 +15946,7 @@ static void set_exp_debug_complete(uint8_t status, uint16_t len,
                                        const void *param, void *user_data)
 {
        struct btd_adapter *adapter = user_data;
-       uint8_t action = btd_opts.experimental ? 0x01 : 0x00;
+       uint8_t action;
 
        if (status != 0) {
                error("Set Experimental Debug failed with status 0x%02x (%s)",
@@ -15954,7 +15954,9 @@ static void set_exp_debug_complete(uint8_t status, uint16_t len,
                return;
        }
 
-       DBG("Experimental Debug successfully set");
+       action = btd_kernel_experimental_enabled(debug_uuid.str);
+
+       DBG("Experimental Debug successfully %s", action ? "set" : "reset");
 
        if (action)
                queue_push_tail(adapter->exps, (void *)debug_uuid.val);
@@ -15994,7 +15996,7 @@ static void set_rpa_resolution_complete(uint8_t status, uint16_t len,
                                        const void *param, void *user_data)
 {
        struct btd_adapter *adapter = user_data;
-       uint8_t action = btd_opts.experimental ? 0x01 : 0x00;
+       uint8_t action;
 
        if (status != 0) {
                error("Set RPA Resolution failed with status 0x%02x (%s)",
@@ -16002,7 +16004,9 @@ static void set_rpa_resolution_complete(uint8_t status, uint16_t len,
                return;
        }
 
-       DBG("RPA Resolution successfully set");
+       action = btd_kernel_experimental_enabled(rpa_resolution_uuid.str);
+
+       DBG("RPA Resolution successfully %s", action ? "set" : "reset");
 
        if (action)
                queue_push_tail(adapter->exps, (void *)rpa_resolution_uuid.val);
@@ -16028,7 +16032,7 @@ static void codec_offload_complete(uint8_t status, uint16_t len,
                                        const void *param, void *user_data)
 {
        struct btd_adapter *adapter = user_data;
-       uint8_t action = btd_opts.experimental ? 0x01 : 0x00;
+       uint8_t action;
 
        if (status != 0) {
                error("Set Codec Offload failed with status 0x%02x (%s)",
@@ -16036,7 +16040,9 @@ static void codec_offload_complete(uint8_t status, uint16_t len,
                return;
        }
 
-       DBG("Codec Offload successfully set");
+       action = btd_kernel_experimental_enabled(codec_offload_uuid.str);
+
+       DBG("Codec Offload successfully %s", action ? "set" : "reset");
 
        if (action)
                queue_push_tail(adapter->exps, (void *)codec_offload_uuid.val);
@@ -16106,20 +16112,22 @@ static void read_exp_features_complete(uint8_t status, uint16_t length,
                size_t j;
                for (j = 0; j < ARRAY_SIZE(exp_table); j++) {
                        const struct exp_feat *feat = &exp_table[j];
+                       const char *str;
                        uint8_t action;
 
                        if (memcmp(rp->features[i].uuid, feat->uuid->val,
                                        sizeof(rp->features[i].uuid)))
                                continue;
 
-                       action = btd_experimental_enabled(feat->uuid->str);
+                       str = feat->uuid->str;
+                       action = btd_kernel_experimental_enabled(str);
 
-                       DBG("%s flags %u action %u", feat->uuid->str,
-                               rp->features[i].flags, action);
+                       DBG("%s flags %u action %u", str,
+                                       rp->features[i].flags, action);
 
                        /* If already set don't attempt to set it again */
                        if (action == (rp->features[i].flags & BIT(0))) {
-                               if (action)
+                               if (action & BIT(0))
                                        queue_push_tail(adapter->exps,
                                                (void *)feat->uuid->val);
                                continue;
index 097e3ea..14b8e1a 100755 (executable)
--- a/src/btd.h
+++ b/src/btd.h
@@ -113,7 +113,8 @@ struct btd_opts {
        gboolean        debug_keys;
        gboolean        fast_conn;
        gboolean        refresh_discovery;
-       struct queue    *experimental;
+       gboolean        experimental;
+       struct queue    *kernel;
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        gboolean        le_privacy;
        char            *pin_code;
@@ -150,6 +151,6 @@ void rfkill_init(void);
 void rfkill_exit(void);
 
 GKeyFile *btd_get_main_conf(void);
-bool btd_experimental_enabled(const char *uuid);
+bool btd_kernel_experimental_enabled(const char *uuid);
 
 void btd_exit(void);
index 47be62d..b661871 100755 (executable)
@@ -83,6 +83,7 @@ static const char *supported_options[] = {
        "JustWorksRepairing",
        "TemporaryTimeout",
        "Experimental",
+       "KernelExperimental",
        "RemoteNameRequestRetryDelay",
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        "EnableLEPrivacy",
@@ -596,12 +597,12 @@ static bool match_experimental(const void *data, const void *match_data)
        return !strcasecmp(value, uuid);
 }
 
-bool btd_experimental_enabled(const char *uuid)
+bool btd_kernel_experimental_enabled(const char *uuid)
 {
-       if (!btd_opts.experimental)
+       if (!btd_opts.kernel)
                false;
 
-       return queue_find(btd_opts.experimental, match_experimental, uuid);
+       return queue_find(btd_opts.kernel, match_experimental, uuid);
 }
 
 static const char *valid_uuids[] = {
@@ -613,24 +614,24 @@ static const char *valid_uuids[] = {
        "*"
 };
 
-static void btd_parse_experimental(char **list)
+static void btd_parse_kernel_experimental(char **list)
 {
        int i;
 
-       if (btd_opts.experimental) {
-               warn("Unable to parse Experimental: list already set");
+       if (btd_opts.kernel) {
+               warn("Unable to parse KernelExperimental: list already set");
                return;
        }
 
-       btd_opts.experimental = queue_new();
+       btd_opts.kernel = queue_new();
 
        for (i = 0; list[i]; i++) {
                size_t j;
                const char *uuid = list[i];
 
                if (!strcasecmp("false", uuid) || !strcasecmp("off", uuid)) {
-                       queue_destroy(btd_opts.experimental, free);
-                       btd_opts.experimental = NULL;
+                       queue_destroy(btd_opts.kernel, free);
+                       btd_opts.kernel = NULL;
                }
 
                if (!strcasecmp("true", uuid) || !strcasecmp("on", uuid))
@@ -643,13 +644,13 @@ static void btd_parse_experimental(char **list)
 
                /* Ignored if UUID is considered invalid */
                if (j == ARRAY_SIZE(valid_uuids)) {
-                       warn("Invalid Experimental UUID: %s", uuid);
+                       warn("Invalid KernelExperimental UUID: %s", uuid);
                        continue;
                }
 
                DBG("%s", uuid);
 
-               queue_push_tail(btd_opts.experimental, strdup(uuid));
+               queue_push_tail(btd_opts.kernel, strdup(uuid));
        }
 }
 
@@ -854,12 +855,20 @@ static void parse_config(GKeyFile *config)
        else
                btd_opts.refresh_discovery = boolean;
 
-       strlist = g_key_file_get_string_list(config, "General", "Experimental",
+       boolean = g_key_file_get_boolean(config, "General", "Experimental",
+                                               &err);
+       if (err)
+               g_clear_error(&err);
+       else
+               btd_opts.experimental = boolean;
+
+       strlist = g_key_file_get_string_list(config, "General",
+                                               "KernelExperimental",
                                                NULL, &err);
        if (err)
                g_clear_error(&err);
        else {
-               btd_parse_experimental(strlist);
+               btd_parse_kernel_experimental(strlist);
                g_strfreev(strlist);
        }
 
@@ -1169,19 +1178,19 @@ static gboolean parse_debug(const char *key, const char *value,
        return TRUE;
 }
 
-static gboolean parse_experimental(const char *key, const char *value,
+static gboolean parse_kernel_experimental(const char *key, const char *value,
                                        gpointer user_data, GError **error)
 {
        char **strlist;
 
        if (value) {
                strlist = g_strsplit(value, ",", -1);
-               btd_parse_experimental(strlist);
+               btd_parse_kernel_experimental(strlist);
                g_strfreev(strlist);
        } else {
-               if (!btd_opts.experimental)
-                       btd_opts.experimental = queue_new();
-               queue_push_head(btd_opts.experimental, strdup("*"));
+               if (!btd_opts.kernel)
+                       btd_opts.kernel = queue_new();
+               queue_push_head(btd_opts.kernel, strdup("*"));
        }
 
        return TRUE;
@@ -1199,9 +1208,11 @@ static GOptionEntry options[] = {
                        "Specify an explicit path to the config file", "FILE"},
        { "compat", 'C', 0, G_OPTION_ARG_NONE, &option_compat,
                                "Provide deprecated command line interfaces" },
-       { "experimental", 'E', G_OPTION_FLAG_OPTIONAL_ARG,
-                               G_OPTION_ARG_CALLBACK, parse_experimental,
-                               "Enable experimental features/interfaces" },
+       { "experimental", 'E', 0, G_OPTION_ARG_NONE, &btd_opts.experimental,
+                               "Enable experimental D-Bus interfaces" },
+       { "kernel", 'K', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK,
+                               parse_kernel_experimental,
+                               "Enable kernel experimental features" },
        { "nodetach", 'n', G_OPTION_FLAG_REVERSE,
                                G_OPTION_ARG_NONE, &option_detach,
                                "Run with logging in foreground" },
@@ -1329,8 +1340,8 @@ int main(int argc, char *argv[])
        if (btd_opts.mode != BT_MODE_LE)
                stop_sdp_server();
 
-       if (btd_opts.experimental)
-               queue_destroy(btd_opts.experimental, free);
+       if (btd_opts.kernel)
+               queue_destroy(btd_opts.kernel, free);
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        g_free(btd_opts.pin_code);
 #endif
index 0d24eba..ff88b4e 100755 (executable)
 # profile is connected. Defaults to true.
 #RefreshDiscovery = true
 
-# Enables experimental features and interfaces, alternatively a list of UUIDs
+# Enables D-Bus experimental interfaces
+# Possible values: true or false
+#Experimental = false
+
+# Enables kernel experimental features, alternatively a list of UUIDs
 # can be given.
 # Possible values: true,false,<UUID List>
 # Possible UUIDS:
 # 330859bc-7506-492d-9370-9a6f0614037f (BlueZ Experimental Bluetooth Quality Report)
 # a6695ace-ee7f-4fb9-881a-5fac66c629af (BlueZ Experimental Offload Codecs)
 # Defaults to false.
-#Experimental = false
+#KernelExperimental = false
 
 # The duration to avoid retrying to resolve a peer's name, if the previous
 # try failed.