From 592234676c9abae1ca3cb8d3f978fe47b94a040d Mon Sep 17 00:00:00 2001 From: Ugo Yu Date: Mon, 23 Mar 2020 14:11:49 +0800 Subject: [PATCH] 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 --- .../java/com/android/server/BluetoothManagerService.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java index cca02aac3d3c6..fcb9af572e14d 100644 --- a/services/core/java/com/android/server/BluetoothManagerService.java +++ b/services/core/java/com/android/server/BluetoothManagerService.java @@ -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();