Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] android/handsfree: Connect audio when Android framemework expects it
@ 2014-03-15 19:58 Marcin Kraglak
  2014-03-15 22:52 ` Szymon Janc
  0 siblings, 1 reply; 4+ messages in thread
From: Marcin Kraglak @ 2014-03-15 19:58 UTC (permalink / raw)
  To: linux-bluetooth

There are few cases when framework doesn't call connect_audio method
from HAL but we should do it internally. Call connect_audio if
we started dialing or we accepted incoming call. Also if headset
connects during active call, start SCO connection. We don't have to
disconnect SCO internally, because Android always call disconect_audio
when call has finished.
---
 android/handsfree.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/android/handsfree.c b/android/handsfree.c
index d4dc596..ec59287 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);
@@ -2088,6 +2095,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;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [PATCH] android/handsfree: Connect audio when Android framemework expects it
@ 2014-03-15 19:54 Marcin Kraglak
  2014-03-16  0:35 ` Marcel Holtmann
  0 siblings, 1 reply; 4+ messages in thread
From: Marcin Kraglak @ 2014-03-15 19:54 UTC (permalink / raw)
  To: linux-bluetooth

There are few cases when framework doesn't call connect_audio method
from HAL but we should do it internally. Call connect_audio if
we started dialing or we accepted incoming call. Also if headset
connects during active call, start SCO connection. We don't have to
disconnect SCO internally, because Android always call disconect_audio
when call has finished.
---
 android/handsfree.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/android/handsfree.c b/android/handsfree.c
index d4dc596..61a9816 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,13 +2062,16 @@ 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);
 
 		update_indicator(IND_CALLSETUP, 0);
+
 		break;
 	case HAL_HANDSFREE_CALL_STATE_DIALING:
 	case HAL_HANDSFREE_CALL_STATE_ALERTING:
@@ -2088,6 +2096,10 @@ 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;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-03-16  0:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-15 19:58 [PATCH] android/handsfree: Connect audio when Android framemework expects it Marcin Kraglak
2014-03-15 22:52 ` Szymon Janc
  -- strict thread matches above, loose matches on Subject: below --
2014-03-15 19:54 Marcin Kraglak
2014-03-16  0:35 ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox