Android 10: need to toggle location permission to see BLE devices

There are many one star reviews for nRF Toolbox on the Android Play Store (not from me!). These one star reviews are from users complaining that the application does not find any BLE devices. The answer from Nordic is that the locate permission needs to be toggled to Deny and then back to Allowed. I have confirmed that this fixes both the nRF Toolbox and our own application. This is OK for a test application but not for the general public.

Questions:

  • Is there a better explanation other than this is Android/Google fault?
  • Is there a programmatic solution to this problem?

Additional information:

1) While Nordic says that this is a Google issue, we have an older application available on the Play Store which does not require us to toggle the permission. This really looks like an issue into the new Nordic SDK framework

2) It seems that the Android apps which do NOT require the toggle have the location permission as:

  • Allow all the time
  • Allow only while using the app
  • Deny

The apps which only have:

  • Allow only while using the app
  • Deny

do require the toggle. 

If we know how to build an app that offers the 3 options that should resolve the problem.

  • Hi Bernard, 

     

    Is there a better explanation other than this is Android/Google fault?

    There is an issue on Android 10, where users have to manually go into app settings and disable and enable location permissions for it to work. They might have to do it a couple of times to get the apps working. This was an issue that popped right after users upgraded their devices to Android 10. 
    What we believe is that the Android 10 upgrade did not restore the permissions granted to the apps properly. 

     

    Is there a programmatic solution to this problem?

     Unfortunately, No. We faced the same issue and the above fix is what we had to do. 

    -Amanda 

  • As I was expecting the problem is really on the Nordic side. The problem is located in your scanner. If you look at:

    https://github.com/NordicSemiconductor/Android-nRF-Toolbox/blob/master/app/src/main/java/no/nordicsemi/android/nrftoolbox/scanner/ScannerFragment.java

    at line 231 you have:

    	private void startScan() {
    		// Since Android 6.0 we need to obtain either Manifest.permission.ACCESS_COARSE_LOCATION or Manifest.permission.ACCESS_FINE_LOCATION to be able to scan for
    		// Bluetooth LE devices. This is related to beacons as proximity devices.
    		// On API older than Marshmallow the following code does nothing.
    		if (ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
    			// When user pressed Deny and still wants to use this functionality, show the rationale
    			if (ActivityCompat.shouldShowRequestPermissionRationale(requireActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) && mPermissionRationale.getVisibility() == View.GONE) {
    				mPermissionRationale.setVisibility(View.VISIBLE);
    				return;
    			}
    
    			requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, REQUEST_PERMISSION_REQ_CODE);
    			return;
    		}
    

    In order for Android 10 to detect BLE devices, the permission must be set to ACCESS_FINE_LOCATION (and not ACCESS_COARSE_LOCATION). It is possible that toggling the permission in the Android setting set the permission to the Manifest value instead of what was requested at run time but that is a side effect, not a bug.

    If Nordic re-release the Toolbox with this change, it will make a lot of people happy (also send an apology to the Android/Google team for blaming them Wink !)

  • Hi Bernard, you may have a point here, I see that it used to be ACCESS_COARSE_LOCATION  that was required for ble scanning. However the documentation seem to have been updated according to this

  • I not only have a point I also verified that changing the code does fix the issue! No toggling of the permission needed,

Related