Sublimis / UrbanBiker

Urban Biker issue tracker and Knowledge Base
https://urban-bike-computer.com/
18 stars 4 forks source link

Gps permission "use all time" missing Android 10 #72

Closed momo2xlc closed 4 years ago

momo2xlc commented 4 years ago

On Sony xz2 Android 10 I found an issue according permission to "use GPS all time" there are only the options "decline" and "only use if app is in foreground" that results in stuck on GPS speed measuring. Had have exact same problem with other app but with that app I could change permission to "use GPS all time" and problems where gone.

Sublimis commented 4 years ago

Hi! Can you please explain in more detail "stuck on GPS speed measuring", what exactly happens?

This seems like either a problem of the device, or an unknown bug in our app, as we'll explain now.

To be able to request "Use GPS all the time" permission, the app must be eligible to access locations in the background. On the official Android Developer pages regarding background location permissions it says:

Note: The Google Play store has updated its policy concerning device location, restricting background location access to apps that need it for their core functionality and meet related policy requirements.

Background location access is not a core functionality of our app (we access locations in the foreground service, thus it's not in the background, according to official definition), and so it does not meet the policy. We are not eligible to request background location access permissions -- this would result in the app being removed from the Play Store.

According to Android documentation, our app should be able to work perfectly fine without this permission. That's why this should be either problem of the device XZ2, or a bug in our app, but we cannot tell more without knowing what exactly happens. On a side note, we did test with the Sony XZ2c (which is essentially the same device), and didn't observe any such issue.

We look forward to any additional info about this. Thanks for the feedback!

momo2xlc commented 4 years ago

Uh okay, thank you for the fast response(i have the compact version too) . Let me try to explain, if I start using the app and hit the track record button speed is shown as expected, after some minutes it shows a speed of just a few km/h and finally 0 (GPS indicator shows always green). If I stop and start the track recording, the correct speed is shown again for some minutes. Sometimes it just helps to hit the screen or switch the app to back and then to foreground again. Try to use Google location service and the generic option, try also different GPS refresh rates but didn't help, battery saving stuff is turned off for urban biker. I have had the same issue on "notify and fitness for mi band" but on that app I could use the option "allow gps in background" and this solved the problem.

Sublimis commented 4 years ago

Please try going to Settings > Tracking / GPS > Advanced, and set the CPU sleep policy to "Fully awake". It's not really a proper solution, but it may do the trick.

This sounds like something is disabling location updates system-wide after the screen times out, but without the screen ever going off. Do you have the option "Keep screen on" enabled and "Allow off when inactive" disabled in Settings > Display > General? Also, is your phone rooted by any chance? Maybe there's some utility installed on the phone which would disable locations after timeout.

However, after reading about similar issues on the Internet, e.g.: https://support.google.com/pixelphone/thread/13830819?hl=en, it seems like the only real solution is to wait for an Android update to solve this issue, as many other users with different phones on Android 10 are experiencing the same problems.

Do let us know if the suggestion in the first sentence of this post helped, though. Thanks again!

momo2xlc commented 4 years ago

Okay I'll try first the display settings and after that add I'll check the cpu settings. I figured out that according to the background gps policy - Google maps is maybe violating it itself. Screenshot_20200606-074429

Sublimis commented 4 years ago

No, not necessarily. Google Maps needs background location access for their "core" functionality, e.g. geofencing, so does not violate policy. Most importantly, Google Maps does not even need approval from Google about whether it can use background location access or not.

As for us other developers, they are very keen in removing apps from the Play Store if they don't like something about them. This process is usually automated -- their bots take down suspicious apps automatically, and usually without warning. The process of getting the app back to the Play Store is slow and painstaking, and most often results in developer removing the offending feature from the app, because Google is always right.

Even if we were to add geofencing to our app, we would have hard time proving that it's needed for the core functionality, and probably wouldn't succeed. Thus, although it may seem easy, we really do not want to mess around with requesting background location access at this time. 😞

Please let us know if some of the settings suggested earlier help, thanks!

momo2xlc commented 4 years ago

Hi got news, it isn't the fault of gps in direct, I tried urban biker in my car and it works fine, so in the car there is no cadenz sensor that's why I decided to disable it in the app and voila got continuously gps speed so there could be some conflict between. It was just a short run so I'll try next time to go longer to clarify.

Sublimis commented 4 years ago

Hi, was just about to ask whether you use any sensor or not! As it turns out, Android 10 requires from app which uses wireless sensors in a Service to declare this fact in its manifest, and we forgot to do that. The developer documentation regarding this is really poor, so it was an honest mistake.

If you originally experienced this issue while getting speeds from a step cadence sensor (and not when using GPS-only speed), this would explain the issue. The next app release will have this fixed (both regular and beta release, which should be published soon).

Thanks for the feedback!

momo2xlc commented 4 years ago

Hey nice you got a point to start, on a yesterday long ride I couldn't verify that turning off the cadenz sensor work but I suppose that the issue is connected with this. I ordered another sensor wich I would use for speed measuring and like to try this later that day. Thanks for the great support.

momo2xlc commented 4 years ago

Hi there discovered a solution for me this morning, if I turn off all other GPS speed related apps (in my case "notify & fitness" and google maps) in background I'm able to get constant speed readings in urban biker with cadence sensor enabled, GPS-CPU in automatic mode, GPS provider: google play and display keep alive settings, maybe that helps. - should I close the issue or change title?

momo2xlc commented 4 years ago

Hi, it's me again, today tested successfully the new version 5.101 on my road bike (just gps and cadence) running in background another app which access GPS sensor too (which leads in trouble as mentioned before on my randonneur) and have had no issues 👍 great work.