-
Notifications
You must be signed in to change notification settings - Fork 590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve location updates without having battery optimizations switched off #420
Comments
I have no idea what you're proposing. Can you be more specific on what you want to see or what you want to change? |
Sorry I didn't make myself clear. At the moment, to get location updates working reliably, you have to disable battery optimisations in the app. This is due to Android 8.0 changes. I think I can remove this limitation by using a foreground service. Without this, the Android system would not allow location updates via the |
The WorkManager option sounds very promising |
It does still receive updates when in the background, just not always at the rate desired. I know you could do a foreground service with a persistent notification but I'm curious why you would want to do that over disabling battery optimizations? Once you do that you have to instruct people how to hide the notification which I think is a worse user experience. If enough people are still not happy with the update rate we still have more options to increase the priority of our location updates: https://github.com/home-assistant/home-assistant-android/blob/master/app/src/main/java/io/homeassistant/companion/android/background/LocationBroadcastReceiver.kt#L208 |
https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest Apparently that is only related to the accuracy and not the rate at which updates happen. Also it does not seem as if there is huge demand for any changes anyway. |
The other issue, moving forward is that in Android 10 they've introduced a new background location permission which is required in order to get location updates in the background.
I don't think this is true. You can make a notification of the lowest priority show as a collapsed notification, though I'd need to double check. |
@Kisty most people don't want an additional undismissable notification and you would need to instruct them on how to hide it completely and not just keep it minimized. To them disabling battery optimizations is a much cleaner route than congesting the notification panel. |
@dshokouhi I see your point. The reason I wanted to try and improve this is for a few reasons.
This came out more as an attempt to standardise the device reporting, starting with locations. I've seen advice on reseting the device tracker which I haven't tried with my wife's phone. |
The problem with simply disabling battery optimizations, is that this doesn't always work....especially after a device is restarted and the app is never launched. |
@dshokouhi Can't you create a low-priority (silent/collapsed) notification when the location update is triggered to happen, then dismiss it once the update is complete? I believe this is how Google Maps handles doing its location updates. |
@KBerstene that notification can be turned off by the user so I don't think its required for location updates, then again we are guessing at this lol. Tasker is a good example because it needs the persistent notification to allow the foreground service to run all the time. I think that as we add more sensors and those sensors update on their own interval (i.e. phone being unplugged) the persistent notification may be needed. If we find that it improves location updates better than disabling battery optimization then I am sure most users will accept it @scottismyname the location service should start up again when you restart the device, if its not please file a separate issue for that because I think its supposed to start on device boot. @Kisty for location check these steps to make sure its able to update as often as it can: https://companion.home-assistant.io/docs/troubleshooting/faqs#location-is-not-updating-in-android-app I also agree that getting more frequent updates would be great too |
Home Assistant Android version: 1.7.1
Android version: 9.0
Phone model: OnePlus 3T
Home Assistant version: 0.105.3
Last working Home Assistant release (if known):
Description of problem: I'm looking at improving background location updates by using the Google codelab as a template. Mainly looking at the background location updates, especially with Android 10 changes. What do you think? https://codelabs.developers.google.com/codelabs/while-in-use-location/index.html#0
Traceback (if applicable):
Additional information:
The text was updated successfully, but these errors were encountered: