corona-warn-app / cwa-app-android

Native Android app using the Apple/Google exposure notification API. The CWA development ends on May 31, 2023. You still can warn other users until April 30, 2023. More information:
https://coronawarn.app/en/faq/#ramp_down
Apache License 2.0
2.44k stars 495 forks source link

"Improve accuracy by bluetooth scanning" necessary? #565

Closed aurisnoctis closed 4 years ago

aurisnoctis commented 4 years ago

(EN) In my Android 6.0.1 settings I have a location submenu named "improve accuracy". There I can switch on or off Wifi scanning and bluetooth scanning. Does bluetooth scanning have to be active for Bluetooth Low Energy (BLE) to work correctly?


(DE) In meinen Android 6.0.1 Einstellungen habe ich unter "Standort" ein Untermenü "Genauigkeit verbessern". Dort kann ich unabhängig voneinander "WLAN-Scan" und "Bluetooth-Scanning" ein- und ausschalten. Sollte Bluetooth-Scanning eingeschaltet sein damit Bluetooth Low Energy (BLE) korrekt arbeiten kann?

tomjschwanke commented 4 years ago

Enabling this setting will allow location services to scan for BLE beacons, even when Bluetooth has been turned off by the end user. I wouldn't rely on this for tracing, so it's best to not turn off Bluetooth. Disabling this setting should have no effect, as long as Bluetooth is still enabled.

aurisnoctis commented 4 years ago

@tomjschwanke Thanks for your input. As far as I understood the bluetooth part of location is why the app needs access to location at all. If I switch the bluetooth scanning in location off - how is location (without bluetooth scanning) then still helping the app?

tomjschwanke commented 4 years ago

Screenshot_20200617-104306

According to the info in this screenshot (it's under location settings) it's only for enabling Bluetooth scans with Bluetooth turned off.

tomjschwanke commented 4 years ago

Location ~permission is needed~ needs to be turned on, because Google scans for beacons, and by scanning for Bluetooth beacons, an app could in theory get the users location (if they know the location of the beacons), so therefore the requirement of having location enabled.

aurisnoctis commented 4 years ago

@tomjschwanke Yes, thanks, I have the same words in my settings. It's still beyond me how location is useful to the app without bluetooth scanning.

aurisnoctis commented 4 years ago

Location permission is needed, because by scanning for Bluetooth beacons, an app could in theory get the users location (if they know the location of the beacons)

Location permission is not needed, see https://github.com/corona-warn-app/cwa-app-android/issues/491#issuecomment-644710288. (Accordingly, there is no location permission entry for the app in Android settings.)

As stated in https://github.com/corona-warn-app/cwa-app-android/issues/491#issuecomment-644710288:

When Google Play Services is scanning for BLE bacons it only gets back a static "fake beacon" from the lower level of the Android operating system if location services are disabled.

Therefore my question: does bluetooth scanning have to be enabled in location settings in order for Android to produce "real beacons" instead of "fake beacons"?

tomjschwanke commented 4 years ago

Location permission is not needed, see https://github.com/corona-warn-app/cwa-app-android/issues/491#issuecomment-644710288. (Accordingly, there is no location permission entry for the app in Android settings.)

I'm sorry, I got my wording wrong. Location needs to be switched on but the app doesn't need the permission.

babymotte commented 4 years ago

@aurisnoctis The way I understand it, the setting in the location menu is an override flag that specifically allows the location service to scan BLE even if bluetooth is globally deactivated. In other words, als long as bluetooth itself is enabled, the setting has no effect because bluetooth scanning is allowed anyway.

bluetooth on + bluetooth scanning in location menu enabled -> bluetoth scanning is used bluetooth on + bluetooth scanning in location menu disabled -> bluetoth scanning is used because the global bluetooth setting itself allows it bluetooth off + bluetooth scanning in location menu enabled -> bluetoth scanning is used because the location menu setting overrides the global bluetooth setting bluetooth off + bluetooth scanning in location menu disabled -> bluetoth scanning is NOT used because the location menu setting forbids the location service to override the global bluetooth setting

According to that, explicitly enabling bluetooth scanning in the location settings should not be necessary as long as bluetooth is generally enabled.

This is how I understand the description in the menu. I have no deeper knowledge of the internal workings of bluetooth on Android and thus may be entirely wrong.

mohe2015 commented 4 years ago

@babymotte I don't know if that is correct but if I disable either of them a notification pops up which tells me to enable it again. So I personally would recommend to keep both enabled but maybe this is also the case because I use a really old version of Android 6. (My location settings menu looks different)

aurisnoctis commented 4 years ago

@babymotte Thank you for the clear explanation of your view (which is also consistent with @tomjschwanke 's)

bluetooth on + bluetooth scanning in location menu disabled -> bluetoth scanning is used because the global bluetooth setting itself allows it

So what is the function of location setting on in addition to bluetooth on if scanning works with bluetooth on alone?

[Note: My goal is to make sure that contact tracing works as supposed. If that means switching on bluetooth + location + bluetooth scanning in location that's fine. Users like me want to know what needs to be active for the app to work correctly.]

aurisnoctis commented 4 years ago

@mohe2015

if I disable either of them a notification pops up which tells me to enable it again

What do you mean by "either of them"? I have Android 6.0.1 on a Samsung S5 and I have the following relevant Android settings:

  1. Bluetooth in Android settings > bluetooth (on / off): should be on for the app
  2. Location in Android settings > location (on / off): should be on for the app as far as I understand
  3. Bluetooth scanning as option in Android settings > location > improve accuracy (on/off, can only be on if location is on): don't know if it should be on
  4. Location mode as option in Android settings > location > mode (high accuracy with GPS, WiFi, mobile networks / energy saving with WiFi and mobile networks / only GPS): don't know if "only GPS" hinders app from working correctly

Alerts by the app: A) The CWA app alerts me at the top of the main screen if Bluetooth is off. (correct) B) The app does not alert me if location is off. (bug) C) The app does not alert me if location is on with bluetooth scanning off. (not sure if correct or bug ?) D) The app does not alert me if location is on with only GPS. (not sure if correct or bug ?)

Alerts by Android: none.

mohe2015 commented 4 years ago

@aurisnoctis I don't have the bluetooth scanning setting. Otherwise same behaviour but if I disable location it alerts me. If I set location mode to GPS only it doesn't. But if I disable and reenable location it sets the mode back to high accuracy. I have a cheap china phone with not enough security updates and 6.0

babymotte commented 4 years ago

So what is the function of location setting on in addition to bluetooth on if scanning works with bluetooth on alone?

I don't want to speculate too much here because in the end I don't really know what I'm talking about :D

But looking at it strictly from a use case perspective I really can't imagine why anyone would want bluetooth and location to be on but BLE to be off. So it would actually make sense if android automatically enabled BLE whenever bluetooth and location are on to avoid unexpected behavior, just like it automatically disables BLE whenever location is off to avoid unintended exposure of the user's position.

What I cannot explain is why the bluetooth scanning switch doesn't get greyed out and automatically set to 'on' whenever bluetooth is enabled. So that would be a potential indication that BLE can actually be switched off while bluetooth and location are on.

aurisnoctis commented 4 years ago

All I wanted to know seems to have been tried out here: https://github.com/corona-warn-app/cwa-app-android/issues/491#issuecomment-645524218

Thank you everyone! Sorry if I was too "suspicious" and questioning things.