opentrace-community / opentrace-android

OpenTrace Android app. Reference implementation of the BlueTrace protocol.
https://bluetrace.io
GNU General Public License v3.0
577 stars 225 forks source link

BLE scanner may not work without location enabled #61

Open vtoubiana opened 3 years ago

vtoubiana commented 3 years ago

I noticed that the app is requesting the location permission but it does not check at runtime that location is enabled. However, according to google (see : https://blog.google/inside-google/company-announcements/update-exposure-notifications ) location has to be enabled to start a BLE scan.

Whereas the android documentation suggest that asking for the location permission is enough, all BLE scanner apps do require that the location is also enabled. This is also true for the contact tracing applications that are built on top of the Exposure Notification API. Apparently, the behavior is not the same on all Android devices: role-model phones will not run scan with location disabled whereas other phones may (https://www.polidea.com/blog/a-curious-relationship-android-ble-and-location/).

Therefore, the runService function should not only check the Bluetooth is enabled, it should also check that location is enabled (https://github.com/opentrace-community/opentrace-android/blob/e8b68321d1c567f45898744c7210323c1660df6f/app/src/main/java/io/bluetrace/opentrace/services/BluetoothMonitoringService.kt).