summaryrefslogtreecommitdiff
path: root/android/handsfree.c
diff options
context:
space:
mode:
authorSzymon Janc <szymon.janc@tieto.com>2015-02-13 14:19:19 +0100
committerSzymon Janc <szymon.janc@tieto.com>2015-02-20 16:25:09 +0100
commitac2ae7f897f0b0be32ce959f90974395c29665a3 (patch)
treed7f3e22b4459afb798882bb76e7270bf59ddb7f4 /android/handsfree.c
parentaa8d69512c174e1e8fffa222d84ef4898991e8c6 (diff)
downloadbluez-ac2ae7f897f0b0be32ce959f90974395c29665a3.tar.gz
android/handsfree: Fix no indicators after rejected incoming call
On KitKat there were some bogus phone_state_change calls after incoming call was rejected from the phone: active=0 hold=0 state=idle active=0 hold=0 state=incoming active=0 hold=0 state=idle active=0 hold=0 state=idle On Lollipop this seems to be fixed and after call is rejected we only get single call with state idle: active=0 hold=0 state=idle So simply reverting workaround commit "Track if incoming call is being rejected" would break KK. Instead, add short timeout after incoming call was rejected. Durring that period we ignore any phone state change to 'incoming' state. If we get any other state change (ie. outgoing call) timer is cleared.
Diffstat (limited to 'android/handsfree.c')
-rw-r--r--android/handsfree.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/android/handsfree.c b/android/handsfree.c
index 7cdc8b4a8..b7aa1dd26 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;
}