From b0474448d5638311fc5167ebc9eaf66b8a6688aa Mon Sep 17 00:00:00 2001 From: Venkata Jagadeesh Garaga Date: Tue, 3 Mar 2020 12:45:52 +0530 Subject: [PATCH] Title: Auto connection not getting initiated after pairing Issue: mProfiles list getting corrupted as its not protected with lock and auto connection failing Steps: 1.Turn on BT 2.Scan the remote headset from DUT 3.Initiating pairing to remote device 4.unpair the remote from DUT UI Repeat steps from 2 to 4. Some times auto connection not getting initiated from DUT. RootCause: if mProfiles accessed simultaneously from onUuidChanged and connectAllEnabledProfiles ,its leading to list corruption. Settings not able to initiate Auto connection as mProfiles list shown as empty. Fix: Remove redundant mProfiles empty check in onUuidChanged - mProfiles accessed inside onUuidChanged without syncronization, if mProfiles accessed simultaneously from onUuidChanged and connectAllEnabledProfiles ,it might lead to list corruption. - mProfiles empty check already there in connectAllEnabledProfiles Hence removing mProfiles empty conditional check in onUuidChanged Test: Follow steps above Bug: 150653750 Change-Id: I88aa6a6cd46d264f4dd32db71e413079bbd40779 --- .../android/settingslib/bluetooth/CachedBluetoothDevice.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java index 69e2044ad2321..e398080c50e4f 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java @@ -609,8 +609,8 @@ public class CachedBluetoothDevice implements Comparable * If a connect was attempted earlier without any UUID, we will do the connect now. * Otherwise, allow the connect on UUID change. */ - if (!mProfiles.isEmpty() - && ((mConnectAttempted + timeout) > SystemClock.elapsedRealtime())) { + if ((mConnectAttempted + timeout) > SystemClock.elapsedRealtime()) { + Log.d(TAG, "onUuidChanged: triggering connectAllEnabledProfiles"); connectAllEnabledProfiles(); }