Fix Bluetooth auto turns ON in airplane mode

Fix a race condition that mBleApps is cleared while turning ON BLE,
this causes Bluetooth turns on classic profiles instead of stays in
BLE_ON state.

Bug: 142220937
Test: enableBle() -> turn on airplane mode, check Bluetooth does not
      turn to ON.
Change-Id: I3cea5384f734dde269cf93a93ed7cc4173f669a0
This commit is contained in:
Ugo Yu
2020-03-23 14:11:49 +08:00
committed by Myles Watson
parent 644a6d52a6
commit 592234676c

View File

@@ -881,6 +881,13 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
Slog.e(TAG, "onBluetoothServiceUp: mBluetooth is null!");
return;
}
if (!mEnableExternal && !isBleAppPresent() && isAirplaneModeOn()) {
// Airplane mode is turned on while enabling BLE only mode, disable
// BLE now.
disableBleScanMode();
sendBrEdrDownCallback();
return;
}
if (isBluetoothPersistedStateOnBluetooth() || !isBleAppPresent()) {
// This triggers transition to STATE_ON
mBluetooth.onLeServiceUp();