Search code examples
androidbluetoothbluetooth-lowenergynfcgoogle-nearby

Android NearBy API terribly slow (~10+ seconds for discovery and connection)


I'm trying to setup a communication channel between two Android phones.

Unfortunately, Google decided to block developer access to Bluetooth adapter MAC address, effectively disabling the entire NFC to Bluetooth handover process (Simple Secure Pairing).

Side note: why? privacy/security gain is minimal to none, especially if you randomize it! you could simply randomize it when an app requests the MAC and that's it!

This SSP process used to take roughly 1-3 seconds at max and generated great user experience.

Currently, I'm stuck with NearBy which generates a terrible user experience (who's gonna wait 10 seconds just for the initial connection?)

The only options we have left:

  • Improving NearBy API somehow (~10 seconds average to discover and connect! why Google, why?)
  • WiFi hotspot - setting an agreed-upon ID as the name, discovering and connecting (~8 seconds average)
  • Bluetooth - requires a popup to be approved each time, a bit faster but results in bad UX.
  • Internet - just use the Internet and fall back to local wireless methods (when 4G internet connects much faster than local wireless Android NearBy, you know Google has definitely failed with the implementation).

Is there some secret sauce I can pour onto NearBy to improve it, to be, at least as fast as Apple AirDrop (~4 seconds average)?

Do I have any other options I'm missing?

Thanks!


Solution

  • The definition of absurdity:

    Two phones that are 1 meter away from each other with several direct wireless options (Bluetooth/BLE/WiFi) take an average of 10 full seconds just to connect (before data is sent).

    Two phones that are 20km away from each other, communicating over cellular data (3G/4G/5G) fully connect after an average of 1.7 seconds! Even after traveling through GSM BTS, proxies, cache, firewalls, BGP routing and other filters.

    enter image description here

    Google has to do something to fix that (after they disabled the only method to make this faster, using BT SSP, handing over NFC to BT - as they disabled BT MAC address exposure).

    My solution right now is to use Internet by default while simultaneously trying to connect via NearBy, as I need a fallback ready to work for some of my clients that don't have a good cellular signal.