forked from upstream-mirrors/OpenTracks
Code formatting.
This commit is contained in:
+39
-82
@@ -89,8 +89,7 @@ public class TrackRecordingService extends Service {
|
|||||||
* The name of extra intent property to indicate whether we want to resume a
|
* The name of extra intent property to indicate whether we want to resume a
|
||||||
* previously recorded track.
|
* previously recorded track.
|
||||||
*/
|
*/
|
||||||
public static final String
|
public static final String RESUME_TRACK_EXTRA_NAME = "com.google.android.apps.mytracks.RESUME_TRACK";
|
||||||
RESUME_TRACK_EXTRA_NAME = "com.google.android.apps.mytracks.RESUME_TRACK";
|
|
||||||
|
|
||||||
public static final double PAUSE_LATITUDE = 100.0;
|
public static final double PAUSE_LATITUDE = 100.0;
|
||||||
public static final double RESUME_LATITUDE = 200.0;
|
public static final double RESUME_LATITUDE = 200.0;
|
||||||
@@ -103,8 +102,7 @@ public class TrackRecordingService extends Service {
|
|||||||
private static final String TAG = TrackRecordingService.class.getSimpleName();
|
private static final String TAG = TrackRecordingService.class.getSimpleName();
|
||||||
|
|
||||||
// 1 minute in milliseconds
|
// 1 minute in milliseconds
|
||||||
private static final long ONE_MINUTE = (long) (UnitConversions.MIN_TO_S
|
private static final long ONE_MINUTE = (long) (UnitConversions.MIN_TO_S * UnitConversions.S_TO_MS);
|
||||||
* UnitConversions.S_TO_MS);
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final int MAX_AUTO_RESUME_TRACK_RETRY_ATTEMPTS = 3;
|
static final int MAX_AUTO_RESUME_TRACK_RETRY_ATTEMPTS = 3;
|
||||||
@@ -142,12 +140,10 @@ public class TrackRecordingService extends Service {
|
|||||||
* Note that sharedPreferenceChangeListener cannot be an anonymous inner
|
* Note that sharedPreferenceChangeListener cannot be an anonymous inner
|
||||||
* class. Anonymous inner class will get garbage collected.
|
* class. Anonymous inner class will get garbage collected.
|
||||||
*/
|
*/
|
||||||
private final OnSharedPreferenceChangeListener
|
private final OnSharedPreferenceChangeListener sharedPreferenceChangeListener = new OnSharedPreferenceChangeListener() {
|
||||||
sharedPreferenceChangeListener = new OnSharedPreferenceChangeListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
|
||||||
if (key == null
|
if (key == null || key.equals(PreferencesUtils.getKey(context, R.string.recording_track_id_key))) {
|
||||||
|| key.equals(PreferencesUtils.getKey(context, R.string.recording_track_id_key))) {
|
|
||||||
long trackId = PreferencesUtils.getLong(context, R.string.recording_track_id_key);
|
long trackId = PreferencesUtils.getLong(context, R.string.recording_track_id_key);
|
||||||
/*
|
/*
|
||||||
* Only through the TrackRecordingService can one stop a recording
|
* Only through the TrackRecordingService can one stop a recording
|
||||||
@@ -163,24 +159,20 @@ public class TrackRecordingService extends Service {
|
|||||||
R.string.recording_track_paused_key,
|
R.string.recording_track_paused_key,
|
||||||
PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT);
|
PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT);
|
||||||
}
|
}
|
||||||
if (key == null
|
if (key == null || key.equals(PreferencesUtils.getKey(context, R.string.stats_units_key))) {
|
||||||
|| key.equals(PreferencesUtils.getKey(context, R.string.stats_units_key))) {
|
|
||||||
boolean metricUnits = PreferencesUtils.isMetricUnits(context);
|
boolean metricUnits = PreferencesUtils.isMetricUnits(context);
|
||||||
voiceExecutor.setMetricUnits(metricUnits);
|
voiceExecutor.setMetricUnits(metricUnits);
|
||||||
splitExecutor.setMetricUnits(metricUnits);
|
splitExecutor.setMetricUnits(metricUnits);
|
||||||
}
|
}
|
||||||
if (key == null
|
if (key == null || key.equals(PreferencesUtils.getKey(context, R.string.voice_frequency_key))) {
|
||||||
|| key.equals(PreferencesUtils.getKey(context, R.string.voice_frequency_key))) {
|
|
||||||
voiceExecutor.setTaskFrequency(PreferencesUtils.getInt(
|
voiceExecutor.setTaskFrequency(PreferencesUtils.getInt(
|
||||||
context, R.string.voice_frequency_key, PreferencesUtils.VOICE_FREQUENCY_DEFAULT));
|
context, R.string.voice_frequency_key, PreferencesUtils.VOICE_FREQUENCY_DEFAULT));
|
||||||
}
|
}
|
||||||
if (key == null
|
if (key == null || key.equals(PreferencesUtils.getKey(context, R.string.split_frequency_key))) {
|
||||||
|| key.equals(PreferencesUtils.getKey(context, R.string.split_frequency_key))) {
|
|
||||||
splitExecutor.setTaskFrequency(PreferencesUtils.getInt(
|
splitExecutor.setTaskFrequency(PreferencesUtils.getInt(
|
||||||
context, R.string.split_frequency_key, PreferencesUtils.SPLIT_FREQUENCY_DEFAULT));
|
context, R.string.split_frequency_key, PreferencesUtils.SPLIT_FREQUENCY_DEFAULT));
|
||||||
}
|
}
|
||||||
if (key == null || key.equals(
|
if (key == null || key.equals(PreferencesUtils.getKey(context, R.string.min_recording_interval_key))) {
|
||||||
PreferencesUtils.getKey(context, R.string.min_recording_interval_key))) {
|
|
||||||
int minRecordingInterval = PreferencesUtils.getInt(context, R.string.min_recording_interval_key, PreferencesUtils.MIN_RECORDING_INTERVAL_DEFAULT);
|
int minRecordingInterval = PreferencesUtils.getInt(context, R.string.min_recording_interval_key, PreferencesUtils.MIN_RECORDING_INTERVAL_DEFAULT);
|
||||||
switch (minRecordingInterval) {
|
switch (minRecordingInterval) {
|
||||||
case PreferencesUtils.MIN_RECORDING_INTERVAL_ADAPT_BATTERY_LIFE:
|
case PreferencesUtils.MIN_RECORDING_INTERVAL_ADAPT_BATTERY_LIFE:
|
||||||
@@ -195,29 +187,17 @@ public class TrackRecordingService extends Service {
|
|||||||
locationListenerPolicy = new AbsoluteLocationListenerPolicy(minRecordingInterval * UnitConversions.ONE_SECOND);
|
locationListenerPolicy = new AbsoluteLocationListenerPolicy(minRecordingInterval * UnitConversions.ONE_SECOND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (key == null || key.equals(
|
if (key == null || key.equals(PreferencesUtils.getKey(context, R.string.recording_distance_interval_key))) {
|
||||||
PreferencesUtils.getKey(context, R.string.recording_distance_interval_key))) {
|
recordingDistanceInterval = PreferencesUtils.getInt(context, R.string.recording_distance_interval_key, PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT);
|
||||||
recordingDistanceInterval = PreferencesUtils.getInt(context,
|
|
||||||
R.string.recording_distance_interval_key,
|
|
||||||
PreferencesUtils.RECORDING_DISTANCE_INTERVAL_DEFAULT);
|
|
||||||
}
|
}
|
||||||
if (key == null || key.equals(
|
if (key == null || key.equals(PreferencesUtils.getKey(context, R.string.max_recording_distance_key))) {
|
||||||
PreferencesUtils.getKey(context, R.string.max_recording_distance_key))) {
|
maxRecordingDistance = PreferencesUtils.getInt(context, R.string.max_recording_distance_key, PreferencesUtils.MAX_RECORDING_DISTANCE_DEFAULT);
|
||||||
maxRecordingDistance = PreferencesUtils.getInt(context,
|
|
||||||
R.string.max_recording_distance_key,
|
|
||||||
PreferencesUtils.MAX_RECORDING_DISTANCE_DEFAULT);
|
|
||||||
}
|
}
|
||||||
if (key == null || key.equals(
|
if (key == null || key.equals(PreferencesUtils.getKey(context, R.string.recording_gps_accuracy_key))) {
|
||||||
PreferencesUtils.getKey(context, R.string.recording_gps_accuracy_key))) {
|
recordingGpsAccuracy = PreferencesUtils.getInt(context, R.string.recording_gps_accuracy_key, PreferencesUtils.RECORDING_GPS_ACCURACY_DEFAULT);
|
||||||
recordingGpsAccuracy = PreferencesUtils.getInt(context,
|
|
||||||
R.string.recording_gps_accuracy_key,
|
|
||||||
PreferencesUtils.RECORDING_GPS_ACCURACY_DEFAULT);
|
|
||||||
}
|
}
|
||||||
if (key == null || key.equals(
|
if (key == null || key.equals(PreferencesUtils.getKey(context, R.string.auto_resume_track_timeout_key))) {
|
||||||
PreferencesUtils.getKey(context, R.string.auto_resume_track_timeout_key))) {
|
autoResumeTrackTimeout = PreferencesUtils.getInt(context,R.string.auto_resume_track_timeout_key, PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_DEFAULT);
|
||||||
autoResumeTrackTimeout = PreferencesUtils.getInt(context,
|
|
||||||
R.string.auto_resume_track_timeout_key,
|
|
||||||
PreferencesUtils.AUTO_RESUME_TRACK_TIMEOUT_DEFAULT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -416,20 +396,15 @@ public class TrackRecordingService extends Service {
|
|||||||
if (waypointCreationRequest.getName() != null) {
|
if (waypointCreationRequest.getName() != null) {
|
||||||
name = waypointCreationRequest.getName();
|
name = waypointCreationRequest.getName();
|
||||||
} else {
|
} else {
|
||||||
int nextWaypointNumber = myTracksProviderUtils.getNextWaypointNumber(
|
int nextWaypointNumber = myTracksProviderUtils.getNextWaypointNumber(recordingTrackId, waypointType);
|
||||||
recordingTrackId, waypointType);
|
|
||||||
if (nextWaypointNumber == -1) {
|
if (nextWaypointNumber == -1) {
|
||||||
nextWaypointNumber = 0;
|
nextWaypointNumber = 0;
|
||||||
}
|
}
|
||||||
name = getString(
|
name = getString(isStatistics ? R.string.marker_split_name_format : R.string.marker_name_format, nextWaypointNumber);
|
||||||
isStatistics ? R.string.marker_split_name_format : R.string.marker_name_format,
|
|
||||||
nextWaypointNumber);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get category
|
// Get category
|
||||||
String category = waypointCreationRequest.getCategory() != null ? waypointCreationRequest
|
String category = waypointCreationRequest.getCategory() != null ? waypointCreationRequest.getCategory() : "";
|
||||||
.getCategory()
|
|
||||||
: "";
|
|
||||||
|
|
||||||
// Get tripStatistics, description, and icon
|
// Get tripStatistics, description, and icon
|
||||||
TripStatistics tripStatistics;
|
TripStatistics tripStatistics;
|
||||||
@@ -444,9 +419,8 @@ public class TrackRecordingService extends Service {
|
|||||||
icon = getString(R.string.marker_statistics_icon_url);
|
icon = getString(R.string.marker_statistics_icon_url);
|
||||||
} else {
|
} else {
|
||||||
tripStatistics = null;
|
tripStatistics = null;
|
||||||
description = waypointCreationRequest.getDescription() != null ? waypointCreationRequest
|
description = waypointCreationRequest.getDescription() != null ? waypointCreationRequest.getDescription() : "";
|
||||||
.getDescription()
|
//TODO Bundle icon?
|
||||||
: "";
|
|
||||||
icon = getString(R.string.marker_waypoint_icon_url);
|
icon = getString(R.string.marker_waypoint_icon_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,13 +444,10 @@ public class TrackRecordingService extends Service {
|
|||||||
duration = 0L;
|
duration = 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
String photoUrl = waypointCreationRequest.getPhotoUrl() != null ? waypointCreationRequest
|
String photoUrl = waypointCreationRequest.getPhotoUrl() != null ? waypointCreationRequest.getPhotoUrl() : "";
|
||||||
.getPhotoUrl()
|
|
||||||
: "";
|
|
||||||
|
|
||||||
// Insert waypoint
|
// Insert waypoint
|
||||||
Waypoint waypoint = new Waypoint(name, description, category, icon, recordingTrackId,
|
Waypoint waypoint = new Waypoint(name, description, category, icon, recordingTrackId, waypointType, length, duration, -1L, -1L, location, tripStatistics, photoUrl);
|
||||||
waypointType, length, duration, -1L, -1L, location, tripStatistics, photoUrl);
|
|
||||||
Uri uri = myTracksProviderUtils.insertWaypoint(waypoint);
|
Uri uri = myTracksProviderUtils.insertWaypoint(waypoint);
|
||||||
return Long.parseLong(uri.getLastPathSegment());
|
return Long.parseLong(uri.getLastPathSegment());
|
||||||
}
|
}
|
||||||
@@ -522,12 +493,10 @@ public class TrackRecordingService extends Service {
|
|||||||
*/
|
*/
|
||||||
private void handleStartCommand(Intent intent, int startId) {
|
private void handleStartCommand(Intent intent, int startId) {
|
||||||
// Check if the service is called to resume track (from phone reboot)
|
// Check if the service is called to resume track (from phone reboot)
|
||||||
if (intent != null && intent.getBooleanExtra(RESUME_TRACK_EXTRA_NAME, false)) {
|
if (intent != null && intent.getBooleanExtra(RESUME_TRACK_EXTRA_NAME, false) && !shouldResumeTrack()) {
|
||||||
if (!shouldResumeTrack()) {
|
Log.i(TAG, "Stop resume track.");
|
||||||
Log.i(TAG, "Stop resume track.");
|
updateRecordingState(PreferencesUtils.RECORDING_TRACK_ID_DEFAULT, true);
|
||||||
updateRecordingState(PreferencesUtils.RECORDING_TRACK_ID_DEFAULT, true);
|
stopSelfResult(startId);
|
||||||
stopSelfResult(startId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -541,8 +510,7 @@ public class TrackRecordingService extends Service {
|
|||||||
Log.d(TAG, "Not resuming. Track is null.");
|
Log.d(TAG, "Not resuming. Track is null.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int retries = PreferencesUtils.getInt(this, R.string.auto_resume_track_current_retry_key,
|
int retries = PreferencesUtils.getInt(this, R.string.auto_resume_track_current_retry_key, PreferencesUtils.AUTO_RESUME_TRACK_CURRENT_RETRY_DEFAULT);
|
||||||
PreferencesUtils.AUTO_RESUME_TRACK_CURRENT_RETRY_DEFAULT);
|
|
||||||
if (retries >= MAX_AUTO_RESUME_TRACK_RETRY_ATTEMPTS) {
|
if (retries >= MAX_AUTO_RESUME_TRACK_RETRY_ATTEMPTS) {
|
||||||
Log.d(TAG, "Not resuming. Exceeded maximum retry attempts.");
|
Log.d(TAG, "Not resuming. Exceeded maximum retry attempts.");
|
||||||
return false;
|
return false;
|
||||||
@@ -562,8 +530,7 @@ public class TrackRecordingService extends Service {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
long stopTime = track.getTripStatistics().getStopTime();
|
long stopTime = track.getTripStatistics().getStopTime();
|
||||||
return stopTime > 0
|
return stopTime > 0 && (System.currentTimeMillis() - stopTime) <= autoResumeTrackTimeout * ONE_MINUTE;
|
||||||
&& (System.currentTimeMillis() - stopTime) <= autoResumeTrackTimeout * ONE_MINUTE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -617,8 +584,7 @@ public class TrackRecordingService extends Service {
|
|||||||
trackTripStatisticsUpdater = new TripStatisticsUpdater(tripStatistics.getStartTime());
|
trackTripStatisticsUpdater = new TripStatisticsUpdater(tripStatistics.getStartTime());
|
||||||
|
|
||||||
long markerStartTime;
|
long markerStartTime;
|
||||||
Waypoint waypoint = myTracksProviderUtils.getLastWaypoint(
|
Waypoint waypoint = myTracksProviderUtils.getLastWaypoint(recordingTrackId, WaypointType.STATISTICS);
|
||||||
recordingTrackId, WaypointType.STATISTICS);
|
|
||||||
if (waypoint != null && waypoint.getTripStatistics() != null) {
|
if (waypoint != null && waypoint.getTripStatistics() != null) {
|
||||||
markerStartTime = waypoint.getTripStatistics().getStopTime();
|
markerStartTime = waypoint.getTripStatistics().getStopTime();
|
||||||
} else {
|
} else {
|
||||||
@@ -628,8 +594,7 @@ public class TrackRecordingService extends Service {
|
|||||||
|
|
||||||
LocationIterator locationIterator = null;
|
LocationIterator locationIterator = null;
|
||||||
try {
|
try {
|
||||||
locationIterator = myTracksProviderUtils.getTrackPointLocationIterator(
|
locationIterator = myTracksProviderUtils.getTrackPointLocationIterator(track.getId(), -1L, false, MyTracksProviderUtils.DEFAULT_LOCATION_FACTORY);
|
||||||
track.getId(), -1L, false, MyTracksProviderUtils.DEFAULT_LOCATION_FACTORY);
|
|
||||||
|
|
||||||
while (locationIterator.hasNext()) {
|
while (locationIterator.hasNext()) {
|
||||||
Location location = locationIterator.next();
|
Location location = locationIterator.next();
|
||||||
@@ -681,7 +646,6 @@ public class TrackRecordingService extends Service {
|
|||||||
* @param trackStarted true if track is started, false if track is resumed
|
* @param trackStarted true if track is started, false if track is resumed
|
||||||
*/
|
*/
|
||||||
private void startRecording(boolean trackStarted) {
|
private void startRecording(boolean trackStarted) {
|
||||||
|
|
||||||
// Update instance variables
|
// Update instance variables
|
||||||
sensorManager = SensorManagerFactory.getSystemSensorManager(this);
|
sensorManager = SensorManagerFactory.getSystemSensorManager(this);
|
||||||
lastLocation = null;
|
lastLocation = null;
|
||||||
@@ -689,8 +653,7 @@ public class TrackRecordingService extends Service {
|
|||||||
isIdle = false;
|
isIdle = false;
|
||||||
|
|
||||||
startGps();
|
startGps();
|
||||||
sendTrackBroadcast(trackStarted ? R.string.track_started_broadcast_action
|
sendTrackBroadcast(trackStarted ? R.string.track_started_broadcast_action : R.string.track_resumed_broadcast_action, recordingTrackId);
|
||||||
: R.string.track_resumed_broadcast_action, recordingTrackId);
|
|
||||||
|
|
||||||
// Restore periodic tasks
|
// Restore periodic tasks
|
||||||
voiceExecutor.restore();
|
voiceExecutor.restore();
|
||||||
@@ -733,9 +696,7 @@ public class TrackRecordingService extends Service {
|
|||||||
updateRecordingTrack(track, myTracksProviderUtils.getLastTrackPointId(trackId), false);
|
updateRecordingTrack(track, myTracksProviderUtils.getLastTrackPointId(trackId), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
String trackName = TrackNameUtils.getTrackName(this, trackId,
|
String trackName = TrackNameUtils.getTrackName(this, trackId, track.getTripStatistics().getStartTime(), myTracksProviderUtils.getFirstValidTrackPoint(trackId));
|
||||||
track.getTripStatistics().getStartTime(),
|
|
||||||
myTracksProviderUtils.getFirstValidTrackPoint(trackId));
|
|
||||||
if (trackName != null && !trackName.equals(track.getName())) {
|
if (trackName != null && !trackName.equals(track.getName())) {
|
||||||
track.setName(trackName);
|
track.setName(trackName);
|
||||||
myTracksProviderUtils.updateTrack(track);
|
myTracksProviderUtils.updateTrack(track);
|
||||||
@@ -779,7 +740,6 @@ public class TrackRecordingService extends Service {
|
|||||||
* @param trackId the track id
|
* @param trackId the track id
|
||||||
*/
|
*/
|
||||||
private void endRecording(boolean trackStopped, long trackId) {
|
private void endRecording(boolean trackStopped, long trackId) {
|
||||||
|
|
||||||
// Shutdown periodic tasks
|
// Shutdown periodic tasks
|
||||||
voiceExecutor.shutdown();
|
voiceExecutor.shutdown();
|
||||||
splitExecutor.shutdown();
|
splitExecutor.shutdown();
|
||||||
@@ -791,8 +751,7 @@ public class TrackRecordingService extends Service {
|
|||||||
}
|
}
|
||||||
lastLocation = null;
|
lastLocation = null;
|
||||||
|
|
||||||
sendTrackBroadcast(trackStopped ? R.string.track_stopped_broadcast_action
|
sendTrackBroadcast(trackStopped ? R.string.track_stopped_broadcast_action : R.string.track_paused_broadcast_action, trackId);
|
||||||
: R.string.track_paused_broadcast_action, trackId);
|
|
||||||
stopGps(trackStopped);
|
stopGps(trackStopped);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -864,6 +823,7 @@ public class TrackRecordingService extends Service {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO Necessary?
|
||||||
// Fix for phones that do not set the time field
|
// Fix for phones that do not set the time field
|
||||||
if (location.getTime() == 0L) {
|
if (location.getTime() == 0L) {
|
||||||
location.setTime(System.currentTimeMillis());
|
location.setTime(System.currentTimeMillis());
|
||||||
@@ -914,8 +874,7 @@ public class TrackRecordingService extends Service {
|
|||||||
|
|
||||||
insertLocation(track, location, null);
|
insertLocation(track, location, null);
|
||||||
isIdle = false;
|
isIdle = false;
|
||||||
} else if (sensorDataSet != null
|
} else if (sensorDataSet != null || distanceToLastTrackLocation >= recordingDistanceInterval) {
|
||||||
|| distanceToLastTrackLocation >= recordingDistanceInterval) {
|
|
||||||
insertLocation(track, lastLocation, lastValidTrackPoint);
|
insertLocation(track, lastLocation, lastValidTrackPoint);
|
||||||
insertLocation(track, location, null);
|
insertLocation(track, location, null);
|
||||||
isIdle = false;
|
isIdle = false;
|
||||||
@@ -985,8 +944,7 @@ public class TrackRecordingService extends Service {
|
|||||||
* @param lastTrackPointId the last track point id
|
* @param lastTrackPointId the last track point id
|
||||||
* @param increaseNumberOfPoints true to increase the number of points
|
* @param increaseNumberOfPoints true to increase the number of points
|
||||||
*/
|
*/
|
||||||
private void updateRecordingTrack(
|
private void updateRecordingTrack(Track track, long lastTrackPointId, boolean increaseNumberOfPoints) {
|
||||||
Track track, long lastTrackPointId, boolean increaseNumberOfPoints) {
|
|
||||||
if (lastTrackPointId >= 0) {
|
if (lastTrackPointId >= 0) {
|
||||||
if (track.getStartId() < 0) {
|
if (track.getStartId() < 0) {
|
||||||
track.setStartId(lastTrackPointId);
|
track.setStartId(lastTrackPointId);
|
||||||
@@ -1003,8 +961,7 @@ public class TrackRecordingService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SensorDataSet getSensorDataSet() {
|
private SensorDataSet getSensorDataSet() {
|
||||||
if (sensorManager == null || !sensorManager.isEnabled()
|
if (sensorManager == null || !sensorManager.isEnabled() || !sensorManager.isSensorDataSetValid()) {
|
||||||
|| !sensorManager.isSensorDataSetValid()) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return sensorManager.getSensorDataSet();
|
return sensorManager.getSensorDataSet();
|
||||||
@@ -1250,7 +1207,7 @@ public class TrackRecordingService extends Service {
|
|||||||
Log.d(TAG, "sensorManager is null.");
|
Log.d(TAG, "sensorManager is null.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (trackRecordingService.sensorManager.getSensorDataSet() == null) {
|
if (trackRecordingService.getSensorDataSet() == null) {
|
||||||
Log.d(TAG, "Sensor data set is null.");
|
Log.d(TAG, "Sensor data set is null.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-6
@@ -106,10 +106,8 @@ public class TrackRecordingServiceConnectionUtils {
|
|||||||
* connection
|
* connection
|
||||||
* @param showEditor true to show the editor
|
* @param showEditor true to show the editor
|
||||||
*/
|
*/
|
||||||
public static void stopRecording(Context context,
|
public static void stopRecording(Context context, TrackRecordingServiceConnection trackRecordingServiceConnection, boolean showEditor) {
|
||||||
TrackRecordingServiceConnection trackRecordingServiceConnection, boolean showEditor) {
|
ITrackRecordingService trackRecordingService = trackRecordingServiceConnection.getServiceIfBound();
|
||||||
ITrackRecordingService trackRecordingService = trackRecordingServiceConnection
|
|
||||||
.getServiceIfBound();
|
|
||||||
if (trackRecordingService != null) {
|
if (trackRecordingService != null) {
|
||||||
try {
|
try {
|
||||||
if (showEditor) {
|
if (showEditor) {
|
||||||
@@ -117,8 +115,7 @@ public class TrackRecordingServiceConnectionUtils {
|
|||||||
* Need to remember the recordingTrackId before calling
|
* Need to remember the recordingTrackId before calling
|
||||||
* endCurrentTrack. endCurrentTrack sets the value to -1L.
|
* endCurrentTrack. endCurrentTrack sets the value to -1L.
|
||||||
*/
|
*/
|
||||||
long recordingTrackId = PreferencesUtils.getLong(
|
long recordingTrackId = PreferencesUtils.getLong(context, R.string.recording_track_id_key);
|
||||||
context, R.string.recording_track_id_key);
|
|
||||||
trackRecordingService.endCurrentTrack();
|
trackRecordingService.endCurrentTrack();
|
||||||
if (recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT) {
|
if (recordingTrackId != PreferencesUtils.RECORDING_TRACK_ID_DEFAULT) {
|
||||||
Intent intent = IntentUtils.newIntent(context, TrackEditActivity.class)
|
Intent intent = IntentUtils.newIntent(context, TrackEditActivity.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user