From 0c69be28786ed71f13e7724bdc523381d018d397 Mon Sep 17 00:00:00 2001 From: Ugo Yu Date: Mon, 23 Mar 2020 14:11:49 +0800 Subject: 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 --- services/core/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 d7b4f2e8f136..192ea72224b1 100644 --- a/services/core/java/com/android/server/BluetoothManagerService.java +++ b/services/core/java/com/android/server/BluetoothManagerService.java @@ -969,6 +969,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(); -- cgit v1.2.3-59-g8ed1b