Fix managing dbus filters depending on BT state
PATCH 1/1 Fix managing dbus filters depending on BT state
Previously even if BT was disabled, bluetoothd would handle some dbus singals (mostly connected with HFP). Now filters are added when BT is enabled and removed when BT is disabled.
--- audio/manager.c | 4 ++-- audio/telephony-dummy.c | 10 ++++++++++ audio/telephony-maemo5.c | 10 ++++++++++ audio/telephony-maemo6.c | 10 ++++++++++ audio/telephony-ofono.c | 10 ++++++++++ audio/telephony.h | 1 + src/adapter.c | 5 +++++ 7 files changed, 48 insertions(+), 2 deletions(-)
audio/manager.c +2 -2
@@ -1178,7 +1178,7 @@ proceed:btd_register_adapter_driver (&media_server_driver);if (enabled.headset) { -telephony_init (); +telephony_set_state (1 );btd_register_adapter_driver (&headset_server_driver); }
@@ -1220,7 +1220,7 @@ void audio_manager_exit(void)if (enabled.headset) {btd_unregister_adapter_driver (&headset_server_driver); -telephony_exit (); +telephony_set_state (0 ); }if (enabled.gateway)
audio/telephony-dummy.c +10 -0
@@ -57,6 +57,8 @@ static gboolean events_enabled = FALSE;*/ static int response_and_hold =-1 ; +static int telephony_state =0 ; +static struct indicator dummy_indicators[] = { {"battchg" ,"0-5" ,5 , TRUE },
@@ -411,8 +413,16 @@ static GDBusSignalTable dummy_signals[] = { { } }; +int telephony_set_state (int state) +{ + telephony_state = state; +} +int telephony_init (void ) { +if (telephony_state ==0 ) +return ; +uint32_t features =AG_FEATURE_REJECT_A_CALL |AG_FEATURE_ENHANCED_CALL_STATUS |AG_FEATURE_EXTENDED_ERROR_RESULT_CODES ;
audio/telephony-maemo5.c +10 -0
@@ -222,6 +222,8 @@ static char *last_dialed_number = NULL;/* Timer for tracking call creation requests */ static guint create_request_timer =0 ; +static int telephony_state =0 ; +static struct indicator maemo_indicators[] = { {"battchg" ,"0-5" ,5 , TRUE },
@@ -2044,8 +2046,16 @@ static DBusHandlerResult signal_filter(DBusConnection *conn,return DBUS_HANDLER_RESULT_NOT_YET_HANDLED ; } +int telephony_set_state (int state) +{ + telephony_state = state; +} +int telephony_init (void ) { +if (telephony_state ==0 ) +return ; +const char *battery_cap ="battery" ;uint32_t features =AG_FEATURE_EC_ANDOR_NR | AG_FEATURE_INBAND_RINGTONE |
audio/telephony-maemo6.c +10 -0
@@ -181,6 +181,8 @@ static char *last_dialed_number = NULL;/* Timer for tracking call creation requests */ static guint create_request_timer =0 ; +static int telephony_state =0 ; +static struct indicator maemo_indicators[] = { {"battchg" ,"0-5" ,5 , TRUE },
@@ -1937,8 +1939,16 @@ static DBusHandlerResult signal_filter(DBusConnection *conn,return DBUS_HANDLER_RESULT_NOT_YET_HANDLED ; } +int telephony_set_state (int state) +{ + telephony_state = state; +} +int telephony_init (void ) { +if (telephony_state ==0 ) +return ; +const char *battery_cap ="battery" ;uint32_t features =AG_FEATURE_EC_ANDOR_NR | AG_FEATURE_INBAND_RINGTONE |
audio/telephony-ofono.c +10 -0
@@ -96,6 +96,8 @@ static gboolean events_enabled = FALSE;*/ static int response_and_hold =-1 ; +static int telephony_state =0 ; +static struct indicator ofono_indicators[] = { {"battchg" ,"0-5" ,5 , TRUE },
@@ -1062,8 +1064,16 @@ done:dbus_message_unref (reply); } +int telephony_set_state (int state) +{ + telephony_state = state; +} +int telephony_init (void ) { +if (telephony_state ==0 ) +return ; +const char *battery_cap ="battery" ;int ret;
audio/telephony.h +1 -0
@@ -232,5 +232,6 @@ static inline int telephony_get_indicator(const struct indicator *indicators,return -ENOENT ; } +int telephony_set_active (int state);int telephony_init (void );void telephony_exit (void );
src/adapter.c +5 -0
@@ -57,6 +57,7 @@#include "glib-helper.h" #include "agent.h" #include "storage.h" +#include "../audio/telephony.h" #define IO_CAPABILITY_DISPLAYONLY 0x00#define IO_CAPABILITY_DISPLAYYESNO 0x01
@@ -2404,6 +2405,8 @@ int adapter_start(struct btd_adapter *adapter) err =adapter_up (adapter, mode); +telephony_init (); +info ("Adapter %s has been enabled" , adapter->path);return err;
@@ -2533,6 +2536,8 @@ int adapter_stop(struct btd_adapter *adapter)call_adapter_powered_callbacks (adapter, FALSE); +telephony_exit (); +info ("Adapter %s has been disabled" , adapter->path);set_mode_complete (adapter);
Signature · 1 line
1.7.0.4
Hi Bartosz,
Quoted 12 lines · Bartosz Szatkowski
Previously even if BT was disabled, bluetoothd would handle some dbus singals (mostly connected with HFP). Now filters are added when BT is enabled and removed when BT is disabled.
--- audio/manager.c | 4 ++-- audio/telephony-dummy.c | 10 ++++++++++ audio/telephony-maemo5.c | 10 ++++++++++ audio/telephony-maemo6.c | 10 ++++++++++ audio/telephony-ofono.c | 10 ++++++++++ audio/telephony.h | 1 + src/adapter.c | 5 +++++ 7 files changed, 48 insertions(+), 2 deletions(-)
Nack on this one. I understand the issue you're trying to fix but it needs to be done differently.
audio/manager.c proceed: · line 1183
Quoted 12 lines
audio/manager.c +1
-1@@ -1178,7 +1178,7 @@ proceed:btd_register_adapter_driver (&media_server_driver);if (enabled.headset) { -telephony_init (); +telephony_set_state (1 );btd_register_adapter_driver (&headset_server_driver); }
If you're gonna call this "state" you should have proper defines or enums for the values, however in this case it's essentially a boolean so that's not necessary. In fact since it's a boolean you don't even need to have any new function or variable at all for it: just use telephony_init and telephony_exit.
Quoted 11 lines
src/adapter.c +1
-0@@ -57,6 +57,7 @@#include "glib-helper.h" #include "agent.h" #include "storage.h" +#include "../audio/telephony.h" #define IO_CAPABILITY_DISPLAYONLY 0x00#define IO_CAPABILITY_DISPLAYYESNO 0x01
src/adapter.c int adapter_start(struct btd_adapter *adapter) · line 2409
Quoted 5 lines
src/adapter.c +2
-0@@ -2404,6 +2405,8 @@ int adapter_start(struct btd_adapter *adapter) err =adapter_up (adapter, mode); +telephony_init (); +
This is just wrong. The core daemon should never have direct access to the telephony driver. Instead, you should have the audio plugin (probably audio/manager.c or audio/headset.c) register a adapter powered callback and then call telehony_init/exit from that callback.
Johan
Luiz Augusto von Dentz
maintainerHi,
Quoted 52 lines · Johan Hedberg
Hi Bartosz,
Quoted 11 lines · Bartosz Szatkowski
Previously even if BT was disabled, bluetoothd would handle some dbus singals (mostly connected with HFP). Now filters are added when BT is enabled and removed when BT is disabled.
---
audio/manager.c | 4 ++--audio/telephony-dummy.c| 10 ++++++++++audio/telephony-maemo5.c| 10 ++++++++++audio/telephony-maemo6.c| 10 ++++++++++audio/telephony-ofono.c| 10 ++++++++++audio/telephony.h| 1 +
src/adapter.c | 5 +++++Quoted 1 line
7 files changed, 48 insertions(+), 2 deletions(-)Nack on this one. I understand the issue you're trying to fix but it needs to be done differently.
audio/manager.c proceed: · line 1183
Quoted 12 lines
audio/manager.c +1
-1@@ -1178,7 +1178,7 @@ proceed: btd_register_adapter_driver(&media_server_driver); if (enabled.headset) { - telephony_init(); + telephony_set_state(1); btd_register_adapter_driver(&headset_server_driver); }If you're gonna call this "state" you should have proper defines or enums for the values, however in this case it's essentially a boolean so that's not necessary. In fact since it's a boolean you don't even need to have any new function or variable at all for it: just use
telephony_initandtelephony_exit.Quoted 14 lines
src/adapter.c +1
-0@@ -57,6 +57,7 @@ #include "glib-helper.h" #include "agent.h" #include "storage.h" +#include "../audio/telephony.h" #define IO_CAPABILITY_DISPLAYONLY 0x00 #define IO_CAPABILITY_DISPLAYYESNO 0x01@@ -2404,6 +2405,8 @@ int adapter_start(struct btd_adapter *adapter) err = adapter_up(adapter, mode);
Quoted 7 lines
src/adapter.c int adapter_start(struct btd_adapter *adapter) · line 2409
Quoted 2 lines
src/adapter.c +2
-0+ telephony_init(); +This is just wrong. The core daemon should never have direct access to the telephony driver. Instead, you should have the audio plugin (probably
audio/manager.coraudio/headset.c) register a adapter powered callback and then call telehony_init/exit from that callback.
I have an almost working version of this using adapter drivers and powered changes via callback registration, the tricky part here is how to detect when to do headset_init/headset_exit since those should be called only once. I didn't know there somebody working on this but anyway I gonna try to finish this asap.
Signature · 2 lines
Luiz Augusto von Dentz Computer Engineer
Quoted 69 lines · Luiz Augusto von Dentz
Hi,
Quoted 52 lines · Johan Hedberg
Hi Bartosz,
Quoted 11 lines · Bartosz Szatkowski
Previously even if BT was disabled, bluetoothd would handle some dbus singals (mostly connected with HFP). Now filters are added when BT is enabled and removed when BT is disabled.
---
audio/manager.c | 4 ++--audio/telephony-dummy.c| 10 ++++++++++audio/telephony-maemo5.c| 10 ++++++++++audio/telephony-maemo6.c| 10 ++++++++++audio/telephony-ofono.c| 10 ++++++++++audio/telephony.h| 1 +
src/adapter.c | 5 +++++Quoted 1 line
7 files changed, 48 insertions(+), 2 deletions(-)Nack on this one. I understand the issue you're trying to fix but it needs to be done differently.
audio/manager.c proceed: · line 1183
Quoted 12 lines
audio/manager.c +1
-1@@ -1178,7 +1178,7 @@ proceed: btd_register_adapter_driver(&media_server_driver); if (enabled.headset) { - telephony_init(); + telephony_set_state(1); btd_register_adapter_driver(&headset_server_driver); }If you're gonna call this "state" you should have proper defines or enums for the values, however in this case it's essentially a boolean so that's not necessary. In fact since it's a boolean you don't even need to have any new function or variable at all for it: just use
telephony_initandtelephony_exit.Quoted 14 lines
src/adapter.c +1
-0@@ -57,6 +57,7 @@ #include "glib-helper.h" #include "agent.h" #include "storage.h" +#include "../audio/telephony.h" #define IO_CAPABILITY_DISPLAYONLY 0x00 #define IO_CAPABILITY_DISPLAYYESNO 0x01@@ -2404,6 +2405,8 @@ int adapter_start(struct btd_adapter *adapter) err = adapter_up(adapter, mode);Quoted 7 lines
src/adapter.c int adapter_start(struct btd_adapter *adapter) · line 2409
Quoted 2 lines
src/adapter.c +2
-0+ telephony_init(); +This is just wrong. The core daemon should never have direct access to the telephony driver. Instead, you should have the audio plugin (probably
audio/manager.coraudio/headset.c) register a adapter powered callback and then call telehony_init/exit from that callback.I have an almost working version of this using adapter drivers and powered changes via callback registration, the tricky part here is how to detect when to do headset_init/headset_exit since those should be called only once. I didn't know there somebody working on this but anyway I gonna try to finish this asap.
Quoted 4 lines
--
Luiz Augusto von Dentz
Computer Engineer
Hi Luiz,
please fell free to send it (no hard fillings :) ) Ive just getting to know bluez so probably it would take me a while to get through whole plugin/callback subsystem.
Signature · 2 lines
Pozdrowienia, Bartosz Szatkowski