audio framework: manage stream volume per device

Improve volume management by keeping track of volume for each type
of device independently.
Volume for each stream (MUSIC, RINGTONE, VOICE_CALL...) is now maintained
per device.

The main changes are:
- AudioService now keeps tracks of stream volumes per device:
 volume indexes are kept in a HashMap < device , index>.
 active device is queried from policy manager when a volume change request
 is received
 initalization, mute and unmute happen on all device simultaneously
- Settings: suffixes is added to volume keys to store each device
volume independently.
- AudioSystem/AudioPolicyService/AudioPolicyInterface: added a device argument
to setStreamVolumeIndex() and getStreamVolumeIndex() to address each
device independently.
- AudioPolicyManagerBase: keep track of stream volumes for each device
and apply volume according to current device selection.

Change-Id: I61ef1c45caadca04d16363bca4140e0f81901b3f
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index 44311d0..586406b 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -407,7 +407,9 @@
     return NO_ERROR;
 }
 
-status_t AudioPolicyService::setStreamVolumeIndex(audio_stream_type_t stream, int index)
+status_t AudioPolicyService::setStreamVolumeIndex(audio_stream_type_t stream,
+                                                  int index,
+                                                  audio_devices_t device)
 {
     if (mpAudioPolicy == NULL) {
         return NO_INIT;
@@ -419,10 +421,19 @@
         return BAD_VALUE;
     }
 
-    return mpAudioPolicy->set_stream_volume_index(mpAudioPolicy, stream, index);
+    if (mpAudioPolicy->set_stream_volume_index_for_device) {
+        return mpAudioPolicy->set_stream_volume_index_for_device(mpAudioPolicy,
+                                                                stream,
+                                                                index,
+                                                                device);
+    } else {
+        return mpAudioPolicy->set_stream_volume_index(mpAudioPolicy, stream, index);
+    }
 }
 
-status_t AudioPolicyService::getStreamVolumeIndex(audio_stream_type_t stream, int *index)
+status_t AudioPolicyService::getStreamVolumeIndex(audio_stream_type_t stream,
+                                                  int *index,
+                                                  audio_devices_t device)
 {
     if (mpAudioPolicy == NULL) {
         return NO_INIT;
@@ -430,7 +441,14 @@
     if (uint32_t(stream) >= AUDIO_STREAM_CNT) {
         return BAD_VALUE;
     }
-    return mpAudioPolicy->get_stream_volume_index(mpAudioPolicy, stream, index);
+    if (mpAudioPolicy->get_stream_volume_index_for_device) {
+        return mpAudioPolicy->get_stream_volume_index_for_device(mpAudioPolicy,
+                                                                stream,
+                                                                index,
+                                                                device);
+    } else {
+        return mpAudioPolicy->get_stream_volume_index(mpAudioPolicy, stream, index);
+    }
 }
 
 uint32_t AudioPolicyService::getStrategyForStream(audio_stream_type_t stream)