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

Commit b8bc01d0 authored by Chelsea Hao's avatar Chelsea Hao Committed by Android (Google) Code Review
Browse files

Merge "Show share audio button only when assistant profile is connected." into main

parents 8ae2f4fc a2e5fc08
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ constructor(
        combine(
                bluetoothStateInteractor.bluetoothStateUpdate,
                deviceItemInteractor.deviceItemUpdate,
                audioSharingInteractor.isAudioSharingOn
                audioSharingInteractor.isAudioSharingOn,
            ) { bluetoothState, deviceItem, audioSharingOn ->
                getButtonState(bluetoothState, deviceItem, audioSharingOn)
            }
@@ -70,7 +70,7 @@ constructor(
    private fun getButtonState(
        bluetoothState: Boolean,
        deviceItem: List<DeviceItem>,
        audioSharingOn: Boolean
        audioSharingOn: Boolean,
    ): AudioSharingButtonState {
        return when {
            // Don't show button when bluetooth is off
@@ -79,20 +79,22 @@ constructor(
            audioSharingOn ->
                AudioSharingButtonState.Visible(
                    R.string.quick_settings_bluetooth_audio_sharing_button_sharing,
                    isActive = true
                    isActive = true,
                )
            // When not broadcasting, don't show button if there's connected source in any device
            deviceItem.any {
                BluetoothUtils.hasConnectedBroadcastSource(
                    it.cachedBluetoothDevice,
                    localBluetoothManager
                    localBluetoothManager,
                )
            } -> AudioSharingButtonState.Gone
            // Show audio sharing when there's a connected LE audio device
            deviceItem.any { BluetoothUtils.isActiveLeAudioDevice(it.cachedBluetoothDevice) } ->
            // Show audio sharing when there's a device connecting to the LE audio assistant profile
            deviceItem.any {
                it.cachedBluetoothDevice.isConnectedLeAudioBroadcastAssistantDevice
            } ->
                AudioSharingButtonState.Visible(
                    R.string.quick_settings_bluetooth_audio_sharing_button,
                    isActive = false
                    isActive = false,
                )
            else -> AudioSharingButtonState.Gone
        }
+2 −1
Original line number Diff line number Diff line
@@ -159,6 +159,8 @@ class AudioSharingButtonViewModelTest : SysuiTestCase() {
            val actual by
                collectLastValue(audioSharingButtonViewModel.audioSharingButtonStateUpdate)
            kosmos.bluetoothTileDialogAudioSharingRepository.setAudioSharingAvailable(true)
            whenever(cachedBluetoothDevice.isConnectedLeAudioBroadcastAssistantDevice)
                .thenReturn(true)
            whenever(deviceItem.cachedBluetoothDevice).thenReturn(cachedBluetoothDevice)
            whenever(
                    BluetoothUtils.hasConnectedBroadcastSource(
@@ -167,7 +169,6 @@ class AudioSharingButtonViewModelTest : SysuiTestCase() {
                    )
                )
                .thenReturn(false)
            whenever(BluetoothUtils.isActiveLeAudioDevice(cachedBluetoothDevice)).thenReturn(true)
            bluetoothState.value = true
            runCurrent()
            deviceItemUpdate.emit(listOf(deviceItem))