Commit 1d72a53d authored by Chris Scott's avatar Chris Scott

Move initial call to setPace in onStartCommand out if if(intent) {} block. ...

Move initial call to setPace in onStartCommand out if if(intent) {} block.  This may have been causing major issues where tracking fails to start after OS kills service due to lack of memory.  Also return START_REDELIVER_INTENT, which also may have been causing problems
parent 7da0878b
...@@ -58,7 +58,7 @@ public class LocationUpdateService extends Service implements LocationListener { ...@@ -58,7 +58,7 @@ public class LocationUpdateService extends Service implements LocationListener {
private Location lastLocation; private Location lastLocation;
private long lastUpdateTime = 0l; private long lastUpdateTime = 0l;
private String authToken = "HypVBMmDxbh76pHpwots"; private String authToken = "FAKE_TOKEN";
private String url = "http://192.168.2.15:3000/users/current_location.json"; private String url = "http://192.168.2.15:3000/users/current_location.json";
private float stationaryRadius; private float stationaryRadius;
...@@ -73,10 +73,10 @@ public class LocationUpdateService extends Service implements LocationListener { ...@@ -73,10 +73,10 @@ public class LocationUpdateService extends Service implements LocationListener {
private Integer stationaryLocationAttempts = 0; private Integer stationaryLocationAttempts = 0;
private Integer speedAcquisitionAttempts = 0; private Integer speedAcquisitionAttempts = 0;
private Integer desiredAccuracy; private Integer desiredAccuracy = 100;
private Integer distanceFilter; private Integer distanceFilter = 30;
private Integer scaledDistanceFilter; private Integer scaledDistanceFilter;
private Integer locationTimeout; private Integer locationTimeout = 30;
private Boolean isDebugging; private Boolean isDebugging;
private ToneGenerator toneGenerator; private ToneGenerator toneGenerator;
...@@ -141,17 +141,16 @@ public class LocationUpdateService extends Service implements LocationListener { ...@@ -141,17 +141,16 @@ public class LocationUpdateService extends Service implements LocationListener {
desiredAccuracy = Integer.parseInt(intent.getStringExtra("desiredAccuracy")); desiredAccuracy = Integer.parseInt(intent.getStringExtra("desiredAccuracy"));
locationTimeout = Integer.parseInt(intent.getStringExtra("locationTimeout")); locationTimeout = Integer.parseInt(intent.getStringExtra("locationTimeout"));
isDebugging = Boolean.parseBoolean(intent.getStringExtra("isDebugging")); isDebugging = Boolean.parseBoolean(intent.getStringExtra("isDebugging"));
Log.i(TAG, "- url: " + url);
Log.i(TAG, "- token: " + authToken);
Log.i(TAG, "- stationaryRadius: " + stationaryRadius);
Log.i(TAG, "- distanceFilter: " + distanceFilter);
Log.i(TAG, "- desiredAccuracy: " + desiredAccuracy);
Log.i(TAG, "- locationTimeout: " + locationTimeout);
Log.i(TAG, "- isDebugging: " + isDebugging);
this.setPace(false);
} }
Log.i(TAG, "- url: " + url);
Log.i(TAG, "- token: " + authToken);
Log.i(TAG, "- stationaryRadius: " + stationaryRadius);
Log.i(TAG, "- distanceFilter: " + distanceFilter);
Log.i(TAG, "- desiredAccuracy: " + desiredAccuracy);
Log.i(TAG, "- locationTimeout: " + locationTimeout);
Log.i(TAG, "- isDebugging: " + isDebugging);
this.setPace(false);
/** /**
* Experimental cell-location-change handler. Hoping to implement something like ios Significant Changes system * Experimental cell-location-change handler. Hoping to implement something like ios Significant Changes system
* *
...@@ -161,7 +160,7 @@ public class LocationUpdateService extends Service implements LocationListener { ...@@ -161,7 +160,7 @@ public class LocationUpdateService extends Service implements LocationListener {
*/ */
//We want this service to continue running until it is explicitly stopped //We want this service to continue running until it is explicitly stopped
return START_STICKY; return START_REDELIVER_INTENT;
} }
@Override @Override
...@@ -347,7 +346,7 @@ public class LocationUpdateService extends Service implements LocationListener { ...@@ -347,7 +346,7 @@ public class LocationUpdateService extends Service implements LocationListener {
private Integer calculateDistanceFilter(Float speed) { private Integer calculateDistanceFilter(Float speed) {
Double newDistanceFilter = (double) distanceFilter; Double newDistanceFilter = (double) distanceFilter;
if (speed > 3 && speed < 100) { if (speed < 100) {
float roundedDistanceFilter = (round(speed / 5) * 5); float roundedDistanceFilter = (round(speed / 5) * 5);
newDistanceFilter = pow(roundedDistanceFilter, 2) + (double) distanceFilter; newDistanceFilter = pow(roundedDistanceFilter, 2) + (double) distanceFilter;
} }
......
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