profile: Add probe_on_discover flag
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Tue, 8 Aug 2023 11:50:37 +0000 (14:50 +0300)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 5 Jan 2024 13:34:03 +0000 (19:04 +0530)
This adds probe_on_discover flag which indicates if profile needs to be
probed when the remote_uuid is discovered and changes device logic to
attempt to probe driver when a new UUID is discovered and
probe_on_discover is set.

src/device.c
src/profile.h

index 0222bbd06692c9e0192b35d3f73c59da5ed670b1..60f888608b852263b937261b69cba13dc9aee639 100644 (file)
@@ -2695,7 +2695,7 @@ done:
 void device_add_eir_uuids(struct btd_device *dev, GSList *uuids)
 {
        GSList *l;
-       bool added = false;
+       GSList *added = NULL;
 
        if (dev->bredr_state.svc_resolved || dev->le_state.svc_resolved)
                return;
@@ -2704,13 +2704,11 @@ void device_add_eir_uuids(struct btd_device *dev, GSList *uuids)
                const char *str = l->data;
                if (g_slist_find_custom(dev->eir_uuids, str, bt_uuid_strcmp))
                        continue;
-               added = true;
+               added = g_slist_append(added, (void *)str);
                dev->eir_uuids = g_slist_append(dev->eir_uuids, g_strdup(str));
        }
 
-       if (added)
-               g_dbus_emit_property_changed(dbus_conn, dev->path,
-                                               DEVICE_INTERFACE, "UUIDs");
+       device_probe_profiles(dev, added);
 }
 
 static void add_manufacturer_data(void *data, void *user_data)
@@ -2740,6 +2738,7 @@ static void add_service_data(void *data, void *user_data)
        struct eir_sd *sd = data;
        struct btd_device *dev = user_data;
        bt_uuid_t uuid;
+       GSList *l;
 
        if (bt_string_to_uuid(&uuid, sd->uuid) < 0)
                return;
@@ -2747,6 +2746,10 @@ static void add_service_data(void *data, void *user_data)
        if (!bt_ad_add_service_data(dev->ad, &uuid, sd->data, sd->data_len))
                return;
 
+       l = g_slist_append(NULL, sd->uuid);
+       device_add_eir_uuids(dev, l);
+       g_slist_free(l);
+
        g_dbus_emit_property_changed(dbus_conn, dev->path,
                                        DEVICE_INTERFACE, "ServiceData");
 }
@@ -6486,6 +6489,12 @@ static bool device_match_profile(struct btd_device *device,
        if (profile->remote_uuid == NULL)
                return false;
 
+       /* Don't match if device was just discovered (not connected) and the
+        * profile don't have probe_on_discover flag set.
+        */
+       if (!btd_device_is_connected(device) && !profile->probe_on_discover)
+               return false;
+
        if (g_slist_find_custom(uuids, profile->remote_uuid,
                                                        bt_uuid_strcmp) == NULL) {
 #ifdef TIZEN_BT_HID_DEVICE_ENABLE
@@ -7827,6 +7836,9 @@ void device_probe_profiles(struct btd_device *device, GSList *uuids)
        struct probe_data d = { device, uuids };
        char addr[18];
 
+       if (!uuids)
+               return;
+
        ba2str(&device->bdaddr, addr);
 
        if (device->blocked) {
index 02291c1b0b0bf31a5fb800e08915405c1fe4943b..55a60c79f3a1cbaabb0ece85d52a83724896beaf 100644 (file)
@@ -33,6 +33,11 @@ struct btd_profile {
         */
        bool experimental;
 
+       /* Indicates the profile needs to be probed when the remote_uuid is
+        * discovered.
+        */
+       bool probe_on_discover;
+
        int (*device_probe) (struct btd_service *service);
        void (*device_remove) (struct btd_service *service);