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

Commit 99a3463d authored by Eric Laurent's avatar Eric Laurent
Browse files

audio policy: fix volume for unsupported device

Do not allow changing volume on an output when
the specified device is not supported by the
corresponding output profile.

There is a similar sanity check in setOutputDevices()
but there was none in AudioOutputDescriptor::setvolume().

Bug: 153411189
Test: atest AudioManagerTest
Test: manual audio smoke tests
Change-Id: I539697c54d70c442ba1ce38d212b43cd3ef0138c
parent a4cfeca6
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -152,10 +152,16 @@ bool AudioOutputDescriptor::isFixedVolume(const DeviceTypeSet& deviceTypes __unu
bool AudioOutputDescriptor::setVolume(float volumeDb,
                                      VolumeSource volumeSource,
                                      const StreamTypeVector &/*streams*/,
                                      const DeviceTypeSet& /*deviceTypes*/,
                                      const DeviceTypeSet& deviceTypes,
                                      uint32_t delayMs,
                                      bool force)
{

    if (!supportedDevices().containsDeviceAmongTypes(deviceTypes)) {
        ALOGV("%s output ID %d unsupported device %s",
                __func__, getId(), toString(deviceTypes).c_str());
        return false;
    }
    // We actually change the volume if:
    // - the float value returned by computeVolume() changed
    // - the force flag is set