From 73802a1802f9c1fa6b14684ed124cce904aee7c0 Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Thu, 10 Dec 2020 13:01:26 -0800 Subject: [PATCH] Bluetooth: Check state correctly when client wants to bind Use mState instead of mEnable to check Bluetooth server status. mEnable is used to indicate whether the next action is enabling or disabling the Bluetooth stack, whereas mState indicates the current state. Test: atest FrameworksServicesTests Bug: 173941366 Change-Id: Id85494f7f40a0201061e74fbf3f08f70a632a62c --- .../core/java/com/android/server/BluetoothManagerService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java index 0b8b3526400a3..aab05532e2b7f 100644 --- a/services/core/java/com/android/server/BluetoothManagerService.java +++ b/services/core/java/com/android/server/BluetoothManagerService.java @@ -1265,7 +1265,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub { @Override public boolean bindBluetoothProfileService(int bluetoothProfile, IBluetoothProfileServiceConnection proxy) { - if (!mEnable) { + if (mState != BluetoothAdapter.STATE_ON) { if (DBG) { Slog.d(TAG, "Trying to bind to profile: " + bluetoothProfile + ", while Bluetooth was disabled"); @@ -1431,7 +1431,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub { mBluetoothLock.readLock().unlock(); } - if (!mEnable || state != BluetoothAdapter.STATE_ON) { + if (state != BluetoothAdapter.STATE_ON) { if (DBG) { Slog.d(TAG, "Unable to bindService while Bluetooth is disabled"); }