quit BluetoothServer when Bluetooth is disabled

This commit is contained in:
Hans-Christoph Steiner 2018-04-11 14:15:17 +02:00
parent 73ad5bd6b3
commit 57e4315e18

View File

@ -66,7 +66,7 @@ public class BluetoothServer extends Thread {
public void run() {
isRunning = true;
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
try {
serverSocket = adapter.listenUsingInsecureRfcommWithServiceRecord("FDroid App Swap", BluetoothConstants.fdroidUuid());
@ -83,6 +83,11 @@ public class BluetoothServer extends Thread {
break;
}
if (!adapter.isEnabled()) {
Utils.debugLog(TAG, "User disabled Bluetooth from outside, stopping.");
break;
}
try {
BluetoothSocket clientSocket = serverSocket.accept();
if (clientSocket != null) {