announce called after getting recordingTrackId. Fixed a potencial race condition.

This commit is contained in:
Román Martínez
2021-04-17 16:41:34 +02:00
committed by Dennis Guse
parent 99126fa357
commit 772dad4837
@@ -146,9 +146,9 @@ public class AnnouncementPeriodicTask implements PeriodicTask {
@Override
public void onTrackRecordingId(Track.Id trackId) {
recordingTrackId = trackId;
announce(trackRecordingService.getTrackStatistics());
}
});
announce(trackRecordingService.getTrackStatistics());
}
/**
@@ -181,7 +181,11 @@ public class AnnouncementPeriodicTask implements PeriodicTask {
}
Track track = contentProviderUtils.getTrack(recordingTrackId);
String category = track != null ? track.getCategory() : "";
if (track == null) {
Log.i(TAG, "It doesn't exists a track with trackid = " + recordingTrackId);
return;
}
String category = track.getCategory();
//TODO Querying all TrackPoints all the time is inefficient; use TrackDataHub or something else.
TrackPointIterator trackPointIterator = contentProviderUtils.getTrackPointLocationIterator(track.getId(), null);