From 1fac43ea0e7fc9a5fd7ec3571e5a05d10205571d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Rymanowski?= Date: Wed, 4 Jan 2023 11:58:14 +0000 Subject: [PATCH] SettingLib: Fix possible issue on bonding to second device If device.createBond() fails, SettingLib might stay in wrong state. Bug: 261646456 Test: compile Change-Id: I99cf32a475ef32a2605e4f379ec956ba288a055f --- .../settingslib/bluetooth/CachedBluetoothDeviceManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java index 6bc1160a8d0ab..2f821d5de480a 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java @@ -383,7 +383,10 @@ public class CachedBluetoothDeviceManager { Log.d(TAG, "Bond " + device.getAnonymizedAddress() + " by CSIP"); mOngoingSetMemberPair = device; syncConfigFromMainDevice(device, groupId); - device.createBond(BluetoothDevice.TRANSPORT_LE); + if (!device.createBond(BluetoothDevice.TRANSPORT_LE)) { + Log.d(TAG, "Bonding could not be started"); + mOngoingSetMemberPair = null; + } } private void syncConfigFromMainDevice(BluetoothDevice device, int groupId) {