diff --git a/android/handsfree.c b/android/handsfree.c
index 7cdc8b4..b7aa1dd 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
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;
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);
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)
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);
}
}
}
+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)
{
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:
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;
}