BasicAirData / GPSLogger

A GPS logger for Android mobile devices
http://www.basicairdata.eu/projects/android/android-gps-logger/
GNU General Public License v3.0
371 stars 119 forks source link

Signal losses during flight recording #174

Closed michaelgrifalconi closed 2 years ago

michaelgrifalconi commented 2 years ago

Hello, according the the documentation about location access, for devices with Android 10 or higher the application should request ACCESS_BACKGROUND_LOCATION to make sure the recording continues in the background.

Current situation on my OnePlus Nord 2 (all battery optimization disabled) permissions for GPS Logger: "Location: Allow every time the app is in use"

Expected situation (same of what I see on Google Maps): "Location: Allow all the time".

Thank you!

GrazianoCapelli commented 2 years ago

The app asks the location permission "only while using the app", and the "all the time" option is not present, because the permission is related to the access, and not the use of the location by an app. In GPS Logger the location is always accessed (started) when the app is in foreground, and then is kept active also in background by the Foreground Service. On Android 10+ the app needs the location permission "only while using the app", it doesn't need the "all the time" access.

What kind of problem are you having to let the app work in background?

GrazianoCapelli commented 2 years ago

according the the documentation about location access, for devices with Android 10 or higher the application should request ACCESS_BACKGROUND_LOCATION to make sure the recording continues in the background.

Unfortunately the Google documentation is not so well explained, and could lead to confusion. Here you can find a fairly complete article on this topic: https://medium.com/@adrian.kajda/restrictions-to-background-location-and-foreground-services-in-android-11-9501adcd5795

Quoting a small chunk of that interesting technical article:

An app is considered to be accessing location in the background unless one of the following conditions is satisfied:

  • An activity belonging to the app is visible.
  • The app is running a foreground service that has declared a foreground service type of location. To declare the foreground service type for a service in your app, set your app’s targetSdkVersion or compileSdkVersion to 29 or higher. Learn more about how foreground services can continue user-initiated actions that require access to location.

GPS Logger falls into the second category.

michaelgrifalconi commented 2 years ago

Thanks for the quick reply and the explanation!

I am having troubles to record a good track for my flight lessons (little General Aviation plane). I saw several complaints on the OnePlus forums about GPS precision but I hoped this permission could have been one factor.

Here is an example of a track, imported to google earth. You can see every now and then, there are missing pieces https://imgur.com/eVDkzoi

Please feel free to close the issue since the main topic was wrong, but if you have any suggestion on what to try it's appreciated!

GrazianoCapelli commented 2 years ago

Unfortunately the permission you reported is not related to your problem.

I took a look to your track, and it seems that there are simply some signal losses. You could try to record a track with the screen on, and verify visually (if possible) if your track suffers of spotted signal losses. You could also record a track during a normal outdoor activity, and check if the signal is stable. As second test, you could also check if the problem is present also when you record, in the same conditions, with another GPS recording app.

In this case, I can suggest (if not yet done) to go to System Settings and set a "high performances" power mode instead of a "power saving" power mode. On a Samsung device, for example, you can find the screen on Device Care -> Battery -> Power Mode:

image

Here a video related to your phone model: https://www.youtube.com/watch?v=x62Ylm9erYQ

Some users reported a similar behaviour recording a flight from inside a plane, and resolved the problem with the Performances power mode, like if the GPS antenna would use a higher power in that power mode.

If you already set the power mode, I think that you could only try to find a better place on the plane for your device, in order to have a better GPS signal, or to buy a cheaper external bluetooth antenna (https://www.basicairdata.eu/projects/android/android-gps-logger/application-note-gpslogger/using-a-bluetooth-gps-receiver-with-gps-logger/).

michaelgrifalconi commented 2 years ago

Thanks for all the info. I already disabled all battery optimization on my phone (will double check the high performance mode though). I agree that might be signal loss instead of permissions or weird android battery stuff.

Phone was always in my pocket so not in the best place to see the sky. I will try another place and also to switch between location source of GPS+Wifi/BT data and GPS only.

Since it will be a few weeks until my next flight, I will close the issue and re-open it if not solved, to avoid polluting the issue list with something without recent updates.

Thank you again for your help!

GrazianoCapelli commented 2 years ago

Ok. Feel free to keep open, or reopen the issue, when you want. In any case, we would be glad to receive a feedback of your tests.