audio policy: limit voice call index to max index

Workaround for issue 111194621: limit voice call volume
index to max value before computing voice volume.

Bug: 111194621
Test: repro steps in bug.
Change-Id: Id965a3cc9d0d20900c910f43f41d998917e6040d
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 28d2ea6..10b9ebe 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -5541,7 +5541,14 @@
         float voiceVolume;
         // Force voice volume to max for bluetooth SCO as volume is managed by the headset
         if (stream == AUDIO_STREAM_VOICE_CALL) {
-            voiceVolume = (float)index/(float)mVolumeCurves->getVolumeIndexMax(stream);
+            // FIXME: issue 111194621: this should not happen
+            int maxIndex = mVolumeCurves->getVolumeIndexMax(stream);
+            if (index > maxIndex) {
+                ALOGW("%s limiting voice call index %d to max index %d",
+                      __FUNCTION__, index, maxIndex);
+                index = maxIndex;
+            }
+            voiceVolume = (float)index/(float)maxIndex;
         } else {
             voiceVolume = 1.0;
         }