Fix NPE during restartBleScan() when scanner is null

Fix: 204533528

Test: N/A
Change-Id: If242e01979c381aab5538e93bdf889ea95e16a20
This commit is contained in:
Guojing Yuan
2021-11-01 20:36:24 +00:00
parent e1211c6726
commit 6e7bf2578f

View File

@@ -1451,8 +1451,12 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
}
void restartBleScan() {
mBluetoothAdapter.getBluetoothLeScanner().stopScan(mBleScanCallback);
startBleScan();
if (mBluetoothAdapter.getBluetoothLeScanner() != null) {
mBluetoothAdapter.getBluetoothLeScanner().stopScan(mBleScanCallback);
startBleScan();
} else {
Slog.w(LOG_TAG, "BluetoothLeScanner is null (likely BLE isn't ON yet).");
}
}
private List<ScanFilter> getBleScanFilters() {