Skip to contentSkip to conversation

emulator: Fix PTS test case TC_AG_TWC_BV_02_I

PATCH New Denis Kenzior 1 participant 1 message Mar 6, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 emulator: Fix PTS test case TC_AG_TWC_BV_02_I

---
 src/emulator.c |   48 +++++++++++++++++++++++++++++-------------------
 1 files changed, 29 insertions(+), 19 deletions(-)
src/emulator.c +29 -19
index 262e782..5f460c2 100644
@@ -36,6 +36,8 @@
 
 #define RING_TIMEOUT 3
 
+#define EMULATOR_FLAG_WAITING_TRANSITION	1
+
 struct ofono_emulator {
 	struct ofono_atom *atom;
 	enum ofono_emulator_type type;
@@ -52,6 +54,7 @@ struct ofono_emulator {
 	gboolean clip;
 	gboolean ccwa;
 	int pns_id;
+	int flags;
 };
 
 struct indicator {
@@ -420,14 +423,6 @@ static gboolean notify_ring(void *user_data)
 		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)
-		c = find_call_with_status(em, CALL_STATUS_WAITING);
-
 	if (c == NULL)
 		return TRUE;
 
@@ -1186,19 +1181,29 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
 	gboolean callsetup;
 	gboolean waiting;
 
+	ofono_debug("name: %s, value: %d", name, value);
+
 	ind = find_indicator(em, name, &i);
 
-	if (ind == NULL || ind->value == value || value < ind->min
-			|| value > ind->max)
+	if (ind == NULL || value < ind->min || value > ind->max)
+		return;
+
+	cs_ind = find_indicator(em, OFONO_EMULATOR_IND_CALLSETUP, NULL);
+	callsetup = ind == cs_ind;
+
+	if (em->flags & EMULATOR_FLAG_WAITING_TRANSITION) {
+		if (ind->value == value && callsetup)
+			goto callsetup;
+	}
+
+	if (ind->value == value)
 		return;
 
 	ind->value = value;
 
 	call_ind = find_indicator(em, OFONO_EMULATOR_IND_CALL, NULL);
-	cs_ind = find_indicator(em, OFONO_EMULATOR_IND_CALLSETUP, NULL);
 
 	call = ind == call_ind;
-	callsetup = ind == cs_ind;
 
 	/*
 	 * When callsetup indicator goes to Incoming and there is an active
@@ -1218,6 +1223,16 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
 			ind->deferred = TRUE;
 	}
 
+callsetup:
+	/*
+	 * In case of waiting call becoming an incoming call, call status
+	 * change may not have been done yet, so do nothing
+	 */
+	if (find_call_with_status(em, CALL_STATUS_WAITING) != NULL) {
+		em->flags |= EMULATOR_FLAG_WAITING_TRANSITION;
+		return;
+	}
+
 	/*
 	 * Ring timer should be started when:
 	 * - callsetup indicator is set to Incoming and there is no active call
@@ -1227,17 +1242,12 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
 	 * 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 (waiting)
-		return;
-
-	/* Call state went from active/held + waiting -> incoming */
-	if (call && value == OFONO_EMULATOR_CALL_INACTIVE &&
-			cs_ind->value == OFONO_EMULATOR_CALLSETUP_INCOMING)
-		goto start_ring;
 
 	if (!callsetup)
 		return;
 
+	em->flags &= ~EMULATOR_FLAG_WAITING_TRANSITION;
+
 	if (value != OFONO_EMULATOR_CALLSETUP_INCOMING) {
 		if (em->callsetup_source > 0) {
 			g_source_remove(em->callsetup_source);
Signature · 1 line
1.7.3.4