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

Prevent crash due to attempting to unbind service when not currently bound #133

Merged
merged 4 commits into from Oct 24, 2016

Conversation

ecgreb
Copy link
Collaborator

@ecgreb ecgreb commented Oct 24, 2016

Overview

Prevent crash due to attempting to unbind service when not currently bound. Simplify logic to disconnect fused location client and service.

Proposed Changes

  • Combines the responsibilities from LostClientManager.removeClient(LostApiClient) and LostClientManager.disconnect(LostApiClient) into a single method.
  • Actively track whether service is currently bound in FusedLocationProviderApiImpl to prevent attempts to unbind when service is not bound. Fixes IllegalArgumentException.
  • Removes client param to FusedLocationServiceConnectionManager.disconnect() since it was only ever called with null.
  • Removes FusedLocationProviderService.disconnect(LostApiClient) since disconnecting the client is now handled by LostClientManager.removeClient(LostApiClient) called before disconnecting the service.
  • Adds tests for EventCallbacks methods in FusedLocationProviderApiImpl.

Closes #132

@ecgreb ecgreb changed the title 132 disconnect service not bound Prevent crash due to attempting to unbind service when not currently bound Oct 24, 2016
}
@Override public void onDisconnect() {
if (isBound) {
context.unbindService(this);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should set isBound = false here. onServiceDisconnected is not called when the client is unbound normally. According to the docs, onServiceDisconnected is only called when the process hosting the service is killed/crashed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. It appears our crash is coming from when two clients attempt to disconnect at the same time. Updated with the suggested change so the second one will not attempt to call unbindService(this).

@sarahsnow1 sarahsnow1 merged commit 1611a60 into master Oct 24, 2016
@sarahsnow1 sarahsnow1 deleted the 132-disconnect-service-not-bound branch October 24, 2016 20:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants