Support Bluetooth discovery for connecting to contacts
On Android 8+ apps don't have access to the device's own Bluetooth address, so we can't share our address with contacts. When adding contacts we use discovery to work around this (#1147). Users have reported that Bluetooth works when adding contacts, but not when subsequently trying to communicate.
Learning our Bluetooth address from contacts would raise some tricky security and privacy issues, such as revealing to existing contacts, by adding a Bluetooth address to our transport properties, that we've just added a contact via Bluetooth.
After adding a contact we could store the contact's address for subsequent connection attempts, but that would only let us connect to contacts who were added via Bluetooth. To let us connect to any nearby contact we need to make the device discoverable and perform discovery.
Making the device temporarily discoverable requires user confirmation each time. Making the device permanently discoverable has privacy implications, and doesn't work on all devices (e.g. the Sony Xperia Tipo). Discovering nearby devices may require a lot of power and may interfere with wifi (#699). BLE discovery uses less power and doesn't require user confirmation, but not all devices can be discovered via BLE (#303).
A possible solution would be to make the device temporarily discoverable, and perform discovery, when the user enables the Bluetooth transport (#185 (closed)). Then we could provide some way of manually triggering discovery, such as a "nearby contacts" tab with a "scan" button. This would limit the discoverability window, and the battery and interference impact of running discovery, to periods when the user had explicitly shown an interest in connecting to nearby contacts. Confirmation dialogs would only be shown in response to user actions.
This falls short of the goal of effortless connectivity, but it may be the best we can achieve within the constraints of the platform.