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

Commit d1abd833 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

AudioDeviceVolumeManager.getDeviceVolume fix returned VolumeInfo

For the VolumeInfo instance returned by getDeviceVolume:
- fix missing rescaling of the min/max volume index,
- do not always configure it the have a mute command

Bug: 271473257
Test: atest android.media.audio.cts.AudioDeviceVolumeManagerTest#testSetGetVolume
Change-Id: I676cb6fca3f301d80a54f6b149ed081c0de48bba
parent 011d00e1
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -4993,8 +4993,8 @@ public class AudioService extends IAudioService.Stub
        int streamType = vi.getStreamType();
        final VolumeInfo.Builder vib = new VolumeInfo.Builder(vi);
        vib.setMinVolumeIndex(mStreamStates[streamType].mIndexMin);
        vib.setMaxVolumeIndex(mStreamStates[streamType].mIndexMax);
        vib.setMinVolumeIndex((mStreamStates[streamType].mIndexMin + 5) / 10);
        vib.setMaxVolumeIndex((mStreamStates[streamType].mIndexMax + 5) / 10);
        synchronized (VolumeStreamState.class) {
            final int index;
            if (isFixedVolumeDevice(ada.getInternalType())) {
@@ -5003,7 +5003,11 @@ public class AudioService extends IAudioService.Stub
                index = (mStreamStates[streamType].getIndex(ada.getInternalType()) + 5) / 10;
            }
            vib.setVolumeIndex(index);
            return vib.setMuted(mStreamStates[streamType].mIsMuted).build();
            // only set as a mute command if stream muted
            if (mStreamStates[streamType].mIsMuted) {
                vib.setMuted(true);
            }
            return vib.build();
        }
    }