Skip to content

Commit

Permalink
Try to stop all scans when Bluetooth is turning off
Browse files Browse the repository at this point in the history
  • Loading branch information
weliem committed Oct 22, 2021
1 parent c19b60a commit 02f33ed
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1134,10 +1134,18 @@ private void handleAdapterState(final int state) {
Logger.d(TAG,"bluetooth turned off");
break;
case BluetoothAdapter.STATE_TURNING_OFF:
expectingBluetoothOffDisconnects = true;

// Stop all scans so that we are back in a clean state
// Note that we can't call stopScan if the adapter is off
if (isScanning()) {
stopScan();
}

if(isAutoScanning()) {
stopAutoconnectScan();
}

expectingBluetoothOffDisconnects = true;

cancelTimeoutTimer();
cancelAutoConnectTimer();
currentCallback = null;
Expand Down

0 comments on commit 02f33ed

Please sign in to comment.