advertising: Fix resetting NO_BREDR flag
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 5 Jun 2020 17:45:21 +0000 (10:45 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 12 Apr 2021 09:00:49 +0000 (14:30 +0530)
When setting BT_AD_FLAG_LIMITED it was actually overwriting
BT_AD_FLAG_NO_BREDR as well so this moves the logic of detecting if the
instance needs to set BT_AD_FLAG_NO_BREDR to set_flags so it is always
updated when attempting to set any flags.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/advertising.c

index 3687544cefcb6bee7ffe0e451c2e8ad52bb29dc5..559abddf59f591ac8666e33f1bad3d4c1dd7992c 100644 (file)
@@ -670,6 +670,13 @@ static bool set_flags(struct btd_adv_client *client, uint8_t flags)
        if (!btd_adapter_get_bredr(client->manager->adapter))
                flags |= BT_AD_FLAG_NO_BREDR;
 
+       /* Set BR/EDR Not Supported if adapter is not discoverable but the
+        * instance is.
+        */
+       if ((flags & (BT_AD_FLAG_GENERAL | BT_AD_FLAG_LIMITED)) &&
+                       !btd_adapter_get_discoverable(client->manager->adapter))
+               flags |= BT_AD_FLAG_NO_BREDR;
+
        if (!bt_ad_add_flags(client->data, &flags, 1))
                return false;
 
@@ -692,12 +699,9 @@ static bool parse_discoverable(DBusMessageIter *iter,
 
        dbus_message_iter_get_basic(iter, &discoverable);
 
-       if (discoverable) {
-               /* Set BR/EDR Not Supported if adapter is no discoverable */
-               if (!btd_adapter_get_discoverable(client->manager->adapter))
-                       flags = BT_AD_FLAG_NO_BREDR;
-               flags |= BT_AD_FLAG_GENERAL;
-       } else
+       if (discoverable)
+               flags = BT_AD_FLAG_GENERAL;
+       else
                flags = 0x00;
 
        if (!set_flags(client , flags))