From fae222ffb3608f209682f1173ff9c19fc5adfe5c Mon Sep 17 00:00:00 2001 From: Yiyi Shen Date: Thu, 13 Feb 2025 16:16:08 +0800 Subject: Add method to check if CachedBluetoothDevice has connected LEA member Test: manual Bug: 396009828 Flag: EXEMPT simple fix Change-Id: I3ac57f30b7bf7f19c7d5e7eebefb5fcf8f18d18c --- .../android/settingslib/bluetooth/CachedBluetoothDevice.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'packages/SettingsLib/src') diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java index 7374f80fd9db..2d8d8a822325 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java @@ -1948,6 +1948,17 @@ public class CachedBluetoothDevice implements Comparable BluetoothProfile.STATE_CONNECTED; } + /** + * @return {@code true} if {@code cachedBluetoothDevice} has member which is LeAudio device + */ + public boolean hasConnectedLeAudioMemberDevice() { + LeAudioProfile leAudio = mProfileManager.getLeAudioProfile(); + return leAudio != null && getMemberDevice().stream().anyMatch( + cachedDevice -> cachedDevice != null && cachedDevice.getDevice() != null + && leAudio.getConnectionStatus(cachedDevice.getDevice()) + == BluetoothProfile.STATE_CONNECTED); + } + /** * @return {@code true} if {@code cachedBluetoothDevice} supports broadcast assistant profile */ -- cgit v1.2.3-59-g8ed1b