Search code examples
androidgoogle-nearbygoogle-nearby-connections

Nearby Connections API: Why isn't Wi-Fi Direct a supported medium for my Galaxy S8?


I'm working on an app that uses the Nearby Connections API. Connections and file transfers seem to work mostly fine on other devices, but I noticed some odd behaviour when using my Samsung Galaxy S8. After reviewing the logs I found this message:

NearbyConnections: Computed the intersection of supported mediums with endpoint F77D. Between their supported mediums ([ WIFI_DIRECT WIFI_HOTSPOT BLE_L2CAP BLUETOOTH BLE ]) and my supported mediums ([ WIFI_HOTSPOT BLUETOOTH BLE NFC ]) we decided on the combined subset ([ WIFI_HOTSPOT BLUETOOTH BLE ]). [CONTEXT service_id=54 ]

The important part is my supported mediums ([ WIFI_HOTSPOT BLUETOOTH BLE NFC ]), which lacks WIFI_DIRECT, meaning that my S8 cannot establish connections to other phones with Wi-Fi Direct. This seemed odd since every other phone that I've tested supports Wi-Fi Direct. It's also strange because my S8 is able to use Wi-Fi Direct for different tasks, as can be seen in this screenshot of the Wi-Fi Direct interface in settings.

Is there a particular reason why Nearby Connections cannot use Wi-Fi Direct on my S8?


Solution

  • Nearby Connections only uses WiFi Direct on Android R+. This is because the APIs were updated in Q to allow silently connecting (w/o a user dialog), which is necessary for the Bluetooth -> WiFi upgrade process used by Nearby Connections. However, in Q, there was a bug when scanning for devices over WiFi Direct and when it's triggered it crashes the whole WiFi service. For that reason, we only use the new APIs on R+.

    (Disclaimer: I work on Nearby Connections)