traccar / traccar-client-android

Traccar Client for Android
https://www.traccar.org/client
Apache License 2.0
665 stars 736 forks source link

Implement Android 10/11 Always Location Usage Permission #422

Closed AliMickey closed 3 years ago

AliMickey commented 3 years ago

Is your feature request related to a problem? Please describe. Google introduced a new flow to how location permissions are handled similar to ios. The app must request "Allow while app is in use" permission, then allow to upgrade the location permission. I believe this is not implemented in traccar currently as i do not have the option and my location is not updated in the background. (Yes i have done all battery optimization troubleshooting)

Describe the solution you'd like Add this new permission request to allow location to be used anytime.

Describe alternatives you've considered The persistent notification doesn't even work for me, it still doesn't update the location after a while.

Additional context Add any other context or screenshots about the feature request here.

Link:

tananaev commented 3 years ago

We don't use background location, so I don't think this is needed. I might be wrong.

mentz commented 3 years ago

I am also having issues with the app not getting location/sending location to server when the app is on background. The app only sends updates when it is open. Device is Samsung Galaxy M21s with latest software updates (Android 11, One UI Core 3.0).

tananaev commented 3 years ago

Have you checked troubleshooting guide?

mentz commented 3 years ago

Troubleshooting guide had the solution I needed, thanks. It was specific to Samsung devices, the solution was in dontkillmyapp.com.

EDIT: It appears that even following both your troubleshooting guide and dontkillmyapp.com, the app still gets suspended and doesn't send location updates to the server.

AliMickey commented 3 years ago

We don't use background location, so I don't think this is needed. I might be wrong.

check the playstore reviews for the app. Android 11 introduced new permissions, battery optimisation is not the problem here, the app has to be actively be used for location to be updated.

The app needs the location all the time permission. (Snapbridge for Nikon has this as an example)

https://developer.android.com/training/location/permissions#background

tananaev commented 3 years ago

I have read that page many times and this is the part applicable to us:

The system considers your app to be using foreground location if a feature of your app accesses the device's current location in one of the following situations:

  • ...
  • Your app is running a foreground service. ...
AliMickey commented 3 years ago

Ok that is true but what do you mean? Android will still disallow background usage of the app.

Below are my app permissions.

IMG_20210411_171044

Further please look at this: image

Link: https://developer.android.com/about/versions/11/privacy/foreground-services

image

tananaev commented 3 years ago

What i mean is that we don't use location in the background.

AliMickey commented 3 years ago

and there is something obviously wrong with how the app handles it in Android 11.

How is the app not in the background once the user sets the settings and closes (swipes) the app away from recents? That is not foreground???

Do you have an android 11 running device to verify your claims? I understand it is easy for users to lie but i am not the only facing this issue. Android 11 legitimately requires your app to request different permissions for it to function correctly.

If you want evidence, i will fork and make a functioning version of the app with the correct permissions.

tananaev commented 3 years ago

I have a Pixel 4 XL with Android 11, which is pretty much as vanilla as it gets.

AliMickey commented 3 years ago

good to hear, and everything works fine even when you clear from recents and have no notification?

I am on Lineage 18.1 with battery optimization off for traccar client.

tananaev commented 3 years ago

If you have no notification, it won't work. By clearing recents you effectively killing the process.

AliMickey commented 3 years ago

ok but the point i was trying to make from the start was i didnt need a persistent notification in prior android versions (9.0).

tananaev commented 3 years ago

It is possible to implement background location, but it doesn't guarantee regular updates.

AliMickey commented 3 years ago

It seems to be working with the notification, although not 100% ideal as it does clutter up the notification drawer, it is functional.

Perhaps consider editing the description on play store to outline android 11 requirements?

Thanks!

AliMickey commented 3 years ago

Well unfortunately it has stopped working again.

It works throughout the day when my phone has internet connectivity.

However during the night, i turn my data and wifi off until morning, i think this forces the app into the background because of no activity? Attached below is the log and the latest location update is my opening the app.

The app is set to update every 60 seconds.

IMG_20210415_122924.jpg

freman commented 3 years ago

I've got this on two android 11 (pixel 5) phones, same problem, app works for a while with or without notifications turned on, then stops. Gone through all the efforts of making sure the battery management doesn't kill it, doesn't really make a difference.

For a week I've had the "traccar client is running" notification prominently in my notifications list, but traccar shows no updates for 6 days.

AliMickey commented 3 years ago

yeah, my notification is constantly on but after a while i seem to lose connectivity. I've given up, it seems to work for the dev for some reason so i dont think we will be getting a fix.

Will be moving to a different platform anyway.

mentz commented 3 years ago

@AliMickey I'm not interested in switching right now, but I would like to know what alternatives there are to Traccar. Could you share what platform you are going to use?

AliMickey commented 3 years ago

@AliMickey I'm not interested in switching right now, but I would like to know what alternatives there are to Traccar. Could you share what platform you are going to use?

Honestly I'm waiting for iPhone 13 to come out and will seriously consider going back to Apple. Not really a good comparison to Traccar but would be using 'Find My' within that ecosystem.

If I had to stay with self hosting, i might try owntracks.

freman commented 3 years ago

If anyone has tasker, I'm pondering trying to brute force api calls to traccar from that...