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
This commit is contained in:
Łukasz Rymanowski
2023-01-04 11:58:14 +00:00
parent b4838aa947
commit 1fac43ea0e

View File

@@ -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) {