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

Commit 41e81e10 authored by Krzysztof Kopyściński's avatar Krzysztof Kopyściński
Browse files

VCS: check group only for group set in `setDeviceVolume`

Bug: 373308672
Test: atest VolumeControlServiceTest
Change-Id: Ia0c0af6a1ba040059b623020560876790f773d9c
parent 89a7702c
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -450,13 +450,14 @@ public class VolumeControlService extends ProfileService {
            Log.e(TAG, "leAudioService not available");
            return;
        }

        if (isGroupOp) {
            int groupId = leAudioService.getGroupId(device);
            if (groupId == IBluetoothLeAudio.LE_AUDIO_GROUP_ID_INVALID) {
                Log.e(TAG, "Device not a part of a group");
                return;
            }

        if (isGroupOp) {
            setGroupVolume(groupId, volume);
        } else {
            Log.i(TAG, "Setting individual device volume");
+17 −1
Original line number Diff line number Diff line
@@ -904,7 +904,23 @@ public class VolumeControlServiceTest {
    }

    @Test
    public void serviceBinderRegisterUnregisterCallback() {
    @EnableFlags(Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES)
    public void testServiceBinderSetDeviceVolumeNoGroupId() throws Exception {
        int deviceVolume = 42;
        when(mLeAudioService.getGroupId(mDevice)).thenReturn(LE_AUDIO_GROUP_ID_INVALID);

        generateDeviceAvailableMessageFromNative(mDevice, 1);
        generateConnectionMessageFromNative(
                mDevice, STATE_CONNECTED, STATE_DISCONNECTED);
        assertThat(mService.getDevices()).contains(mDevice);

        mBinder.setDeviceVolume(mDevice, deviceVolume, false, mAttributionSource);
        verify(mNativeInterface).setVolume(mDevice, deviceVolume);
        assertThat(mService.getDeviceVolume(mDevice)).isEqualTo(deviceVolume);
    }

    @Test
    public void testServiceBinderRegisterUnregisterCallback() throws Exception {
        IBluetoothVolumeControlCallback callback =
                Mockito.mock(IBluetoothVolumeControlCallback.class);
        Binder binder = Mockito.mock(Binder.class);