This commit is contained in:
Dennis Guse
2020-01-03 22:34:11 +01:00
parent 27e50b2dd9
commit 09fe35f1ca
38 changed files with 120 additions and 208 deletions
@@ -150,7 +150,7 @@ public class TrackRecordingService extends Service {
private boolean currentSegmentHasLocation;
private boolean isIdle; // true if idle
private ServiceBinder binder = new ServiceBinder(this);
private LocationListener locationListener = new LocationListener() {
private final LocationListener locationListener = new LocationListener() {
@Override
public void onLocationChanged(final Location location) {
@@ -358,7 +358,7 @@ public class TrackRecordingService extends Service {
track.setTripStatistics(trackTripStatisticsUpdater.getTripStatistics());
contentProviderUtils.updateTrack(track);
startRecording(true);
startRecording();
return trackId;
}
@@ -382,7 +382,7 @@ public class TrackRecordingService extends Service {
} catch (RuntimeException e) {
Log.e(TAG, "RuntimeException", e);
}
startRecording(true);
startRecording();
}
/**
@@ -408,15 +408,13 @@ public class TrackRecordingService extends Service {
insertLocation(track, resume, null);
}
startRecording(false);
startRecording();
}
/**
* Common code for starting a new track, resuming a track, or restarting after phone reboot.
*
* @param trackStarted true if track is started, false if track is resumed
*/
private void startRecording(boolean trackStarted) {
private void startRecording() {
// Update instance variables
remoteSensorManager = new BluetoothRemoteSensorManager(this);
remoteSensorManager.start();
@@ -686,7 +684,7 @@ public class TrackRecordingService extends Service {
}
try {
Uri uri = contentProviderUtils.insertTrackPoint(location, track.getId());
contentProviderUtils.insertTrackPoint(location, track.getId());
trackTripStatisticsUpdater.addLocation(location, recordingDistanceInterval);
updateRecordingTrack(track, LocationUtils.isValidLocation(location));
} catch (SQLiteException e) {
@@ -24,9 +24,9 @@ class TrackRecordingServiceNotificationManager {
private final static String CHANNEL_ID = TrackRecordingServiceNotificationManager.class.getSimpleName();
private NotificationCompat.Builder notificationBuilder;
private final NotificationCompat.Builder notificationBuilder;
private NotificationManager notificationManager;
private final NotificationManager notificationManager;
private boolean previousLocationWasAccurate = true;
@@ -57,9 +57,9 @@ public class BluetoothConnectionManager {
private SensorState sensorState;
private BluetoothGatt bluetoothGatt;
private BluetoothDevice bluetoothDevice;
private final BluetoothDevice bluetoothDevice;
private BluetoothGattCallback connectCallback = new BluetoothGattCallback() {
private final BluetoothGattCallback connectCallback = new BluetoothGattCallback() {
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
switch (newState) {
@@ -61,11 +61,7 @@ public class AnnouncementPeriodicTask implements PeriodicTask {
stop = false;
break;
case AudioManager.AUDIOFOCUS_LOSS:
stop = true;
break;
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
stop = true;
break;
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
stop = true;
break;