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
gugelfrei
Eric Laurent 4 years ago
parent a4cfeca69f
commit 99a3463d17

@ -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

Loading…
Cancel
Save