Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 62e141a2 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix ble stop scan crash when BT is not turned on"

parents d7015099 465f4c8b
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import static android.bluetooth.BluetoothAdapter.ACTION_BLE_STATE_CHANGED;
import static android.bluetooth.BluetoothAdapter.ACTION_STATE_CHANGED;
import static android.bluetooth.BluetoothAdapter.EXTRA_PREVIOUS_STATE;
import static android.bluetooth.BluetoothAdapter.EXTRA_STATE;
import static android.bluetooth.BluetoothAdapter.STATE_BLE_ON;
import static android.bluetooth.BluetoothAdapter.STATE_ON;
import static android.bluetooth.BluetoothAdapter.nameForState;
import static android.bluetooth.le.ScanCallback.SCAN_FAILED_ALREADY_STARTED;
import static android.bluetooth.le.ScanCallback.SCAN_FAILED_APPLICATION_REGISTRATION_FAILED;
@@ -232,8 +234,14 @@ class BleCompanionDeviceScanner implements AssociationStore.OnChangeListener {
            return;
        }

        mBleScanner.stopScan(mScanCallback);
        mScanning = false;

        if (mBtAdapter.getState() != STATE_ON && mBtAdapter.getState() != STATE_BLE_ON) {
            Log.d(TAG, "BT Adapter is not turned ON");
            return;
        }

        mBleScanner.stopScan(mScanCallback);
    }

    @MainThread