hal: Add SSR/PDR handling in voice call

When SSR/PDR occurs, sometimes RIL/telephony
does not set the call state and mode accordingly due
to which the dapm widgets do not power down leading
to clock count mismatch and SSR failure. Set the call
state to CALL_INACTIVE for all active sessions and
mode to MODE_NORMAL to end the voice call and power down
the widgets within audio.

CRs-Fixed: 2383876
Change-Id: I907a62557ef6519aded98e85ef8811234a6c06c8
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 1acc3b3..6bcdbac 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -3848,9 +3848,17 @@
           use_case_table[out->usecase],
           status == CARD_STATUS_OFFLINE ? "offline" : "online");
 
-    if (status == CARD_STATUS_OFFLINE)
+    if (status == CARD_STATUS_OFFLINE) {
         out_on_error(stream);
-
+        if (voice_is_call_state_active(adev) &&
+            out == adev->primary_output) {
+            ALOGD("%s: SSR/PDR occurred, end all calls", __func__);
+            pthread_mutex_lock(&adev->lock);
+            voice_stop_call(adev);
+            adev->mode = AUDIO_MODE_NORMAL;
+            pthread_mutex_unlock(&adev->lock);
+        }
+    }
     return;
 }