From 99a3463d17da6c287e6db05790372b5b943d6468 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Thu, 16 Apr 2020 16:52:38 -0700 Subject: [PATCH] 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 --- .../managerdefinitions/src/AudioOutputDescriptor.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp index aaa28bceed..d5272bc4c1 100644 --- a/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp +++ b/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp @@ -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