[BUG] AudioPolicy: combo UC: mute may not work

When a SwOutput hosts a combo use case, if this output is routed
to a device using an HW Gain, the highest priority product strategy/
volume source will only be allowed for volume operation.
If muting the other volume source (adjustStreamVolume on AudioService
translated into setVolumeIndexForAttributes), the AudioPolicyManager
will block the volume change.

This CL fixes this issue by considering the mute and implement it
through Sw gain on AudioFlinger in case of concurrent UC on Output.

Test: audio smoke tests
Bug: 187173302

Signed-off-by: Francois Gaffie <francois.gaffie@renault.com>
Change-Id: I2799ac7140970c1e94e0c6424e9e840b83fe8ef7
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 00f5580..2487789 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -2801,6 +2801,8 @@
         // HW Gain management, do not change the volume
         if (desc->useHwGain()) {
             applyVolume = false;
+            // If the volume source is active with higher priority source, ensure at least Sw Muted
+            desc->setSwMute((index == 0), vs, curves.getStreamTypes(), curDevices, 0 /*delayMs*/);
             for (const auto &productStrategy : mEngine->getOrderedProductStrategies()) {
                 auto activeClients = desc->clientsList(true /*activeOnly*/, productStrategy,
                                                        false /*preferredDevice*/);
@@ -6575,8 +6577,9 @@
                     isSingleDeviceType(deviceTypes, audio_is_bluetooth_out_sco_device))) {
         volumeDb = 0.0f;
     }
+    const bool muted = (index == 0) && (volumeDb != 0.0f);
     outputDesc->setVolume(
-            volumeDb, volumeSource, curves.getStreamTypes(), deviceTypes, delayMs, force);
+            volumeDb, muted, volumeSource, curves.getStreamTypes(), deviceTypes, delayMs, force);
 
     if (outputDesc == mPrimaryOutput && (isVoiceVolSrc || isBtScoVolSrc)) {
         float voiceVolume;