osmandapp / OsmAnd

OsmAnd
https://osmand.net
Other
4.58k stars 1.01k forks source link

GPS signal lost when using Android Auto #13732

Open mdykierek opened 2 years ago

mdykierek commented 2 years ago

Description

When driving with OsmAnd on Android Auto the message about GPS signal lost keeps coming and map does not update properly. There is no option to allow using GPS at all times for OsmAnd only when the app is in use. To avoid this misbehavior I have to start OsmAnd in foreground on the phone which is inconvenient.

How to reproduce?

Connect phone to Android Auto, start navigation from the car panel. Drive. GPS signal goes away and comes back in long intervals. The location updates every 15-30 seconds and the location is scattered all over the place.

Your Environment

OsmAnd Version: 4.1.11 Android/iOS version: Android 11 Device model: Xiaomi Mi 9T Pro

Maps used (online or offline):
Does not matter.

vshcherb commented 2 years ago

Experienced same issue. It's android device dependent and sometimes turning screen on / off helps but not all the time.

mdykierek commented 2 years ago

Running OsmAnd in foreground even with screen off solves the issue.Thing is one would expect to connect the phone,start engine and go.On Feb 11, 2022 18:07, vshcherb @.***> wrote: Experienced same issue. It's android device dependent and sometimes turning screen on / off helps but not all the time.

—Reply to this email directly, view it on GitHub, or unsubscribe.Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>

MikeSpeigle commented 2 years ago

I also have this issue. I can confirm at least when plugging device into android auto and launching osmAnd from android auto that gps signal will be dropped and reconnected about once or twice a minute.

Also it does appear that if app is launched from phone and kept open during the trip that gps signal is not lost.

Android Auto version: 7.3.620524-release Device Android version: Android 11 stock sony OsmAnd+ 4.1.11, released: 2021-12-15

brunofin commented 2 years ago

I also experience this. In my case I noticed this only happens if I switch apps on my phone (meaning OsmAnd is now an app running on the background). If I leave it as the active app it works fine all the time even with the screen off.

I believe this is a permission issue as OsmAnd does not declare neither asks for permission to get location on the background, only while using the app, meaning when it becomes a background app it has to rely on coarse location which isn't ideal for navigation.

brunofin commented 2 years ago

I may try getting my hands dirty and try building it from source with the new permission declaration and manually force it to allow all the time here and test. I'll follow up in case I have issues or if it solves the problem.

mdykierek commented 2 years ago

The behavior you observe matches my description. The situation I had on my phone was - I had 4 options to have location always/all the time, only when using, always ask, and deny. When I chose always, the option did not work. I opened the settings again and first option (always on) was gone forever. Now I am using OsmAnd in foreground with screen off. This becomes cumbersome when a message or a call is received or have to switch to some app at a gas station for example (fuel.io).

sonora commented 1 year ago

For the sake of testing:Please note my findings in the first few paragraphs of https://osmand.net/docs/user/troubleshooting/track-recording-issues. Unless I overlooked something when I did the research, the issue of the 'Always on' location permission going away was a 'feature' of Android 11.

But we have adjusted OsmAnd to use a Foreground service (already some versions ago) during track recording or an ongoing turn-by-turn navigation. (Device will show a corresponding permanent entry in the system notification area.) So I guess for any testing you can trick your phone into the"OsmAnd is considered to be in the foreground" state simply by using one of these two functionalities, no need for any custom build.

sonora commented 1 year ago

To be more explicit: Pleae note that it's simply the new Android wording which can be misleading:

"Allow while using the app" means that the app can permanently obtain the location as long as the app is either displayed on the screen itself or has a visible notification in the Android notification bar, like OsmAnd has during navigation or trip recording. (This is technically referred to as "foreground mode".)

"Allow all the time", on the other hand, means that an app can in principle obtain your location 'unnotoiced' without any of these conditions applying. But Android limits the frequency of location access in this ("background") mode to something like once per hour, certainly not the correct mode for a navigtion app.

Miwer commented 1 month ago

Hello - has anyone found any solution to this problem?

I am also affected by this, and I cannot use OsmAnd with Android Auto, unless I keep the screen on with OsmAnd in the foreground. GPS signal goes away and comes back in long intervals, like described by OP. Switching app or putting OsmAnd in the background (with screen on), and I loose GPS location (GPS icon also disappear from top status bar). Keeping the app in the foreground, but turning screen off via power button - I loose GPS.

I have disabled all battery optimization for OsmAnd and Android Auto.

OsmAnd~ Version: 4.7.17 (F-Droid version, installed with King Installer to make available in AA) Location Permission: Allow only while using the app (Always Allow is not available like it is for Google Maps) Location Source: (don't know - setting not available in F-Droid version) Android Auto: 12.2.642414-release Android version: Android 12 Device model: Xiaomi Poco X3 NFC w/ Stock MIUI Global 14.0.5.0

I notice I am using Xiaomi like OP although different OS version. Could this be a MIUI issue? Unfortunately I don't have another Android 12 device to test at the moment.