Diff between 3c2dbb61909cfd676f7d3e97c55dd04e4b94fccb and 00138d547e37ebe7aecccdb5bd779744835657db

Changed Files

File Additions Deletions Status
android/handsfree.c +12 -7 modified

Full Patch

diff --git a/android/handsfree.c b/android/handsfree.c
index 1afe011..4e49032 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -2004,7 +2004,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();
+	if (device.num_active == 0 && device.num_held == 0)
+		connect_audio();
 }
 
 static void phone_state_alerting(int num_active, int num_held)
@@ -2075,7 +2076,9 @@ static void phone_state_idle(int num_active, int num_held)
 	case HAL_HANDSFREE_CALL_STATE_INCOMING:
 		if (num_active > device.num_active) {
 			update_indicator(IND_CALL, 1);
-			connect_audio();
+
+			if (device.num_active == 0 && device.num_held == 0)
+				connect_audio();
 		}
 
 		if (num_held > device.num_held)
@@ -2098,14 +2101,16 @@ static void phone_state_idle(int num_active, int num_held)
 			/* TODO better way for forcing indicator */
 			device.inds[IND_CALLHELD].val = 0;
 			update_indicator(IND_CALLHELD, 1);
-		} else if (num_active > 0 && device.num_active == 0) {
-			/* If number of active calls change but there was no
-			 * call setup change this means that there were active
+		} else if ((num_active > 0 || num_held > 0) &&
+						device.num_active == 0 &&
+						device.num_held == 0) {
+			/* If number of active or held calls change but there
+			 * was no call setup change this means that there were
 			 * calls present when headset was connected.
-			 *
-			 * TODO should we care about held calls here as well?
 			 */
 			connect_audio();
+		} else if (num_active == 0 && num_held == 0) {
+			disconnect_sco();
 		} else {
 			update_indicator(IND_CALLHELD,
 					num_held ? (num_active ? 1 : 2) : 0);