OSDN Git Service

core: Fix Paired property notification for multiple bearers
authorJohan Hedberg <johan.hedberg@intel.com>
Thu, 20 Mar 2014 14:06:21 +0000 (16:06 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Thu, 20 Mar 2014 14:06:21 +0000 (16:06 +0200)
The code in device_set_paired wasn't quite right previously. We should
not be sending Paired=true if we've already done that once due to the
other supported bearer.

src/device.c

index f72a72b..67c4e6d 100644 (file)
@@ -4002,13 +4002,21 @@ void device_set_paired(struct btd_device *dev, uint8_t bdaddr_type)
        if (state->paired)
                return;
 
-       if (!state->svc_resolved)
+       state->paired = true;
+
+       /* If the other bearer state was alraedy true we don't need to
+        * send any property signals.
+        */
+       if (dev->bredr_state.paired == dev->le_state.paired)
+               return;
+
+       if (!state->svc_resolved) {
                dev->pending_paired = true;
-       else if (dev->bredr_state.paired != dev->le_state.paired)
-               g_dbus_emit_property_changed(dbus_conn, dev->path,
-                                               DEVICE_INTERFACE, "Paired");
+               return;
+       }
 
-       state->paired = true;
+       g_dbus_emit_property_changed(dbus_conn, dev->path,
+                                               DEVICE_INTERFACE, "Paired");
 }
 
 static void device_auth_req_free(struct btd_device *device)