To avoid the paired devices are added twice 06/30906/2
authorwu zheng <wu.zheng@intel.com>
Thu, 27 Nov 2014 02:53:21 +0000 (10:53 +0800)
committerwu zheng <wu.zheng@intel.com>
Thu, 27 Nov 2014 02:53:21 +0000 (10:53 +0800)
When add the paired devices to privilege file,
It is not sure that the paired device has been removed
by the remote device and re-piared.
To avoid it, the patch is added.

Change-Id: Ib5969f7dd94958566b176d0ea07a2a8ad3d79177
Signed-off-by: Wu Zheng <wu.zheng@intel.com>
src/pairing.c

index 4fe06adad99381dee7f3692eb4387d29bd8267ef..12dd7a39b397b9be1f05017a490d28dd9a702220 100644 (file)
@@ -1051,14 +1051,17 @@ static void pair_cb(gchar *address, gboolean paired, gpointer user_data)
        if (isbonding) {
                if (paired && pairing_device_address &&
                        !g_strcmp0(pairing_device_address, address)) {
+                       remove_userprivileges(0, address, FALSE);
                        set_userprivileges(pairing_device_uid,
                                                pairing_device_address);
                        isbonding = FALSE;
                }
        } else {
                if (paired)
-                       if (address && relay_agent)
+                       if (address && relay_agent) {
+                               remove_userprivileges(0, address, FALSE);
                                set_userprivileges(relay_agent->uid, address);
+                       }
        }
 
        if (!paired)