Commit 8ef8ff1d authored by Chris Scott's avatar Chris Scott

Transmit isMoving state from plugin->service in case setConfig is executed,...

Transmit isMoving state from plugin->service in case setConfig is executed, which must stop/start the service to apply the new config -- we don't want to put the service in stationary-mode if it's already in moving mode
parent 3b3a8959
...@@ -33,6 +33,7 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin { ...@@ -33,6 +33,7 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin {
private Boolean isEnabled = false; private Boolean isEnabled = false;
private Boolean stopOnTerminate = false; private Boolean stopOnTerminate = false;
private Boolean isMoving = false;
private Intent backgroundServiceIntent; private Intent backgroundServiceIntent;
...@@ -113,6 +114,7 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin { ...@@ -113,6 +114,7 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin {
JSONObject config = data.getJSONObject(0); JSONObject config = data.getJSONObject(0);
Log.i(TAG, "- configure: " + config.toString()); Log.i(TAG, "- configure: " + config.toString());
backgroundServiceIntent.putExtra("isMoving", isMoving);
if (config.has("distanceFilter")) { if (config.has("distanceFilter")) {
backgroundServiceIntent.putExtra("distanceFilter", (float) config.getInt("distanceFilter")); backgroundServiceIntent.putExtra("distanceFilter", (float) config.getInt("distanceFilter"));
} }
...@@ -156,7 +158,6 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin { ...@@ -156,7 +158,6 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin {
public void onPause(boolean multitasking) { public void onPause(boolean multitasking) {
Log.i(TAG, "- onPause"); Log.i(TAG, "- onPause");
if (isEnabled) { if (isEnabled) {
//setPace(isMoving);
EventBus.getDefault().post(new PausedEvent(true)); EventBus.getDefault().post(new PausedEvent(true));
} }
} }
...@@ -176,10 +177,12 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin { ...@@ -176,10 +177,12 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin {
result.setKeepCallback(true); result.setKeepCallback(true);
if (location instanceof StationaryLocation) { if (location instanceof StationaryLocation) {
isMoving = false;
if (stationaryCallback != null) { if (stationaryCallback != null) {
runInBackground(stationaryCallback, result); runInBackground(stationaryCallback, result);
} }
} else { } else {
isMoving = true;
result.setKeepCallback(true); result.setKeepCallback(true);
runInBackground(locationCallback, result); runInBackground(locationCallback, result);
} }
......
...@@ -133,6 +133,7 @@ public class BackgroundGeolocationService extends Service implements GoogleApiCl ...@@ -133,6 +133,7 @@ public class BackgroundGeolocationService extends Service implements GoogleApiCl
activityRecognitionInterval = intent.getIntExtra("activityRecognitionInterval", 60000); activityRecognitionInterval = intent.getIntExtra("activityRecognitionInterval", 60000);
stopTimeout = intent.getLongExtra("stopTimeout", 0); stopTimeout = intent.getLongExtra("stopTimeout", 0);
forceReload = intent.getBooleanExtra("forceReload", false); forceReload = intent.getBooleanExtra("forceReload", false);
isMoving = intent.getBooleanExtra("isMoving", false);
// HTTP Configuration // HTTP Configuration
url = intent.getStringExtra("url"); url = intent.getStringExtra("url");
...@@ -157,6 +158,7 @@ public class BackgroundGeolocationService extends Service implements GoogleApiCl ...@@ -157,6 +158,7 @@ public class BackgroundGeolocationService extends Service implements GoogleApiCl
Log.i(TAG, " stopTimeout: " + stopTimeout); Log.i(TAG, " stopTimeout: " + stopTimeout);
Log.i(TAG, " stopOnTerminate: " + stopOnTerminate); Log.i(TAG, " stopOnTerminate: " + stopOnTerminate);
Log.i(TAG, " forceReload: " + forceReload); Log.i(TAG, " forceReload: " + forceReload);
Log.i(TAG, " isMoving: " + isMoving);
Log.i(TAG, "----------------------------------------"); Log.i(TAG, "----------------------------------------");
// For debug sounds, turn on ToneGenerator. // For debug sounds, turn on ToneGenerator.
...@@ -203,7 +205,9 @@ public class BackgroundGeolocationService extends Service implements GoogleApiCl ...@@ -203,7 +205,9 @@ public class BackgroundGeolocationService extends Service implements GoogleApiCl
Intent locationIntent = new Intent(this, LocationService.class); Intent locationIntent = new Intent(this, LocationService.class);
locationUpdatePI = PendingIntent.getService(this, 0, locationIntent, PendingIntent.FLAG_UPDATE_CURRENT); locationUpdatePI = PendingIntent.getService(this, 0, locationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
setPace(isMoving);
// Start monitoring ARS // Start monitoring ARS
if (googleApiClient.isConnected()) { if (googleApiClient.isConnected()) {
requestActivityUpdates(); requestActivityUpdates();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment