Closed westnordost closed 7 years ago
This permission is not required by the Google Play services version of this method and I agree should be removed.
I'm still not sure what the proper behavior is for this API if bluetooth permissions are not granted and setNeedBle(true)
is called so doing some additional tests in a sample app.
After some additional testing of Google Play services apparently setNeedBle(true)
has nothing to do with Bluetooth system settings found under the "Bluetooth" menu option. Disabling Bluetooth communication in the settings menu has no bearing on the result of checkLocationSettings(...)
at all.
The method setNeedBle(true)
only cares about Bluetooth as it is used in the "Location" system settings which interestingly enough has been added to the descriptions of "High accuracy" and "Battery saving" in Android 7 (Nougat).
This means in Lost we are not providing the correct behavior when setNeedBle(true)
is called. We should not be querying and enabling the BluetoothAdapter
but only using this as another data point for updating the location settings.
According to the location settings menu option descriptions it would appear Bluetooth location is available whenever the network location provider is also available. Therefore perhaps we should indicate resolution is required if setNeedBle(true)
is called and location services are either off or set to "Device only".
Of course in Lost we cannot automatically update the location settings on behalf of the user (this requires system level permissions) in the same way Google Play services does but instead we can only redirect the user to the location settings menu.
Description
SettingsApi.checkLocationSettings
is annotated with@RequiresPermission(anyOf = {BLUETOOTH, BLUETOOTH_ADMIN})
which makes Android Studio suggest to add the Bluetooth permission to the manifest, regardless of if the LocationSettingsRequest contains a.setNeedBle(true)
or not.Since setting the
.setNeedBle(true)
is something the user of this library would do deliberately and the default is false, I think it makes sense to remove this annotation and instead document@throws SecurityException if the LocationSettingsRequest is set to need bluetooth but the app did not declare this permission in the manifest
or alike.Lost & Android Version
2.1.1 on Android 6