Open Source Telephony
 help / color / mirror / Atom feed
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis <frederic.danis@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH] emulator: fix CCWA for PTS
Date: Fri, 24 Jun 2011 16:11:05 +0200	[thread overview]
Message-ID: <1308924665-9039-1-git-send-email-frederic.danis@linux.intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 5264 bytes --]

During test TP/TCA/BV-05-I [Terminate Ongoing Call – While Call Waiting]
PTS fails if multiple +CCWA are sent (waiting for 1st phone number when
waiting one becomes incoming, intead of 2nd phone number).
So, send only 1 +CCWA.

Update RING timer management to be started as soon as an incoming call
exists, and retrieve +CLIP info for incoming or waiting call (in case
of waiting call becoming incoming call, call indicator changes before
internal call status is updated)
---
 src/emulator.c |   74 ++++++++++++++++++++++++++++++-------------------------
 1 files changed, 40 insertions(+), 34 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c
index 906404d..eea69f0 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -352,7 +352,8 @@ static void notify_ccwa(struct ofono_emulator *em)
 	 */
 	char str[OFONO_MAX_PHONE_NUMBER_LENGTH + 14 + 1];
 
-	if (!em->ccwa)
+	if ((em->type == OFONO_EMULATOR_TYPE_HFP && em->slc == FALSE) ||
+			!em->ccwa)
 		return;
 
 	c = find_call_with_status(em, CALL_STATUS_WAITING);
@@ -366,8 +367,9 @@ static void notify_ccwa(struct ofono_emulator *em)
 		g_at_server_send_unsolicited(em->server, "+CCWA: \"\",128");
 }
 
-static void notify_ring(struct ofono_emulator *em)
+static gboolean notify_ring(void *user_data)
 {
+	struct ofono_emulator *em = user_data;
 	struct ofono_call *c;
 	const char *phone;
 	/*
@@ -376,15 +378,25 @@ static void notify_ring(struct ofono_emulator *em)
 	 */
 	char str[OFONO_MAX_PHONE_NUMBER_LENGTH + 14 + 1];
 
+	if (em->type == OFONO_EMULATOR_TYPE_HFP && em->slc == FALSE)
+		return TRUE;
+
 	g_at_server_send_unsolicited(em->server, "RING");
 
 	if (!em->clip)
-		return;
+		return TRUE;
 
 	c = find_call_with_status(em, CALL_STATUS_INCOMING);
 
+	/*
+	 * In case of waiting call becoming an incoming call, call status
+	 * change may not have been done yet, so try to find waiting call too
+	 */
 	if (c == NULL)
-		return;
+		c = find_call_with_status(em, CALL_STATUS_WAITING);
+
+	if (c == NULL)
+		return TRUE;
 
 	switch (c->clip_validity) {
 	case CLIP_VALIDITY_VALID:
@@ -397,22 +409,6 @@ static void notify_ring(struct ofono_emulator *em)
 		g_at_server_send_unsolicited(em->server, "+CLIP: \"\",128");
 		break;
 	}
-}
-
-static gboolean send_callsetup_notification(gpointer user_data)
-{
-	struct ofono_emulator *em = user_data;
-	struct indicator *call_ind;
-
-	if (em->type == OFONO_EMULATOR_TYPE_HFP && em->slc == FALSE)
-		return TRUE;
-
-	call_ind = find_indicator(em, OFONO_EMULATOR_IND_CALL, NULL);
-
-	if (call_ind->value == OFONO_EMULATOR_CALL_INACTIVE)
-		notify_ring(em);
-	else
-		notify_ccwa(em);
 
 	return TRUE;
 }
@@ -1078,7 +1074,10 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
 	char buf[20];
 	struct indicator *ind;
 	struct indicator *call_ind;
+	struct indicator *cs_ind;
+	gboolean call;
 	gboolean callsetup;
+	gboolean waiting;
 
 	ind = find_indicator(em, name, &i);
 
@@ -1089,16 +1088,20 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
 	ind->value = value;
 
 	call_ind = find_indicator(em, OFONO_EMULATOR_IND_CALL, NULL);
+	cs_ind = find_indicator(em, OFONO_EMULATOR_IND_CALLSETUP, NULL);
 
-	callsetup = g_str_equal(name, OFONO_EMULATOR_IND_CALLSETUP);
+	call = (ind == call_ind);
+	callsetup = (ind == cs_ind);
 
 	/*
 	 * When callsetup indicator goes to Incoming and there is an active
 	 * call a +CCWA should be sent before +CIEV
 	 */
-	if (callsetup && value == OFONO_EMULATOR_CALLSETUP_INCOMING &&
-			call_ind->value == OFONO_EMULATOR_CALL_ACTIVE)
-		send_callsetup_notification(em);
+	waiting = (callsetup && value == OFONO_EMULATOR_CALLSETUP_INCOMING &&
+			call_ind->value == OFONO_EMULATOR_CALL_ACTIVE);
+
+	if (waiting)
+		notify_ccwa(em);
 
 	if (em->events_mode == 3 && em->events_ind && em->slc) {
 		sprintf(buf, "+CIEV: %d,%d", i, ind->value);
@@ -1106,21 +1109,24 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
 	}
 
 	/*
-	 * Ring timer should be started when callsetup indicator is set to
-	 * Incoming.  If there is no active call, a first RING should be
-	 * sent just after the +CIEV and should be stopped for all other
-	 * values of callsetup
+	 * Ring timer should be started when:
+	 * - callsetup indicator is set to Incoming and there is no active call
+	 *   (not a waiting call)
+	 * - or call indicator is set to inactive while callsetup is already
+	 *   set to Incoming.
+	 * In those cases, a first RING should be sent just after the +CIEV
+	 * Ring timer should be stopped for all other values of callsetup
 	 */
-	if (!callsetup)
+	if (!((callsetup && !waiting) ||
+			(call && value == OFONO_EMULATOR_CALL_INACTIVE &&
+			cs_ind->value == OFONO_EMULATOR_CALLSETUP_INCOMING)))
 		return;
 
-	switch (value) {
+	switch (cs_ind->value) {
 	case OFONO_EMULATOR_CALLSETUP_INCOMING:
-		if (call_ind->value == OFONO_EMULATOR_CALL_INACTIVE)
-			send_callsetup_notification(em);
-
+		notify_ring(em);
 		em->callsetup_source = g_timeout_add_seconds(RING_TIMEOUT,
-					send_callsetup_notification, em);
+							notify_ring, em);
 		break;
 	default:
 		if (em->callsetup_source > 0) {
-- 
1.7.1


                 reply	other threads:[~2011-06-24 14:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1308924665-9039-1-git-send-email-frederic.danis@linux.intel.com \
    --to=frederic.danis@linux.intel.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox