mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-11 13:33:07 +02:00
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 static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -28,9 +27,6 @@ public class TrackPointCreatorTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private GPSHandler locationHandler;
|
private GPSHandler locationHandler;
|
||||||
|
|
||||||
@Mock
|
|
||||||
private SharedPreferences sharedPreferences;
|
|
||||||
|
|
||||||
private TrackPointCreator subject;
|
private TrackPointCreator subject;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ class TrackRecordingManager {
|
|||||||
photoUrl = photoUrl != null ? photoUrl : "";
|
photoUrl = photoUrl != null ? photoUrl : "";
|
||||||
|
|
||||||
// Insert marker
|
// 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);
|
Uri uri = contentProviderUtils.insertMarker(marker);
|
||||||
return new Marker.Id(ContentUris.parseId(uri));
|
return new Marker.Id(ContentUris.parseId(uri));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,6 +87,8 @@ public class TrackRecordingService extends Service implements TrackPointCreator.
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
updateRecordingDataWhileRecording();
|
updateRecordingDataWhileRecording();
|
||||||
|
trackPointCreator.onNewTrackPointWithoutGPS(); //TODO Should not be called every second, right? + with do some duplicate computation with updateRecordingDataWhileRecording().
|
||||||
|
|
||||||
Handler localHandler = TrackRecordingService.this.handler;
|
Handler localHandler = TrackRecordingService.this.handler;
|
||||||
if (localHandler == null) {
|
if (localHandler == null) {
|
||||||
// when this happens, no recording is running and we should not send any notifications.
|
// 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;
|
return lastTrackPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Distance getThresholdHorizontalAccuracy() {
|
||||||
|
return thresholdHorizontalAccuracy;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called from {@link GpsStatus} to inform that GPS status has changed from prevStatus to currentStatus.
|
* 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);
|
gpsHandler.onSharedPreferenceChanged(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onNewTrackPoint(TrackPoint trackPoint, Distance thresholdHorizontalAccuracy) {
|
public synchronized void onNewTrackPoint(@NonNull TrackPoint trackPoint, @NonNull Distance thresholdHorizontalAccuracy) {
|
||||||
fill(trackPoint);
|
fill(trackPoint);
|
||||||
|
|
||||||
boolean stored = service.newTrackPoint(trackPoint, thresholdHorizontalAccuracy);
|
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() {
|
public TrackPoint createSegmentStartManual() {
|
||||||
return TrackPoint.createSegmentStartManualWithTime(createNow());
|
return TrackPoint.createSegmentStartManualWithTime(createNow());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user