Skip to content

Commit

Permalink
Set time from system clock correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
gerhardol committed Jul 30, 2023
1 parent 3745587 commit e0ee1b8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/src/main/org/runnerup/tracker/Tracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,10 @@ public void onLocationChanged(@NonNull Location arg0) {

private void onLocationChangedImpl(Location arg0, boolean internal) {
if (!mTimeFromGpsPoints || internal) {
long now = SystemClock.elapsedRealtimeNanos();
arg0.setElapsedRealtimeNanos(now);
long elapsedNs = SystemClock.elapsedRealtimeNanos();
arg0.setElapsedRealtimeNanos(elapsedNs);
long timeMs = System.currentTimeMillis();
arg0.setTime(timeMs);
}

Integer hrValue = getCurrentHRValueElapsed(arg0.getElapsedRealtimeNanos(), MAX_CURRENT_AGE);
Expand Down Expand Up @@ -663,7 +665,7 @@ private void onLocationChangedImpl(Location arg0, boolean internal) {
mElapsedTimeNanos += timeDiffNanos;
mElapsedDistance += distDiff;
}
if (hrValue != null) {
if (hrValue != null && hrValue > 0) {
mHeartbeats += (hrValue * timeDiffNanos) / (double)(60 * 1000 * NANO_IN_MILLI);
mHeartbeatNanos += timeDiffNanos; // TODO handle loss of HRM connection
mMaxHR = Math.max(hrValue, mMaxHR);
Expand Down

0 comments on commit e0ee1b8

Please sign in to comment.