3

I have an application which is installed in the phones cab drivers use to track the location and distance traveled by the cab. (The phone is rooted and we have all privileges on the phone). In the first implementation of our application we used LocationManager.requestLocationUpdates to get location updates from GPS and Network providers. Since we need to capture every kilometer traveled by the cab we enabled "High Accuracy" mode in location settings.

For two reasons we are willing to move to Fused-location-provider

  1. For some reason (a known bug in android: https://code.google.com/p/android/issues/detail?id=57707) NETWORK_PROVIDER is not providing location updates.
  2. For some reason the devices are suddenly loses GPS fix and are not gaining again until the device reboots.

We observed that FusedLocationProvider is giving better results and are planning to change our application to use FusedLocationProvider. Now the problem is - our devices have an older version of GooglePlayServices which does not have LocationServices. Two options we have are

  1. Use older version of FusedLocationProvider using LocationRequest and LocationClient. Though it is giving good results outdoors(which is our primary requirement), we are not getting location updates(not-at-all) indoors even with wifi enable and with good network signal (This also seems to be a known issue (Location updates not working indoors as claimed by Fusion Location Provider APIs). So, i suspect there could be some bugs in older version of GooglePlayServices and/or FusedLocationProvider which would have been fixed in later versions.

  2. Update GooglePlayServices on all phones (by installing apk over the air) and use LocationServices to get location updates with high accuracy as priority. This implementation is giving location updates even indoors which is what we expect -- Here the problem is when I update GooglePlayServices with an apk when I request location updates in my application it is opening 2 popups one asking for confirmation to improve location accuracy and the other is to turn on ability for google apps to use my location. It is working fine even if I don't accept second popup but if I don't accept the first popup it is changing the location setting to "Device Only" mode (which means only GPS provider is used).

Improve Location Accuracy

Permission to enable google apps to use location

We can not expect all our drivers to accept the popup when it is shown. I would like to know if there is any way I can do "default accept" kind of thing for the first popup so that my devices remain in "High Accuracy" mode.

I found a solution to disable location consent which comes when high accuracy mode is enabled manually in Location Settings. That solution was working with our old application but with updated GooglePlayServices it is not working.

Any way of achieving this - like executing a command in device shell , issuing an intent or modifying the GooglePlayServices apk itself is fine with me.

Community
  • 1
  • 1
nagamanojv
  • 301
  • 5
  • 16
  • I have same problem. if you find any solution please share. – Nasser Mansouri Jan 16 '19 at 16:59
  • @NasserMansouri didn't find a solution to do it the right way, but since all our phones were of same make and model the popup was coming at same location. So, we simulated touch at the (x,y) location of the checkbox through adb shell command. If that is the case with you may be you can try that. – nagamanojv Jan 30 '19 at 11:20

1 Answers1

0

On rooted devices you can preempt these dialogs by programmatically setting the following values before initializing your use of the location services.

Run the following commands as su:

content insert --uri content://com.google.settings/partner --bind name:s:network_location_opt_in --bind value:i:1
content insert --uri content://com.google.settings/partner --bind name:s:use_location_for_services --bind value:i:1
content insert --uri content://settings/global --bind name:s:assisted_gps_enabled --bind value:i:1
content insert --uri content://settings/secure --bind name:s:allowed_geolocation_origins --bind value:s:'http://www.google.co.uk http://www.google.com'
user55674
  • 51
  • 1
  • 4