Merge "hal: send calibration parameters in stream route"
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 188223b..806a4be 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1545,8 +1545,7 @@
                     !voice_is_in_call(adev) &&
                     (out == adev->primary_output)) {
                 ret = voice_start_call(adev);
-            } else if ((adev->mode == AUDIO_MODE_IN_CALL) &&
-                            voice_is_in_call(adev) &&
+            } else if (voice_is_in_call(adev) &&
                             (out == adev->primary_output)) {
                 voice_update_devices_for_all_voice_usecases(adev);
             }
diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp
index b679fdb..a8cbcda 100644
--- a/policy_hal/AudioPolicyManager.cpp
+++ b/policy_hal/AudioPolicyManager.cpp
@@ -1558,8 +1558,8 @@
                                                   0 /* ignored */);
        }
     }
-    mPrevPhoneState = oldState;
 #endif
+    mPrevPhoneState = oldState;
 
     int delayMs = 0;
     if (isStateInCall(state)) {
@@ -1609,6 +1609,12 @@
     ALOGD(" End of setPhoneState ... mPhoneState: %d ",mPhoneState);
 }
 
+bool AudioPolicyManager::isStateInCall(int state)
+{
+    return ((state == AudioSystem::MODE_IN_CALL) || (state == AudioSystem::MODE_IN_COMMUNICATION) ||
+       ((state == AudioSystem::MODE_RINGTONE) && (mPrevPhoneState == AudioSystem::MODE_IN_CALL)));
+}
+
 extern "C" AudioPolicyInterface* createAudioPolicyManager(AudioPolicyClientInterface *clientInterface)
 {
     return new AudioPolicyManager(clientInterface);
diff --git a/policy_hal/AudioPolicyManager.h b/policy_hal/AudioPolicyManager.h
index dce5bad..ab57768 100644
--- a/policy_hal/AudioPolicyManager.h
+++ b/policy_hal/AudioPolicyManager.h
@@ -61,6 +61,9 @@
         virtual bool isOffloadSupported(const audio_offload_info_t& offloadInfo);
 
         virtual void setPhoneState(int state);
+
+        // true if given state represents a device in a telephony or VoIP call
+        virtual bool isStateInCall(int state);
 protected:
         // return the strategy corresponding to a given stream type
         static routing_strategy getStrategy(AudioSystem::stream_type stream);