forked from upstream-mirrors/OpenTracks
Bugfix: SensorHandler may receive a connectionLost from BluetoothDriver without being connected first.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package de.dennisguse.opentracks.sensors;
|
package de.dennisguse.opentracks.sensors;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@@ -18,6 +19,8 @@ import de.dennisguse.opentracks.settings.PreferencesUtils;
|
|||||||
|
|
||||||
public abstract class SensorHandler<AggregatorInput, AggregatorOutput> implements DriverObserver<AggregatorInput> {
|
public abstract class SensorHandler<AggregatorInput, AggregatorOutput> implements DriverObserver<AggregatorInput> {
|
||||||
|
|
||||||
|
private static final String TAG = SensorHandler.class.getSimpleName();
|
||||||
|
|
||||||
private final SensorManager sensorManager;
|
private final SensorManager sensorManager;
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -107,6 +110,11 @@ public abstract class SensorHandler<AggregatorInput, AggregatorOutput> implement
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnectionLost() {
|
public void onConnectionLost() {
|
||||||
|
if (SensorHandler.this.aggregator == null) {
|
||||||
|
Log.d(TAG, "Connection lost, but where not connected.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SensorHandler.this.aggregator.resetAggregated();
|
SensorHandler.this.aggregator.resetAggregated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user