Recording data from BLE sensors alone (need to provide distance).

GPS is optional in this case, but no coordinates will be available.

Naive implementation tries to store data every second using the UI timer.

Part of #500.
This commit is contained in:
Dennis Guse
2021-11-21 15:10:13 +01:00
parent 24b638aa30
commit ba66c45005
5 changed files with 12 additions and 6 deletions
@@ -142,7 +142,7 @@ class TrackRecordingManager {
photoUrl = photoUrl != null ? photoUrl : "";
// Insert marker
Marker marker = new Marker(name, description, category, icon, trackId, getTrackStatistics(), lastStoredTrackPoint, photoUrl);
Marker marker = new Marker(name, description, category, icon, trackId, getTrackStatistics(), lastStoredTrackPointWithLocation, photoUrl);
Uri uri = contentProviderUtils.insertMarker(marker);
return new Marker.Id(ContentUris.parseId(uri));
}
@@ -87,6 +87,8 @@ public class TrackRecordingService extends Service implements TrackPointCreator.
@Override
public void run() {
updateRecordingDataWhileRecording();
trackPointCreator.onNewTrackPointWithoutGPS(); //TODO Should not be called every second, right? + with do some duplicate computation with updateRecordingDataWhileRecording().
Handler localHandler = TrackRecordingService.this.handler;
if (localHandler == null) {
// when this happens, no recording is running and we should not send any notifications.
@@ -158,6 +158,10 @@ public class GPSHandler implements LocationListener, GpsStatus.GpsStatusListener
return lastTrackPoint;
}
Distance getThresholdHorizontalAccuracy() {
return thresholdHorizontalAccuracy;
}
/**
* Called from {@link GpsStatus} to inform that GPS status has changed from prevStatus to currentStatus.
*
@@ -101,7 +101,7 @@ public class TrackPointCreator {
gpsHandler.onSharedPreferenceChanged(key);
}
public void onNewTrackPoint(TrackPoint trackPoint, Distance thresholdHorizontalAccuracy) {
public synchronized void onNewTrackPoint(@NonNull TrackPoint trackPoint, @NonNull Distance thresholdHorizontalAccuracy) {
fill(trackPoint);
boolean stored = service.newTrackPoint(trackPoint, thresholdHorizontalAccuracy);
@@ -110,6 +110,10 @@ public class TrackPointCreator {
}
}
public void onNewTrackPointWithoutGPS() {
onNewTrackPoint(new TrackPoint(TrackPoint.Type.SENSORPOINT, createNow()), gpsHandler.getThresholdHorizontalAccuracy());
}
public TrackPoint createSegmentStartManual() {
return TrackPoint.createSegmentStartManualWithTime(createNow());
}