Merge pull request #1073 from Philoul/Fix/FixCrashInsightBT

Fix Crash on Insight Driver
This commit is contained in:
Milos Kozak 2021-12-15 08:48:40 +01:00 committed by GitHub
commit afea158d0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -108,8 +108,7 @@ public class InsightConnectionService extends DaggerService implements Connectio
private DelayedActionThread disconnectTimer; private DelayedActionThread disconnectTimer;
private DelayedActionThread recoveryTimer; private DelayedActionThread recoveryTimer;
private DelayedActionThread timeoutTimer; private DelayedActionThread timeoutTimer;
private final BluetoothAdapter bluetoothAdapter = private BluetoothAdapter bluetoothAdapter;
((BluetoothManager)getApplicationContext().getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter();
private BluetoothDevice bluetoothDevice; private BluetoothDevice bluetoothDevice;
private BluetoothSocket bluetoothSocket; private BluetoothSocket bluetoothSocket;
private ConnectionEstablisher connectionEstablisher; private ConnectionEstablisher connectionEstablisher;
@ -259,6 +258,7 @@ public class InsightConnectionService extends DaggerService implements Connectio
@Override @Override
public synchronized void onCreate() { public synchronized void onCreate() {
super.onCreate(); super.onCreate();
bluetoothAdapter = ((BluetoothManager)getApplicationContext().getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter();
pairingDataStorage = new PairingDataStorage(this); pairingDataStorage = new PairingDataStorage(this);
state = pairingDataStorage.isPaired() ? InsightState.DISCONNECTED : InsightState.NOT_PAIRED; state = pairingDataStorage.isPaired() ? InsightState.DISCONNECTED : InsightState.NOT_PAIRED;
wakeLock = ((PowerManager) getSystemService(POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AndroidAPS:InsightConnectionService"); wakeLock = ((PowerManager) getSystemService(POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AndroidAPS:InsightConnectionService");