Diff between 5d5444d657309fe0fb8a29707c81a4d0c4258f9b and 84066fccbc58a11e035435f11c4b5daa8c740059

Changed Files

File Additions Deletions Status
android/handsfree.c +11 -1 modified

Full Patch

diff --git a/android/handsfree.c b/android/handsfree.c
index 00da445..2ab0c32 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -1653,6 +1653,9 @@ static bool disconnect_sco(void)
 
 static bool connect_audio(void)
 {
+	if (device.audio_state != HAL_EV_HANDSFREE_AUDIO_STATE_DISCONNECTED)
+		return false;
+
 	/* we haven't negotiated codec, start selection */
 	if ((device.features & HFP_HF_FEAT_CODEC) && !device.negotiated_codec) {
 		select_codec(0);
@@ -1989,6 +1992,8 @@ static void phone_state_dialing(int num_active, int num_held)
 
 	if (num_active == 0 && num_held > 0)
 		update_indicator(IND_CALLHELD, 2);
+
+	connect_audio();
 }
 
 static void phone_state_alerting(int num_active, int num_held)
@@ -2057,8 +2062,10 @@ static void phone_state_idle(int num_active, int num_held)
 
 	switch (device.setup_state) {
 	case HAL_HANDSFREE_CALL_STATE_INCOMING:
-		if (num_active > device.num_active)
+		if (num_active > device.num_active) {
 			update_indicator(IND_CALL, 1);
+			connect_audio();
+		}
 
 		if (num_held > device.num_held)
 			update_indicator(IND_CALLHELD, 1);
@@ -2089,6 +2096,9 @@ static void phone_state_idle(int num_active, int num_held)
 		update_indicator(IND_CALLSETUP, 0);
 
 		break;
+	case HAL_HANDSFREE_CALL_STATE_ACTIVE:
+		connect_audio();
+		break;
 	default:
 		DBG("unhandled state %u", device.setup_state);
 		break;