Fix wrong use of dbus interface 13/207713/1 accepted/tizen/unified/20190613.061538 submit/tizen/20190612.081916
authorDeokhyun Kim <dukan.kim@samsung.com>
Tue, 11 Jun 2019 08:57:21 +0000 (17:57 +0900)
committerDeokhyun Kim <dukan.kim@samsung.com>
Tue, 11 Jun 2019 08:57:36 +0000 (17:57 +0900)
Change-Id: I68ff2b37cb1f7cf19a3b5aee5eb46c18b03a5688
Signed-off-by: Deokhyun Kim <dukan.kim@samsung.com>
bt-api/bt-telephony.c
bt-service/bt-service-event-receiver.c

index 8e531ba..8bc75f3 100644 (file)
@@ -490,18 +490,7 @@ static void __bluetooth_telephony_event_filter(GDBusConnection *connection,
 {
        BT_DBG("+");
 
-       if (strcasecmp(interface_name, HFP_AGENT_SERVICE) == 0) {
-               if (strcasecmp(signal_name, HFP_NREC_STATUS_CHANGE) == 0)
-                       __bluetooth_handle_nrec_status_change(parameters);
-               else if (strcasecmp(signal_name, HFP_ANSWER_CALL) == 0)
-                       __bluetooth_telephony_answer_call(parameters);
-               else if (strcasecmp(signal_name, HFP_REJECT_CALL) == 0)
-                       __bluetooth_telephony_reject_call(parameters);
-               else if (strcasecmp(signal_name, HFP_RELEASE_CALL) == 0)
-                       __bluetooth_telephony_release_call(parameters);
-               else if (strcasecmp(signal_name, HFP_THREEWAY_CALL) == 0)
-                       __bluetooth_telephony_threeway_call(parameters);
-       } else if (strcasecmp(interface_name, BLUEZ_HEADSET_INTERFACE) == 0) {
+       if (strcasecmp(interface_name, BLUEZ_HEADSET_INTERFACE) == 0) {
                if (strcasecmp(signal_name, "PropertyChanged") == 0) {
                        GVariant *values;
                        gchar *property;
@@ -626,7 +615,16 @@ static void __bluetooth_telephony_event_filter(GDBusConnection *connection,
                        }
 
                        g_variant_unref(values);
-               }
+               } else if (strcasecmp(signal_name, HFP_NREC_STATUS_CHANGE) == 0)
+                       __bluetooth_handle_nrec_status_change(parameters);
+               else if (strcasecmp(signal_name, HFP_ANSWER_CALL) == 0)
+                       __bluetooth_telephony_answer_call(parameters);
+               else if (strcasecmp(signal_name, HFP_REJECT_CALL) == 0)
+                       __bluetooth_telephony_reject_call(parameters);
+               else if (strcasecmp(signal_name, HFP_RELEASE_CALL) == 0)
+                       __bluetooth_telephony_release_call(parameters);
+               else if (strcasecmp(signal_name, HFP_THREEWAY_CALL) == 0)
+                       __bluetooth_telephony_threeway_call(parameters);
        }
        BT_DBG("-");
 }
@@ -1209,89 +1207,22 @@ int __bt_telephony_event_subscribe_signal(GDBusConnection *conn,
        if (conn == NULL)
                return -1;
 
-       static guint subscribe_event1_id = 0;
-       static guint subscribe_event2_id = 0;
-       static guint subscribe_event3_id = 0;
-       static guint subscribe_event4_id = 0;
-       static guint subscribe_event5_id = 0;
-       static guint subscribe_event6_id = 0;
+       static guint event_id = 0;
 
        if (subscribe == TRUE) {
-               if (subscribe_event1_id == 0) {
-                       subscribe_event1_id = g_dbus_connection_signal_subscribe(conn,
+               if (event_id == 0) {
+                       event_id = g_dbus_connection_signal_subscribe(conn,
                                        NULL, BLUEZ_HEADSET_INTERFACE,
-                                       "PropertyChanged", NULL, NULL, 0,
-                                       __bluetooth_telephony_event_filter,
-                                       NULL, NULL);
-               }
-               if (subscribe_event2_id == 0) {
-                       subscribe_event2_id = g_dbus_connection_signal_subscribe(conn,
-                                       NULL, HFP_AGENT_SERVICE,
-                                       HFP_NREC_STATUS_CHANGE, NULL, NULL, 0,
-                                       __bluetooth_telephony_event_filter,
-                                       NULL, NULL);
-               }
-
-               if (subscribe_event3_id == 0) {
-                       subscribe_event3_id = g_dbus_connection_signal_subscribe(conn,
-                                       NULL, HFP_AGENT_SERVICE,
-                                       HFP_ANSWER_CALL, NULL, NULL, 0,
-                                       __bluetooth_telephony_event_filter,
-                                       NULL, NULL);
-               }
-               if (subscribe_event4_id == 0) {
-                       subscribe_event4_id = g_dbus_connection_signal_subscribe(conn,
-                                       NULL, HFP_AGENT_SERVICE,
-                                       HFP_REJECT_CALL, NULL, NULL, 0,
-                                       __bluetooth_telephony_event_filter,
-                                       NULL, NULL);
-               }
-               if (subscribe_event5_id == 0) {
-                       subscribe_event5_id = g_dbus_connection_signal_subscribe(conn,
-                                       NULL, HFP_AGENT_SERVICE,
-                                       HFP_RELEASE_CALL, NULL, NULL, 0,
-                                       __bluetooth_telephony_event_filter,
-                                       NULL, NULL);
-               }
-               if (subscribe_event6_id == 0) {
-                       subscribe_event6_id = g_dbus_connection_signal_subscribe(conn,
-                                       NULL, HFP_AGENT_SERVICE,
-                                       HFP_THREEWAY_CALL, NULL, NULL, 0,
+                                       NULL, NULL, NULL, 0,
                                        __bluetooth_telephony_event_filter,
                                        NULL, NULL);
                }
-
                return BLUETOOTH_TELEPHONY_ERROR_NONE;
        } else {
-               if (subscribe_event1_id > 0) {
-                       g_dbus_connection_signal_unsubscribe(conn,
-                                       subscribe_event1_id);
-                       subscribe_event1_id = 0;
-               }
-               if (subscribe_event2_id > 0) {
-                       g_dbus_connection_signal_unsubscribe(conn,
-                                       subscribe_event2_id);
-                       subscribe_event2_id = 0;
-               }
-               if (subscribe_event3_id > 0) {
-                       g_dbus_connection_signal_unsubscribe(conn,
-                                       subscribe_event3_id);
-                       subscribe_event3_id = 0;
-               }
-               if (subscribe_event4_id > 0) {
-                       g_dbus_connection_signal_unsubscribe(conn,
-                                       subscribe_event4_id);
-                       subscribe_event4_id = 0;
-               }
-               if (subscribe_event5_id > 0) {
-                       g_dbus_connection_signal_unsubscribe(conn,
-                                       subscribe_event5_id);
-                       subscribe_event5_id = 0;
-               }
-               if (subscribe_event6_id > 0) {
+               if (event_id > 0) {
                        g_dbus_connection_signal_unsubscribe(conn,
-                                       subscribe_event6_id);
-                       subscribe_event6_id = 0;
+                                       event_id);
+                       event_id = 0;
                }
                return BLUETOOTH_TELEPHONY_ERROR_NONE;
        }
index 105943a..ed3bb9c 100644 (file)
@@ -2862,7 +2862,9 @@ static  void __bt_manager_event_filter(GDBusConnection *connection,
        } else if (g_strcmp0(interface_name, BT_NETWORK_SERVER_INTERFACE) == 0) {
                _bt_handle_network_server_event(parameters, signal_name);
        } else if (g_strcmp0(interface_name, BT_HEADSET_INTERFACE) == 0) {
-               _bt_handle_headset_event(parameters, object_path);
+               if (g_strcmp0(signal_name, "PropertyChanged") == 0) {
+                       _bt_handle_headset_event(parameters, object_path);
+               }
        } else if (g_strcmp0(interface_name, BT_SINK_INTERFACE) == 0) {
                _bt_handle_sink_event(parameters, object_path);
        } else if (g_strcmp0(interface_name, BT_AGENT_INTERFACE) == 0) {
@@ -3270,7 +3272,7 @@ int _bt_register_audio_subscribe_signal(GDBusConnection *conn,
                if (subs_headset_id == -1) {
                        subs_headset_id = g_dbus_connection_signal_subscribe(conn,
                                NULL, BT_HEADSET_INTERFACE,
-                               NULL, NULL, NULL, 0,
+                               "PropertyChanged", NULL, NULL, 0,
                                __bt_manager_event_filter,
                                NULL, NULL);
                }