Cleanup: Move current time handling into SensorManager.

This commit is contained in:
Dennis Guse
2026-02-12 11:57:21 +01:00
committed by Dennis Guse
parent 6b4e7d7d9b
commit 24f052491b
2 changed files with 7 additions and 17 deletions
@@ -250,13 +250,16 @@ public class SensorManager implements SharedPreferences.OnSharedPreferenceChange
}
public SensorDataSet getSensorDataSet(Instant now) {
//We always need a Position with now
SensorData<Position> gpsSensorData = gpsHandler.getSensorData(now);
var a = temperatureHandler.getSensorData(now);
var b = altitudeChangeHandler.getSensorData(now);
if (gpsSensorData != null && gpsSensorData.data() != null) {
gpsSensorData = new SensorData<>(gpsSensorData.data().with(now), gpsSensorData.sensorNameOrAddress());
} else {
gpsSensorData = new SensorData<>(Position.of(now), "");
}
return new SensorDataSet(
gpsSensorData != null ? gpsSensorData : new SensorData<>(Position.of(now), ""), //We always need a Position(now)
gpsSensorData,
getSpeed(now),
getDistance(now),
getHeartRate(now),
@@ -2,10 +2,6 @@ package de.dennisguse.opentracks.sensors.sensorData;
import android.location.Location;
import androidx.annotation.NonNull;
import java.time.Instant;
import de.dennisguse.opentracks.data.models.Position;
public class AggregatorGPS extends Aggregator<Location, Position> {
@@ -28,13 +24,4 @@ public class AggregatorGPS extends Aggregator<Location, Position> {
*/
output = null;
}
@NonNull
@Override
public Position getAggregatedValue(Instant now) {
Position value = super.getAggregatedValue(now);
if (value == null) value = Position.empty();
return value.with(now);
}
}