diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2008-09-04 17:36:51 +0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2008-09-04 17:36:51 +0300 |
commit | 4449fea64a582999d9bcf4a5f91832c9fdf1e389 (patch) | |
tree | d8b35d60c34107985d5c00d80e3ea4be6181b917 | |
parent | de6c33d2666072676a7e2afc8b9be6f2804242c1 (diff) |
Disallow HFP connections when the telephony plugin isn't yet initialized
-rw-r--r-- | audio/headset.c | 13 | ||||
-rw-r--r-- | audio/manager.c | 11 |
2 files changed, 18 insertions, 6 deletions
diff --git a/audio/headset.c b/audio/headset.c index 74093afa..6ab949cf 100644 --- a/audio/headset.c +++ b/audio/headset.c @@ -1108,6 +1108,10 @@ static DBusMessage *hs_connect(DBusConnection *conn, DBusMessage *msg, ".AlreadyConnected", "Already Connected"); + if (hs->hfp_handle && !ag.telephony_ready) + return g_dbus_create_error(msg, ERROR_INTERFACE ".NotReady", + "Telephony subsystem not ready"); + err = rfcomm_connect(device, NULL, NULL, NULL); if (err < 0) return g_dbus_create_error(msg, ERROR_INTERFACE @@ -1827,6 +1831,14 @@ void headset_set_authorized(struct audio_device *dev) { struct headset *hs = dev->headset; + /* For HFP telephony isn't ready just disconnect */ + if (hs->hfp_active && !ag.telephony_ready) { + error("Unable to accept HFP connection since the telephony " + "subsystem isn't initialized"); + headset_set_state(dev, HEADSET_STATE_DISCONNECTED); + return; + } + hs->rfcomm = hs->tmp_rfcomm; hs->tmp_rfcomm = NULL; @@ -1836,6 +1848,7 @@ void headset_set_authorized(struct audio_device *dev) hs->auto_dc = FALSE; + /* For HSP (no special SLC setup) move to CONNECTED state */ if (!hs->hfp_active) headset_set_state(dev, HEADSET_STATE_CONNECTED); } diff --git a/audio/manager.c b/audio/manager.c index cb241d76..d824548e 100644 --- a/audio/manager.c +++ b/audio/manager.c @@ -464,12 +464,11 @@ static void auth_cb(DBusError *derr, void *user_data) } else { char hs_address[18]; - headset_set_authorized(device); - ba2str(&device->dst, hs_address); - debug("Accepted headset connection from %s for %s", hs_address, device->path); + + headset_set_authorized(device); } } @@ -510,16 +509,16 @@ static void ag_io_cb(GIOChannel *chan, int err, const bdaddr_t *src, goto drop; } + headset_set_state(device, HEADSET_STATE_CONNECT_IN_PROGRESS); + err = btd_request_authorization(&device->src, &device->dst, uuid, auth_cb, device); if (err < 0) { debug("Authorization denied: %s", strerror(-err)); - headset_close_rfcomm(device); + headset_set_state(device, HEADSET_STATE_DISCONNECTED); return; } - headset_set_state(device, HEADSET_STATE_CONNECT_IN_PROGRESS); - return; drop: |