mapzen / eraser-map

Privacy-focused mapping application for Android
GNU General Public License v3.0
74 stars 24 forks source link

Fix Crash #745

Closed sarahsnow1 closed 7 years ago

sarahsnow1 commented 7 years ago

Overview

This PR fixes a crash caused by the LostApiClient being unexpectedly disconnected. It updates the MapzenLocationImpl to unregister the listener it registers when stopLocationUpdates() is called instead of disconnecting the client. This behavior is more symmetrical to startLocationUpdates().

Proposed Changes

When the app launches both the SDK and EM create and connect LostApiClients. The first time a route starts, the SDK's client is disconnected when the "find me" button is hidden (this is expected), EM's client remains connected, and location updates are registered for (also expected). When the user backs out of a route, location updates are stopped and EM's client is disconnected (unexpected) but the underlying service remains connected because the SDK's client is connected. Then, the next time a route is started, onClickStartNavigation checks that the client is connected (it is because the SDK's client is). Then, before location updates are registered for, the "find me" button is hidden and because no other clients are connected, the service is disconnected. This PR prevents the LostApiClient connection state from being modified after it is checked by keeping EM's client connected.

Closes #740