forked from upstream-mirrors/OpenTracks
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:
-4
@@ -3,7 +3,6 @@ package de.dennisguse.opentracks.services.handlers;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -28,9 +27,6 @@ public class TrackPointCreatorTest {
|
||||
@Mock
|
||||
private GPSHandler locationHandler;
|
||||
|
||||
@Mock
|
||||
private SharedPreferences sharedPreferences;
|
||||
|
||||
private TrackPointCreator subject;
|
||||
|
||||
@Before
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user