From 825feb8cd52345bc950aa7906db17de41bfcd3a9 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Wed, 13 Feb 2013 20:14:32 -0600 Subject: hfp_hf_bluez5: Use faster method of disable() --- plugins/hfp_hf_bluez5.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'plugins/hfp_hf_bluez5.c') diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c index 43acd998..ca20bfc0 100644 --- a/plugins/hfp_hf_bluez5.c +++ b/plugins/hfp_hf_bluez5.c @@ -248,21 +248,26 @@ static int hfp_enable(struct ofono_modem *modem) static int hfp_disable(struct ofono_modem *modem) { - const char *path; + struct hfp *hfp = ofono_modem_get_data(modem); + struct hfp_slc_info *info = &hfp->info; + GIOChannel *channel; + int fd; DBG("%p", modem); - path = ofono_modem_get_string(modem, "DevicePath"); - /* - * We call Device1.DisconnectProfile() for the connection to be - * dropped, which will cause the profile RequestDisconnection() method - * to be called which will bring the modem down + * Instead of triggering two round trips to BlueZ (DisconnectProfile, + * RequestDisconnection) simply kill the connection on the RFCOMM fd + * we already have. But for this we have to call shutdown(). */ - bt_disconnect_profile(ofono_dbus_get_connection(), path, HFP_AG_UUID, - NULL, NULL); + channel = g_at_chat_get_channel(info->chat); + fd = g_io_channel_unix_get_fd(channel); + shutdown(fd, SHUT_RDWR); - return -EINPROGRESS; + g_at_chat_unref(info->chat); + info->chat = NULL; + + return 0; } static void hfp_pre_sim(struct ofono_modem *modem) -- cgit v1.2.3