Skip to content
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

Crashes due to missing LocationService null checks #257

Closed
ivosabev opened this issue Aug 2, 2018 · 3 comments
Closed

Crashes due to missing LocationService null checks #257

ivosabev opened this issue Aug 2, 2018 · 3 comments

Comments

@ivosabev
Copy link

ivosabev commented Aug 2, 2018

There are multiple errors reported where the LocationService is referenced when it was killed by the system and its value is null.

Examples:
#232
#201

It seems that it is due calling methods on mService without a null check in common/src/main/java/com/marianhello/bgloc/BackgroundGeolocationFacade

Examples:

public void switchMode(final int mode) {
    synchronized (mLock) {
        mService.executeProviderCommand(LocationProvider.CMD_SWITCH_MODE, mode);
    }
}

public void sendCommand(final int commandId) {
    synchronized (mLock) {
        mService.executeProviderCommand(commandId, 0);
    }
}

In general in Android you can never expect the Service to be running, since the system kills them at a whim. I think the least to do is add a null check. I can submit a pull request, but wanted to check if this is okay with you @mauron85 or you want to look for a better solution with some recovery scenario.

@mauron85
Copy link
Owner

mauron85 commented Aug 8, 2018

Yes, please submit PR.

@ivosabev
Copy link
Author

Seems code has changed significantly since then, I will close the issue.

@ivosabev
Copy link
Author

I actually found a place where a null check is missing and submitted a PR (mauron85/background-geolocation-android#17)

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

No branches or pull requests

2 participants