Use system time instead of GPS-provided time.

#316.
This commit is contained in:
Dennis Guse
2020-12-22 21:41:04 +01:00
parent fcc17413e3
commit bc66cd33a9
8 changed files with 49 additions and 106 deletions
@@ -1,7 +1,5 @@
package de.dennisguse.opentracks.util;
import android.util.Log;
import androidx.annotation.NonNull;
import de.dennisguse.opentracks.content.data.TrackPoint;
@@ -16,27 +14,6 @@ public class TrackPointUtils {
private TrackPointUtils() {
}
/**
* 1. Ancient fix for phones that do not set the time in {@link android.location.Location}.
* 2. Fix for GPS time rollover happening every 19.7 years: https://en.wikipedia.org/wiki/GPS_Week_Number_Rollover
*/
public static void fixTime(@NonNull TrackPoint trackPoint) {
if (trackPoint.getTime() == 0L) {
Log.w(TAG, "Time of provided location was 0. Using current time.");
trackPoint.setTime(System.currentTimeMillis());
return;
}
{
long timeDiff = Math.abs(trackPoint.getTime() - System.currentTimeMillis());
if (timeDiff > 1023 * UnitConversions.ONE_WEEK_MS) {
Log.w(TAG, "GPS week rollover.");
trackPoint.setTime(trackPoint.getTime() + 1024 * UnitConversions.ONE_WEEK_MS);
}
}
}
public static boolean isMoving(@NonNull TrackPoint trackPoint) {
return trackPoint.hasSpeed() && trackPoint.getSpeed() >= MAX_NO_MOVEMENT_SPEED;
}