Skip to content

Commit

Permalink
Apply stillness check for network and passive locations too
Browse files Browse the repository at this point in the history
  • Loading branch information
mendhak committed May 4, 2015
1 parent ab89422 commit e4074e5
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,7 @@ private void StartGpsManager() {
GetPreferences();

//If the user has been still for more than the minimum seconds
if(Session.getUserStillSinceTimeStamp() > 0
&& (System.currentTimeMillis() - Session.getUserStillSinceTimeStamp()) > (AppSettings.getMinimumSeconds() * 1000)){
if(userHasBeenStillForTooLong()) {
tracer.info("No movement in the past interval, resetting alarm");
SetAlarmForNextPoint();
return;
Expand Down Expand Up @@ -577,6 +576,11 @@ private void StartGpsManager() {
SetStatus(R.string.started);
}

private boolean userHasBeenStillForTooLong() {
return !Session.hasDescription() && !Session.isSinglePointMode() &&
(Session.getUserStillSinceTimeStamp() > 0 && (System.currentTimeMillis() - Session.getUserStillSinceTimeStamp()) > (AppSettings.getMinimumSeconds() * 1000));
}

private void startAbsoluteTimer() {
if (AppSettings.getAbsoluteTimeout() >= 1) {
handler.postDelayed(stopManagerRunnable, AppSettings.getAbsoluteTimeout() * 1000);
Expand Down Expand Up @@ -748,6 +752,13 @@ void OnLocationChanged(Location loc) {
return;
}

//Don't log a point if user has been still
// However, if user has set an annotation, just log the point, disregard any filters
if(userHasBeenStillForTooLong()) {
tracer.info("Received location but the user hasn't moved, ignoring");
return;
}

if(!isFromValidListener(loc)){
return;
}
Expand Down

0 comments on commit e4074e5

Please sign in to comment.