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.
|
||||
*/
|
||||
public void resumeTrack(Track.Id trackId) {
|
||||
trackPointCreator.resetSensorData();
|
||||
trackPointCreator.reset();
|
||||
trackRecordingManager.resume(trackId, trackPointCreator.createSegmentStartManual());
|
||||
|
||||
// Set recording status
|
||||
|
||||
@@ -162,14 +162,12 @@ public class GPSHandler implements LocationListener, GpsStatus.GpsStatusListener
|
||||
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
|
||||
public void onGpsStatusChanged(GpsStatusValue prevStatus, GpsStatusValue currentStatus) {
|
||||
trackPointCreator.sendGpsStatus(currentStatus);
|
||||
}
|
||||
|
||||
void reset() {
|
||||
lastTrackPoint = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,13 +70,14 @@ public class TrackPointCreator implements BluetoothRemoteSensorManager.SensorDat
|
||||
gpsHandler.onStop();
|
||||
}
|
||||
|
||||
public void resetSensorData() {
|
||||
public void reset() {
|
||||
if (remoteSensorManager == null || altitudeSumManager == null) {
|
||||
Log.d(TAG, "No recording running and no reset necessary.");
|
||||
return;
|
||||
}
|
||||
remoteSensorManager.reset();
|
||||
altitudeSumManager.reset();
|
||||
gpsHandler.reset();
|
||||
}
|
||||
|
||||
private SensorDataSet fill(TrackPoint trackPoint) {
|
||||
@@ -123,7 +124,7 @@ public class TrackPointCreator implements BluetoothRemoteSensorManager.SensorDat
|
||||
|
||||
boolean stored = service.newTrackPoint(trackPoint, gpsHandler.getThresholdHorizontalAccuracy());
|
||||
if (stored) {
|
||||
resetSensorData();
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +135,7 @@ public class TrackPointCreator implements BluetoothRemoteSensorManager.SensorDat
|
||||
public TrackPoint createSegmentEnd() {
|
||||
TrackPoint segmentEnd = TrackPoint.createSegmentEndWithTime(createNow());
|
||||
fill(segmentEnd);
|
||||
resetSensorData();
|
||||
reset();
|
||||
return segmentEnd;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user