policy: update voice volume after output device is changed.

During voice call, when device switch from handset to speaker,
speaker volume in voice stream is set only after voice call is
routed to speaker. In this duration, handset volume is used for
voice call even if speaker device is enabled.

Fix it by setting voice volume after voice output device is changed.

CRs-Fixed: 2281357
Change-Id: I5cf9639cfac788d12c07f3c83b610bc16fc0143c
diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp
index 7a323c9..27f6a40 100644
--- a/policy_hal/AudioPolicyManager.cpp
+++ b/policy_hal/AudioPolicyManager.cpp
@@ -1042,6 +1042,9 @@
     }
     if (mEngine->getPhoneState() == AUDIO_MODE_IN_CALL && hasPrimaryOutput()) {
         audio_devices_t newDevice = getNewOutputDevice(mPrimaryOutput, true /*fromCache*/);
+        if (forceVolumeReeval && (newDevice != AUDIO_DEVICE_NONE)) {
+            applyStreamVolumes(mPrimaryOutput, newDevice, delayMs, true);
+        }
         waitMs = updateCallRouting(newDevice, delayMs);
     }
     // Use reverse loop to make sure any low latency usecases (generally tones)
@@ -1057,10 +1060,11 @@
         if ((mEngine->getPhoneState() != AUDIO_MODE_IN_CALL) || (outputDesc != mPrimaryOutput)) {
             waitMs = setOutputDevice(outputDesc, newDevice, (newDevice != AUDIO_DEVICE_NONE),
                                      delayMs);
-        }
-        if (forceVolumeReeval && (newDevice != AUDIO_DEVICE_NONE)) {
-            applyStreamVolumes(outputDesc, newDevice, waitMs, true);
-        }
+
+            if (forceVolumeReeval && (newDevice != AUDIO_DEVICE_NONE)) {
+                applyStreamVolumes(outputDesc, newDevice, waitMs, true);
+            }
+         }
     }
 
     Vector<sp <AudioInputDescriptor> > activeInputs = mInputs.getActiveInputs();