Bugfix: SensorHandler may receive a connectionLost from BluetoothDriver without being connected first.

This commit is contained in:
Dennis Guse
2026-02-10 18:11:51 +01:00
parent 14cebf3fec
commit 60e2fe57f9
@@ -1,6 +1,7 @@
package de.dennisguse.opentracks.sensors;
import android.content.Context;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -18,6 +19,8 @@ import de.dennisguse.opentracks.settings.PreferencesUtils;
public abstract class SensorHandler<AggregatorInput, AggregatorOutput> implements DriverObserver<AggregatorInput> {
private static final String TAG = SensorHandler.class.getSimpleName();
private final SensorManager sensorManager;
@VisibleForTesting
@@ -107,6 +110,11 @@ public abstract class SensorHandler<AggregatorInput, AggregatorOutput> implement
@Override
public void onConnectionLost() {
if (SensorHandler.this.aggregator == null) {
Log.d(TAG, "Connection lost, but where not connected.");
return;
}
SensorHandler.this.aggregator.resetAggregated();
}