Support RFCOMM Client and Server with same UUID 41/284041/1 accepted/tizen/unified/20221115.172855
authorAnuj Jain <anuj01.jain@samsung.com>
Wed, 9 Nov 2022 04:57:43 +0000 (10:27 +0530)
committerAnuj Jain <anuj01.jain@samsung.com>
Wed, 9 Nov 2022 04:57:43 +0000 (10:27 +0530)
This patch add functionality to support both RFCOMM
client and server with same UUID at a time.

Change-Id: Ie64d46d9d50de65f322112a6a3793b05922254f4
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
src/profile.c

index 0b2ed2b..3c699a8 100644 (file)
@@ -1028,7 +1028,10 @@ void btd_profile_foreach(void (*func)(struct btd_profile *p, void *data),
        }
 }
 
-static struct btd_profile *btd_profile_find_uuid(const char *uuid)
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+
+static struct btd_profile *btd_profile_find_uuid(const char *uuid,
+               const char *path)
 {
        GSList *l, *next;
 
@@ -1044,6 +1047,33 @@ static struct btd_profile *btd_profile_find_uuid(const char *uuid)
                struct ext_profile *ext = l->data;
                struct btd_profile *p = &ext->p;
 
+               /* Compare the paths in order to register both client and server
+                * with same UUID at a time */
+               if (!g_strcmp0(p->local_uuid, uuid) && !strncmp(ext->path, path, 18))
+                       return p;
+               next = g_slist_next(l);
+       }
+
+       return NULL;
+}
+
+#else
+
+static struct btd_profile *btd_profile_find_uuid(const char *uuid)
+{
+       GSList *l, *next;
+
+       for (l = profiles; l != NULL; l = next) {
+               struct btd_profile *p = l->data;
+
+               if (!g_strcmp0(p->local_uuid, uuid))
+                       return p;
+               next = g_slist_next(l);
+       }
+       for (l = ext_profiles; l != NULL; l = next) {
+               struct ext_profile *ext = l->data;
+               struct btd_profile *p = &ext->p;
+
                if (!g_strcmp0(p->local_uuid, uuid))
                        return p;
                next = g_slist_next(l);
@@ -1052,6 +1082,8 @@ static struct btd_profile *btd_profile_find_uuid(const char *uuid)
        return NULL;
 }
 
+#endif
+
 int btd_profile_register(struct btd_profile *profile)
 {
        profiles = g_slist_append(profiles, profile);
@@ -2996,7 +3028,11 @@ static DBusMessage *register_profile(DBusConnection *conn,
        dbus_message_iter_get_basic(&args, &uuid);
        dbus_message_iter_next(&args);
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       if (btd_profile_find_uuid(uuid, path)) {
+#else
        if (btd_profile_find_uuid(uuid)) {
+#endif
                warn("%s tried to register %s which is already registered",
                                                                sender, uuid);
                return btd_error_not_permitted(msg, "UUID already registered");