Skip to content
This repository has been archived by the owner on Apr 23, 2023. It is now read-only.

Location Provider keeps showing after HIGH_POWER updates are removed #213

Closed
tobrun opened this issue Jun 1, 2017 · 14 comments
Closed

Location Provider keeps showing after HIGH_POWER updates are removed #213

tobrun opened this issue Jun 1, 2017 · 14 comments
Assignees

Comments

@tobrun
Copy link

tobrun commented Jun 1, 2017

Description

Location provider icon in status bar keeps showing after removing HIGH_POWER location updates while using two lost api clients.

Steps to Reproduce

Have 2 components with each one lost api client. The first component is started when the application is created and requests NO_POWER updates as long as the application lives. The second component is started for a specific activity and requests HIGH_POWER updates. When that activity is destroyed we remove the location request but the location provider keeps showing. Only killing the application resolves this.

LMK if you need more information.

Lost & Android Version

LOST 3.0.0, Android API 25

@tobrun
Copy link
Author

tobrun commented Jun 1, 2017

cc @sarahlensing

@msmollin
Copy link
Contributor

msmollin commented Jun 1, 2017

Thanks for the write up @tobrun! We'll look into this today.

@msmollin msmollin added the ready label Jun 1, 2017
@sarahsnow1
Copy link
Contributor

This is a side-effect of code we overlooked when we migrated Lost to support multiple clients. We are currently pretty aggressive when it comes to requesting updates (we request them with the highest frequency among all client requests) and we don't remove them in cases like above (see reference).

I'll circle back to implementing a fix for this in a couple days (after we get an upcoming Android SDK release out). Thanks for the clear issue!

@zugaldia
Copy link

zugaldia commented Jun 5, 2017

@sarahlensing @msmollin Thank you for the quick 👀 and update on this issue. Are there any workarounds that we could use on our end meanwhile to remove those location requests?

@sarahsnow1 sarahsnow1 self-assigned this Jun 6, 2017
@sarahsnow1
Copy link
Contributor

@zugaldia You could disconnect and reconnect the NO_POWER client when the HIGH_POWER one disconnects

@tobrun
Copy link
Author

tobrun commented Jun 6, 2017

@sarahlensing seeing the same behaviour with that in place.
If needed I can whip up a small test application to reproduce.

@ecgreb
Copy link
Collaborator

ecgreb commented Jun 6, 2017

A quick look at the logic in FusionEngine to register for location updates makes me think there should be an else block here to disable GPS updates if no interval is currently set.

@sarahsnow1
Copy link
Contributor

@tobrun When you "disconnect and reconnect" the NO_POWER client are you removing location updates requested by that client?

So, something like this:

noPowerClient.connect();

//noPowerClient onConnected
LocationRequest request = LocationRequest.create()
                .setPriority(LocationRequest.PRIORITY_NO_POWER)
                .setFastestInterval(0)
                .setSmallestDisplacement(0)
                .setInterval(1000);
LocationServices.FusedLocationApi.requestLocationUpdates(noPowerClient, request, noPowerListener);

highPriorityClient.connect();

// highPriorityClient onConnected
LocationRequest request = LocationRequest.create()
                .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
                .setFastestInterval(0)
                .setSmallestDisplacement(0)
                .setInterval(1000); 

LocationServices.FusedLocationApi.requestLocationUpdates(highPriorityClient, request, highPriorityListener);

//highPriorityClient shutdown
LocationServices.FusedLocationApi.removeLocationUpdates(highPriorityClient, highPriorityListener);

//noPower shutdown
LocationServices.FusedLocationApi.removeLocationUpdates(noPowerClient, noPowerListener);

//noPower restart
highPriorityClient.connect();

@ecgreb I'm going down the path of splitting LocationEngine#setRequest into addRequest and removeRequest and leaving enable/disable alone (bc there isn't a way to remove updates on a priority-based level with LocationManager). removeRequest will disable the engine and then re-enable it if there are still requests left. There will be a PR soon for review, I'd love your eyes on it

@ecgreb
Copy link
Collaborator

ecgreb commented Jun 7, 2017

@sarahlensing sounds good!

@tobrun
Copy link
Author

tobrun commented Jun 7, 2017

@sarahlensing looks like you've identified the root issue, happy to help test a potential fix. Re. the workaround, while this could resolve the issue within our SDK, it will not resolve the issue of an end developer using his own LOST client.

@sarahsnow1
Copy link
Contributor

@tobrun There is a 3.0.1-SNAPSHOT deployed now, so if you want to test, just pull that down. A PR is also up, feel free to give feedback!

@tobrun
Copy link
Author

tobrun commented Jun 8, 2017

Initial tests aren't showing the issue in OP, with mapbox/mapbox-gl-native#9142 we're addressing the issue, we'd like to do a release candidate to verify the issues is no longer present and help our devs verify it on their end, do you have any plans for a patch release that we could include?

@sarahsnow1
Copy link
Contributor

Great!

A patch release is planned for the beginning of next week.

@sarahsnow1
Copy link
Contributor

sarahsnow1 commented Jun 19, 2017

3.0.1 release is out https://github.com/mapzen/lost/releases/tag/lost-3.0.1

Thanks for everyone's help and patience

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants