[Audiosharing] Block pairing if there exists temp bond device
Test: atest Flag: com.android.settingslib.flags.enable_temporary_bond_devices_ui Bug: 392004799 Change-Id: I641ec995e7e0883b428effe219acb25d2c2da9dd
This commit is contained in:
@@ -54,6 +54,7 @@ import com.android.settingslib.utils.ThreadUtils;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -315,11 +316,15 @@ public final class Utils {
|
||||
CachedBluetoothDeviceManager deviceManager = localBtManager.getCachedDeviceManager();
|
||||
List<BluetoothDevice> connectedDevices =
|
||||
assistant == null ? ImmutableList.of() : assistant.getAllConnectedDevices();
|
||||
Collection<CachedBluetoothDevice> bondedDevices =
|
||||
deviceManager == null ? ImmutableList.of() : deviceManager.getCachedDevicesCopy();
|
||||
// Block the pairing if there is ongoing audio sharing session and
|
||||
// a) there is already one temp bond sink connected
|
||||
// a) there is already one temp bond sink bonded
|
||||
// or b) there are already two sinks joining the audio sharing
|
||||
return assistant != null && deviceManager != null
|
||||
&& (connectedDevices.stream().anyMatch(BluetoothUtils::isTemporaryBondDevice)
|
||||
&& (bondedDevices.stream().anyMatch(
|
||||
d -> BluetoothUtils.isTemporaryBondDevice(d.getDevice())
|
||||
&& d.getBondState() == BluetoothDevice.BOND_BONDED)
|
||||
|| connectedDevices.stream().filter(
|
||||
d -> BluetoothUtils.hasActiveLocalBroadcastSourceForBtDevice(d,
|
||||
localBtManager))
|
||||
|
Reference in New Issue
Block a user