audio: fix mic mute for SIP calls

Do not allow mic mute only when in PSTN calls.

Bug: 17321604.
Change-Id: Ie82d4ea4de767c38e5d476d5827ebb9ae0c45c63
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index c5a4e88..51a3ed6 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1832,8 +1832,9 @@
     /*
      * Instead of writing zeroes here, we could trust the hardware
      * to always provide zeroes when muted.
+     * No need to acquire adev->lock to read mic_muted here as we don't change its state.
      */
-    if (ret == 0 && voice_get_mic_mute(adev) && !voice_is_in_call(adev))
+    if (ret == 0 && adev->mic_muted && in->usecase != USECASE_AUDIO_RECORD_AFE_PROXY)
         memset(buffer, 0, bytes);
 
 exit:
@@ -2303,6 +2304,7 @@
     ALOGD("%s: state %d\n", __func__, state);
     pthread_mutex_lock(&adev->lock);
     ret = voice_set_mic_mute(adev, state);
+    adev->mic_muted = state;
     pthread_mutex_unlock(&adev->lock);
 
     return ret;
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index c45cb74..e742bc7 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -211,6 +211,7 @@
     struct voice voice;
     unsigned int cur_hdmi_channels;
     bool bt_wb_speech_enabled;
+    bool mic_muted;
 
     int snd_card;
     void *platform;