0

In order to scan for BTLE devices, an Android app needs ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION. But does the app need to scan for BTLE devices in order to pair with one?

I'm seeing this specifically with an app that pairs with a sleep monitor and justifies it like this:

As of Android 6.0 Marshmallow, Android requires that apps performing Bluetooth Low Energy scans first ask for — and gain — permission to access a device’s Location Services.

For that reason, Sense will ask for permission to access Location Services during setup. In order to finish pairing Sense, you’ll need to grant access to Location Services.

Is this really necessary? How can they pair without requiring the user's location? I could already pair with the device independent of the app via the OS Bluetooth dialog.

Sense Bluetooth location why

Community
  • 1
  • 1
Dan Dascalescu
  • 143,271
  • 52
  • 317
  • 404

1 Answers1

1

Technically if the BLE device is already paired with the mobile device, the app shouldn't even need to scan. Instead it can call this function to to get a list of devices that can be filtered by BLE: https://developer.android.com/reference/android/bluetooth/BluetoothAdapter.html#getBondedDevices()

Set<BluetoothDevice> devices = bluetoothAdapter.getBondedDevices();
for (BluetoothDevice device : devices) {
   if (device.getType() != BluetoothDevice.DEVICE_TYPE_LE) {
     continue;
   }
   //Do things to BLE device
}

But that doesn't allow me to filter by a UUID, which means I have to determine what the device is based on the address or name, both of which aren't reliable.

randdusing
  • 41
  • 1
  • 2
  • If the device is under the control of the app developers (i.e. hello.is makes both the app and the sensor), can they rely on the name? It *is* possible for more devices to be within range, but their can conform to a pattern (in this case it's `Sense-.*`. – Dan Dascalescu Dec 10 '16 at 22:25
  • If you control the name, then it's not really a big deal. I was thinking more from the heart rate monitor perspective where there's almost no way to know every single device name. But actually the most important 'filtering' is really when the user decides what device to choose within the app. – randdusing Dec 11 '16 at 23:11