Skip to content

Add contacts via Bluetooth if possible

akwizgran requested to merge add-contacts-via-bluetooth into master

This branch changes the key agreement protocol in a backward-compatible way to prefer Bluetooth over LAN when adding contacts in person.

If the device supports Bluetooth, the user must grant the location permission and allow the device to become discoverable. The LAN plugin still accepts incoming connections, but it's not used for outgoing connections if the peer supports Bluetooth.

If the device doesn't support Bluetooth, the location permission isn't requested. The LAN plugin accepts incoming connections and is also used for outgoing connections if the peer supports LAN.

These changes are meant to solve several problems:

  • The user may refuse permission for location and/or discoverability, then proceed to scan QR codes. Depending on the other user's choices, whether the users are connected to the same LAN, and whether the LAN uses client isolation, it may not be possible for them to succeed no matter how many times they retry
  • When LAN and Bluetooth are both available, choosing Bluetooth allows the devices to exchange Bluetooth addresses, which enables them to reconnect via Bluetooth later. LAN connections are established faster than Bluetooth connections, so if we used both transports in parallel the devices would be unlikely to learn their Bluetooth addresses
  • Some devices don't support Bluetooth, so we still need to support incoming and outgoing LAN connections

Downsides of this approach:

  • Granting the location permission and allowing Bluetooth discoverability are now mandatory when adding contacts in person (unless the device doesn't support Bluetooth). Some users won't like this
  • Adding contacts via Bluetooth takes ~ 15 seconds longer than via LAN

On balance, I think the downsides are worth it. When both devices are connected to a LAN that doesn't use client isolation, adding contacts is slower then before and it's no longer possible to refuse the Bluetooth permissions. But in less optimal situations where adding contacts used to fail repeatedly, it now works. And once a single contact has been added in person, the device reliably learns its own Bluetooth address.

Edited by akwizgran

Merge request reports