Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fae222ff authored by Yiyi Shen's avatar Yiyi Shen
Browse files

Add method to check if CachedBluetoothDevice has connected LEA member

Test: manual
Bug: 396009828
Flag: EXEMPT simple fix
Change-Id: I3ac57f30b7bf7f19c7d5e7eebefb5fcf8f18d18c
parent efeea629
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -1948,6 +1948,17 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
                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
     */