Bug fixing and refactoring:

1) Make sure no one but service changes recordingTrackId (which is owned by it)
2) Cache sharedPreferences
3) Clear recordingTrackId if it doesn't correspond to a valid track or the service is not recording
4) More unit tests
This commit is contained in:
Bartlomiej Niechwiej
2010-10-28 22:49:01 -07:00
parent dc8ee5943c
commit a0f090a83a
4 changed files with 49 additions and 69 deletions
@@ -662,6 +662,11 @@ public class TrackRecordingService extends Service implements LocationListener {
if (recordingTrack != null) {
restoreStats(recordingTrack);
isRecording = true;
} else {
// Make sure we have consistent state in shared preferences.
Log.w(MyTracksConstants.TAG, "TrackRecordingService.onCreate: Resetting "
+ "an orphaned recording track: " + recordingTrackId);
prefManager.setRecordingTrack(recordingTrackId = -1);
}
showNotification();
}