No GPS location on LineageOS 18.1
See original GitHub issueDescribe the bug After upgrading to LineageOS 18.1 (Android 11), OpenTracks never receives a GPS location. There is not even a location icon in the notifications bar, which suggests to me that the OS doesn’t think that OpenTracks has asked for a location. OpenTracks worked before the upgrade, on LineageOS 16 (Android 9). I have removed and reinstalled OpenTracks, which did not help.
The only location provider I have is the onboard GPS. I am running a bare LineageOS ROM, without microG, Mozilla Location Service, or any other network location provider. This was also the case when the phone ran LineageOS 16 (Android 9).
Other applications, e.g. OsmAnd and StreetComplete, manage to get a GPS location, and while they are running, the location icon appears in the notification bar.
Permissions on OpenTracks look right: ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION are both granted. The only denied permissions on OpenTracks are BLUETOOTH_SCAN and BLUETOOTH_CONNECT.
adb logcat output is not particularly helpful. Here’s everything from trying to start recording a track until the last mention of either “GPS”, “GNSS” or “location”:
03-06 17:41:55.967 671 19955 I ActivityTaskManager: START u0 {flg=0x14000000 cmp=de.dennisguse.opentracks/.TrackRecordingActivity} from uid 10204
03-06 17:41:55.989 671 19955 W ActivityTaskManager: Tried to set launchTime (0) < mLastActivityLaunchTime (82689784)
03-06 17:41:56.135 1761 19503 D KeyguardViewMediator: setOccluded true
03-06 17:41:56.135 19756 19756 I TrackRecordingServiceConnection: Binding the service.
03-06 17:41:56.136 1761 1761 D KeyguardViewMediator: adjustStatusBarLocked: mShowing=false mOccluded=true isSecure=true force=false --> flags=0x0
03-06 17:41:56.141 19756 19756 I TrackRecordingServiceConnection: Starting the service.
03-06 17:41:56.143 19756 19756 I TrackRecordingServiceConnection: Binding the service.
03-06 17:41:56.144 19756 19756 I TrackRecordingServiceConnection: Binding the service.
03-06 17:41:56.153 19756 19756 I TrackRecordingService: new status null -> RecordingStatus{trackId=null, paused=false}
03-06 17:41:56.181 19756 19756 I TrackRecordingServiceConnection: Binding the service.
03-06 17:41:56.198 19756 19756 I TrackRecordingServiceConnection: Connected to the service.
03-06 17:41:56.200 19756 19756 I chatty : uid=10204(de.dennisguse.opentracks) identical 1 line
03-06 17:41:56.201 19756 19756 I TrackRecordingServiceConnection: Connected to the service.
03-06 17:41:56.204 671 696 I ActivityTaskManager: Displayed de.dennisguse.opentracks/.TrackRecordingActivity: +237ms
03-06 17:41:56.286 19756 19756 I TrackRecordingService: new status RecordingStatus{trackId=null, paused=false} -> RecordingStatus{trackId=5, paused=false}
03-06 17:41:56.287 19756 19756 I SystemUtils: Acquiring wake lock.
03-06 17:41:56.291 19756 19756 E GPSHandler: Not started.
03-06 17:41:56.298 575 606 E LocSvc_APIClientBase: onResponseCb:894] ERROR: 5 ID: 40
03-06 17:41:56.301 19756 19756 W BluetoothRemoteSensorManager: Bluetooth not enabled.
03-06 17:41:56.302 19756 19756 I chatty : uid=10204(de.dennisguse.opentracks) identical 3 lines
03-06 17:41:56.302 19756 19756 W BluetoothRemoteSensorManager: Bluetooth not enabled.
03-06 17:41:56.309 19756 19756 W AltitudeSumManager: No pressure sensor available.
03-06 17:41:56.309 19756 19756 D AltitudeSumManager: Reset
03-06 17:41:56.323 19756 19756 D VoiceAnnouncement: Start
03-06 17:41:56.325 671 688 I GnssLocationProvider: GNSS HAL Requesting location updates from network provider for 10000 millis.
03-06 17:41:56.326 19756 19756 I VoiceAnnouncement: TextToSpeech initialized with status -1
03-06 17:41:56.326 671 688 W GnssLocationProvider: Unable to request location.
03-06 17:41:56.326 671 688 W GnssLocationProvider: java.lang.IllegalArgumentException: provider doesn't exist: network
03-06 17:41:56.326 671 688 W GnssLocationProvider: at com.android.server.location.LocationManagerService.requestLocationUpdatesLocked(LocationManagerService.java:1964)
03-06 17:41:56.326 671 688 W GnssLocationProvider: at com.android.server.location.LocationManagerService.requestLocationUpdates(LocationManagerService.java:1947)
03-06 17:41:56.326 671 688 W GnssLocationProvider: at android.location.LocationManager.requestLocationUpdates(LocationManager.java:1178)
03-06 17:41:56.326 671 688 W GnssLocationProvider: at android.location.LocationManager.requestLocationUpdates(LocationManager.java:1139)
03-06 17:41:56.326 671 688 W GnssLocationProvider: at com.android.server.location.gnss.GnssLocationProvider.handleRequestLocation(GnssLocationProvider.java:828)
03-06 17:41:56.326 671 688 W GnssLocationProvider: at com.android.server.location.gnss.GnssLocationProvider.access$2700(GnssLocationProvider.java:100)
03-06 17:41:56.326 671 688 W GnssLocationProvider: at com.android.server.location.gnss.GnssLocationProvider$ProviderHandler.handleMessage(GnssLocationProvider.java:2079)
03-06 17:41:56.326 671 688 W GnssLocationProvider: at android.os.Handler.dispatchMessage(Handler.java:106)
03-06 17:41:56.326 671 688 W GnssLocationProvider: at android.os.Looper.loop(Looper.java:223)
03-06 17:41:56.326 671 688 W GnssLocationProvider: at android.os.HandlerThread.run(HandlerThread.java:67)
03-06 17:41:56.326 671 688 W GnssLocationProvider: at com.android.server.ServiceThread.run(ServiceThread.java:44)
The Java exception saying “provider doesn’t exist: network” looks suspect, but it appears when running OsmAnd as well, and that app manages to get a GPS location.
Technical information
- Device: Moto G5 Plus (XT1685)
- OS: LineageOS 18.1
- OpenTracks version: 3.25.1, from F-Droid
Issue Analytics
- State:
- Created 2 years ago
- Comments:16 (9 by maintainers)
Top Related StackOverflow Question
I’ll try to take a look at implementing option 2.
So, that took way more work than expected, but I think I now know what happens, even if I don’t know why.
Setting breakpoints in OpenTracks’
GPSHandlershowed me thatregisterLocationListener()was called, which in turn calledlocationManager.requestLocationUpdates(). Toggling location globally calledonProviderEnabled()andonProviderDisabled(), so the location listener has definitely been registered, butonLocationChanged()which is supposed to actually receive location updates was never called.To have a chance of figuring out what was supposed to happen, I looked at the simplest GPS application I could find and easily build, which turned out to be GPS Cockpit. Sprinkling its source with breakpoints, I found that the location icon in the phone’s status bar (the pin) appeared after the app registered a GNSS status callback (at this line in the GPS Cockpit source code).
Blindly copying the code that registers the GNSS status callback from GPS Cockpit into OpenTracks gave me a
GPSHandler.registerLocationListener()that looks like this:And with that code added, I see the location icon in the phone’s status bar, and OpenTracks starts writing trackpoints.
However, I cannot find any documentation stating that you have to use both
requestLocationUpdates()andregisterGnssStatusCallback()to get a location. The few articles that do talk about that combination, like this StackOverflow question, talk about using the GNSS status callback to get detailed satellite information, which an app that just wants a location shouldn’t care about.Looking at some other GPS-using apps, OsmAnd (which works for me) calls
registerGnssStatusCallback(). StreetComplete also works for me even though I cannot find any call toregisterGnssStatusCallback(), but it’s written in Kotlin of which I know even less than Java, so I am probably missing something.Also, I have no idea how horrible my cargo-culted Java code is. It definitely leaks a callback object every time it’s called. Hopefully, someone who actually knows Java can turn it into something productive.