Diff between aa8d69512c174e1e8fffa222d84ef4898991e8c6 and ac2ae7f897f0b0be32ce959f90974395c29665a3

Changed Files

File Additions Deletions Status
android/handsfree.c +32 -6 modified

Full Patch

diff --git a/android/handsfree.c b/android/handsfree.c
index 7cdc8b4..b7aa1dd 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -127,7 +127,7 @@ struct hf_device {
 	int num_active;
 	int num_held;
 	int setup_state;
-	bool call_hanging_up;
+	guint call_hanging_up;
 
 	uint8_t negotiated_codec;
 	uint8_t proposed_codec;
@@ -263,6 +263,9 @@ static void device_destroy(struct hf_device *dev)
 
 	g_free(dev->clip);
 
+	if (dev->call_hanging_up)
+		g_source_remove(dev->call_hanging_up);
+
 	set_audio_state(dev, HAL_EV_HANDSFREE_AUDIO_STATE_DISCONNECTED);
 	set_state(dev, HAL_EV_HANDSFREE_CONN_STATE_DISCONNECTED);
 
@@ -2248,6 +2251,11 @@ static gboolean ring_cb(gpointer user_data)
 static void phone_state_dialing(struct hf_device *dev, int num_active,
 								int num_held)
 {
+	if (dev->call_hanging_up) {
+		g_source_remove(dev->call_hanging_up);
+		dev->call_hanging_up = 0;
+	}
+
 	update_indicator(dev, IND_CALLSETUP, 2);
 
 	if (num_active == 0 && num_held > 0)
@@ -2260,6 +2268,11 @@ static void phone_state_dialing(struct hf_device *dev, int num_active,
 static void phone_state_alerting(struct hf_device *dev, int num_active,
 								int num_held)
 {
+	if (dev->call_hanging_up) {
+		g_source_remove(dev->call_hanging_up);
+		dev->call_hanging_up = 0;
+	}
+
 	update_indicator(dev, IND_CALLSETUP, 3);
 }
 
@@ -2334,6 +2347,17 @@ static void phone_state_incoming(struct hf_device *dev, int num_active,
 	}
 }
 
+static gboolean hang_up_cb(gpointer user_data)
+{
+	struct hf_device *dev = user_data;
+
+	DBG("");
+
+	dev->call_hanging_up = 0;
+
+	return FALSE;
+}
+
 static void phone_state_idle(struct hf_device *dev, int num_active,
 								int num_held)
 {
@@ -2361,9 +2385,11 @@ static void phone_state_idle(struct hf_device *dev, int num_active,
 
 		update_indicator(dev, IND_CALLSETUP, 0);
 
-		if (num_active == dev->num_active && num_held == dev->num_held)
-			dev->call_hanging_up = true;
-
+		if (num_active == 0 && num_held == 0 &&
+				num_active == dev->num_active &&
+				num_held == dev->num_held)
+			dev->call_hanging_up = g_timeout_add(800, hang_up_cb,
+									dev);
 		break;
 	case HAL_HANDSFREE_CALL_STATE_DIALING:
 	case HAL_HANDSFREE_CALL_STATE_ALERTING:
@@ -2376,9 +2402,9 @@ static void phone_state_idle(struct hf_device *dev, int num_active,
 		update_indicator(dev, IND_CALLSETUP, 0);
 		break;
 	case HAL_HANDSFREE_CALL_STATE_IDLE:
-
 		if (dev->call_hanging_up) {
-			dev->call_hanging_up = false;
+			g_source_remove(dev->call_hanging_up);
+			dev->call_hanging_up = 0;
 			return;
 		}