Skip to content

Commit

Permalink
Make sure mService exists when we call start or stop (#17)
Browse files Browse the repository at this point in the history
Make sure mService exists when we call start or stop
  • Loading branch information
ivosabev authored and mauron85 committed Sep 29, 2018
1 parent 07df724 commit 08374b8
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,17 @@ public BackgroundLocation getCurrentLocation(int timeout, long maximumAge, boole

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

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

Expand Down Expand Up @@ -519,14 +523,18 @@ public void registerHeadlessTask(final String jsFunction) {
private void startBackgroundService() {
logger.info("Attempt to start bg service");
synchronized (mLock) {
mService.start();
if (mService != null) {
mService.start();
}
}
}

private void stopBackgroundService() {
logger.info("Attempt to stop bg service");
synchronized (mLock) {
mService.stop();
if (mService != null) {
mService.stop();
}
}
}

Expand Down

0 comments on commit 08374b8

Please sign in to comment.