diff --git a/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/PluginViewModel.java b/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/PluginViewModel.java index 165a3b41a..cc2c5ef7f 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/PluginViewModel.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/PluginViewModel.java @@ -1,6 +1,7 @@ package org.briarproject.briar.android.navdrawer; import android.app.Application; +import android.bluetooth.BluetoothAdapter; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -99,6 +100,7 @@ public class PluginViewModel extends AndroidViewModel implements EventListener { torPluginState.setValue(getTransportState(TorConstants.ID)); wifiPluginState.setValue(getTransportState(LanTcpConstants.ID)); btPluginState.setValue(getTransportState(BluetoothConstants.ID)); + initialiseBluetoothState(); loadSettings(); } @@ -173,6 +175,12 @@ public class PluginViewModel extends AndroidViewModel implements EventListener { mergeSettings(s, id.getString()); } + private void initialiseBluetoothState() { + BluetoothAdapter bt = BluetoothAdapter.getDefaultAdapter(); + if (bt == null) bluetoothTurnedOn.setValue(false); + else bluetoothTurnedOn.setValue(bt.getState() == STATE_ON); + } + private void loadSettings() { dbExecutor.execute(() -> { try {