forked from upstream-mirrors/OpenTracks
TrackPointCreator needs to reset GPSHandler as it might have been running beforehand.
This commit is contained in:
@@ -239,7 +239,7 @@ public class TrackRecordingService extends Service implements TrackPointCreator.
|
|||||||
* @param trackId the id of the track to be resumed.
|
* @param trackId the id of the track to be resumed.
|
||||||
*/
|
*/
|
||||||
public void resumeTrack(Track.Id trackId) {
|
public void resumeTrack(Track.Id trackId) {
|
||||||
trackPointCreator.resetSensorData();
|
trackPointCreator.reset();
|
||||||
trackRecordingManager.resume(trackId, trackPointCreator.createSegmentStartManual());
|
trackRecordingManager.resume(trackId, trackPointCreator.createSegmentStartManual());
|
||||||
|
|
||||||
// Set recording status
|
// Set recording status
|
||||||
|
|||||||
@@ -162,14 +162,12 @@ public class GPSHandler implements LocationListener, GpsStatus.GpsStatusListener
|
|||||||
return thresholdHorizontalAccuracy;
|
return thresholdHorizontalAccuracy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called from {@link GpsStatus} to inform that GPS status has changed from prevStatus to currentStatus.
|
|
||||||
*
|
|
||||||
* @param prevStatus previous {@link GpsStatusValue}.
|
|
||||||
* @param currentStatus current {@link GpsStatusValue}.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void onGpsStatusChanged(GpsStatusValue prevStatus, GpsStatusValue currentStatus) {
|
public void onGpsStatusChanged(GpsStatusValue prevStatus, GpsStatusValue currentStatus) {
|
||||||
trackPointCreator.sendGpsStatus(currentStatus);
|
trackPointCreator.sendGpsStatus(currentStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
lastTrackPoint = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,13 +70,14 @@ public class TrackPointCreator implements BluetoothRemoteSensorManager.SensorDat
|
|||||||
gpsHandler.onStop();
|
gpsHandler.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetSensorData() {
|
public void reset() {
|
||||||
if (remoteSensorManager == null || altitudeSumManager == null) {
|
if (remoteSensorManager == null || altitudeSumManager == null) {
|
||||||
Log.d(TAG, "No recording running and no reset necessary.");
|
Log.d(TAG, "No recording running and no reset necessary.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
remoteSensorManager.reset();
|
remoteSensorManager.reset();
|
||||||
altitudeSumManager.reset();
|
altitudeSumManager.reset();
|
||||||
|
gpsHandler.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
private SensorDataSet fill(TrackPoint trackPoint) {
|
private SensorDataSet fill(TrackPoint trackPoint) {
|
||||||
@@ -123,7 +124,7 @@ public class TrackPointCreator implements BluetoothRemoteSensorManager.SensorDat
|
|||||||
|
|
||||||
boolean stored = service.newTrackPoint(trackPoint, gpsHandler.getThresholdHorizontalAccuracy());
|
boolean stored = service.newTrackPoint(trackPoint, gpsHandler.getThresholdHorizontalAccuracy());
|
||||||
if (stored) {
|
if (stored) {
|
||||||
resetSensorData();
|
reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +135,7 @@ public class TrackPointCreator implements BluetoothRemoteSensorManager.SensorDat
|
|||||||
public TrackPoint createSegmentEnd() {
|
public TrackPoint createSegmentEnd() {
|
||||||
TrackPoint segmentEnd = TrackPoint.createSegmentEndWithTime(createNow());
|
TrackPoint segmentEnd = TrackPoint.createSegmentEndWithTime(createNow());
|
||||||
fill(segmentEnd);
|
fill(segmentEnd);
|
||||||
resetSensorData();
|
reset();
|
||||||
return segmentEnd;
|
return segmentEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user