Invoke HAL_DISCOVERY_STATE_STOPPED event once
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / bluez_hal / src / bt-hal-event-receiver.c
index 654560f..b74a110 100644 (file)
@@ -126,7 +126,6 @@ static gboolean __bt_hal_discovery_finished_cb(gpointer user_data)
        struct hal_ev_discovery_state_changed ev;
        ev.state = HAL_DISCOVERY_STATE_STOPPED;
        event_cb(HAL_EV_DISCOVERY_STATE_CHANGED, &ev, sizeof(ev));
-       DBG("-");
 
        return FALSE;
 }
@@ -226,8 +225,6 @@ static void __bt_hal_adapter_property_changed_event(GVariant *msg)
        ev->num_props = 0;
        ev->status = BT_STATUS_SUCCESS;
 
-       DBG("+");
-
        while (g_variant_iter_loop(&value_iter, "{sv}", &key, &value)) {
                if (!g_strcmp0(key, "Address")) {
                        uint8_t bdaddr[6];
@@ -366,7 +363,6 @@ static void __bt_hal_adapter_property_changed_event(GVariant *msg)
                        DBG("##Discovering = [%d]", is_discovering);
 
                        if (is_discovering == FALSE) {
-                               DBG("###### Adapter Has stopped Discovering ######");
                                /* In Tizen Bluez, this actually does not mean Discovery is stopped
                                   in Bluez. Tizen Bluez sends this event after a certain timeout,
                                   Therefore, we must forecefully call StopDiscovery to stop discovery in BlueZ */
@@ -386,13 +382,17 @@ static void __bt_hal_adapter_property_changed_event(GVariant *msg)
                                                DBUS_TIMEOUT, NULL,
                                                &err);
                                if (err) {
+                                       struct hal_ev_discovery_state_changed ev;
+
                                        ERR("Dbus Error : %s", err->message);
 
+                                       if (g_strrstr(err->message, "No discovery started"))
+                                               continue;
+
                                        /* This error is thrown by Bluez, as Discovery is already stopped.
                                           Discovery is stopped if user cancels on going discovery.
                                           In order to maintain correct state of Bluetooth Discovery state,
                                           simply send Discovery stopped event to HAL user */
-                                       struct hal_ev_discovery_state_changed ev;
                                        ev.state = HAL_DISCOVERY_STATE_STOPPED;
                                        event_cb(HAL_EV_DISCOVERY_STATE_CHANGED, &ev, sizeof(ev));
                                        g_clear_error(&err);
@@ -404,7 +404,6 @@ static void __bt_hal_adapter_property_changed_event(GVariant *msg)
                                }
 
                        } else {
-                               DBG("###### Adapter Has started Discovering ######");
                                struct hal_ev_discovery_state_changed ev;
                                ev.state = HAL_DISCOVERY_STATE_STARTED;
                                event_cb(HAL_EV_DISCOVERY_STATE_CHANGED, &ev, sizeof(ev));
@@ -450,7 +449,7 @@ static void __bt_hal_adapter_property_changed_event(GVariant *msg)
                        ev->num_props++;
                } else if (!g_strcmp0(key, "Modalias")) {
                        char *modalias = NULL;
-                       g_variant_get(value, "s", &modalias);
+                       g_variant_get(value, "&s", &modalias);
                        DBG("##Adapter ModAlias [%s]", modalias);
                } else if (!g_strcmp0(key, "SupportedLEFeatures")) {
                        DBG("##LE Supported features");
@@ -508,62 +507,20 @@ static void __bt_hal_adapter_property_changed_event(GVariant *msg)
                DBG("Send Adapter properties changed event to HAL user, Num Prop [%d] total size [%zd]", ev->num_props, size);
                event_cb(HAL_EV_ADAPTER_PROPS_CHANGED, buf, size);
        }
-
-       DBG("-");
-}
-
-static void __bt_hal_flight_ps_mode_cb(keynode_t *node, void *data)
-{
-       gboolean flight_mode = FALSE;
-       int type;
-       DBG_SECURE("HAL callback hit");
-       DBG_SECURE("key=%s", vconf_keynode_get_name(node));
-       type = vconf_keynode_get_type(node);
-       if (type == VCONF_TYPE_BOOL) {
-               flight_mode = vconf_keynode_get_bool(node);
-               if (flight_mode != TRUE) {
-                       ERR("Ignore the event");
-                       return;
-               } else {
-                       ERR("Flight Mode == TRUE");
-               }
-       } else {
-               ERR("Invaild vconf key type : %d", type);
-               return;
-       }
-       DBG("Enabling core now");
-       _bt_hal_enable_core();
-}
-
-static void _bt_hal_register_vconf_handler(void)
-{
-       DBG("+");
-
-       if (vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
-               (vconf_callback_fn)__bt_hal_flight_ps_mode_cb, NULL) < 0)
-                       ERR("Unable to register key handler");
-       DBG("Telephony is disabled");
-       if (vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE,
-               (vconf_callback_fn)__bt_hal_flight_ps_mode_cb, NULL) < 0)
-                       ERR("Unable to register key handler");
 }
 
 void _bt_hal_handle_adapter_event(GVariant *msg, const char *member)
 {
-       DBG("+");
-
        if (member == NULL)
                return;
 
        if (strcasecmp(member, "DeviceCreated") == 0) {
                DBG("DeviceCreated: Unhandled");
        } else if (strcasecmp(member, "AdvertisingEnabled") == 0) {
-               DBG("AdvertisingEnabled");
-               DBG("Advertising Enabled");
                int slot_id;
                gboolean status = FALSE;
                g_variant_get(msg, "(ib)", &slot_id, &status);
-               DBG("Advertising Enabled : server_slot_id [%d]  status [%d]", slot_id, status);
+
                /* Send event to application */
                _bt_hal_set_advertising_status(slot_id, status);
        } else if (strcasecmp(member, "RssiEnabled") == 0) {
@@ -628,9 +585,25 @@ void _bt_hal_handle_adapter_event(GVariant *msg, const char *member)
 
                g_free(address);
        } else if (strcasecmp(member, BT_HAL_HARDWARE_ERROR) == 0) {
+#ifndef TIZEN_BT_HAL
                DBG("BT Hardware Error: Unhandled");
+#else
+               struct hal_ev_controller_error_recieved info;
+
+               INFO("### BT Hardware Error");
+               info.code = HAL_CONTROLLER_ERROR_HW_ERROR;
+               event_cb(HAL_EV_CONTROLLER_ERROR_RECIEVED, &info, sizeof(info));
+#endif
        } else if (strcasecmp(member, BT_HAL_TX_TIMEOUT_ERROR) == 0) {
-               DBG("BT TX Timeout Error: Unhandled");
+#ifndef TIZEN_BT_HAL
+               DBG("BT Hardware Error: Unhandled");
+#else
+               struct hal_ev_controller_error_recieved info;
+
+               INFO("### BT TX Timeout Error");
+               info.code = HAL_CONTROLLER_ERROR_TX_TIMEOUT;
+               event_cb(HAL_EV_CONTROLLER_ERROR_RECIEVED, &info, sizeof(info));
+#endif
        } else if (strcasecmp(member, BT_HAL_DBFW_PLUS_INFO) == 0) {
 #ifdef TIZEN_BT_HAL
                DBG("### DBFW+ info received from BLUEZ");
@@ -661,8 +634,6 @@ void _bt_hal_handle_adapter_event(GVariant *msg, const char *member)
                }
 #endif
        }
-
-       DBG("-");
 }
 
 static gboolean __bt_hal_parse_device_properties(GVariant *item)
@@ -675,7 +646,6 @@ static gboolean __bt_hal_parse_device_properties(GVariant *item)
 
        if (!item)
                return FALSE;
-       DBG("+");
 
        /* Buffer and propety count management */
        uint8_t buf[BT_HAL_MAX_PROPERTY_BUF_SIZE];
@@ -797,10 +767,9 @@ static gboolean __bt_hal_parse_device_properties(GVariant *item)
                } else if (strcasecmp(key, "LegacyManufacturerData") == 0) {
                        /* TODO: To be handled later*/
                } else {
-                       ERR("Unhandled Property:[%s]", key);
+                       DBG("Unhandled Property:[%s]", key);
                }
        }
-       DBG("-");
 
        if (size > 1 && is_bredr_dev) {
                DBG("Send Device found event to HAL user, Num Prop [%d] total size [%zd]", ev->num_props, size);
@@ -914,8 +883,6 @@ static void __bt_hal_handle_device_event(GVariant *value, GVariant *parameters)
                g_variant_unref(value);
                return;
        }
-
-       DBG("-");
 }
 
 static void __bt_hal_send_hid_connection_state_event(
@@ -980,8 +947,6 @@ static void __bt_hal_handle_input_event(GVariant *msg, const char *path)
                g_variant_unref(val);
                g_variant_unref(child);
        }
-
-       DBG("-");
 }
 
 static gboolean __bt_hal_parse_interface(GVariant *msg)
@@ -1087,8 +1052,10 @@ static gboolean __bt_hal_event_manager(gpointer data)
                } else {
                        bt_event = __bt_hal_parse_event(value);
                        if (bt_event == BT_HAL_DEVICE_EVENT) {
+                               DBG("InterfacesAdded %s ", obj_path);
                                __bt_hal_handle_device_event(value, param->parameters);
                        } else if (bt_event == BT_HAL_AVRCP_CONTROL_EVENT) {
+                               DBG("InterfacesAdded %s ", obj_path);
                                _bt_hal_set_control_device_path(obj_path);
                        }
                }
@@ -1101,7 +1068,7 @@ static gboolean __bt_hal_event_manager(gpointer data)
                /*TODO: Handle Interfaces Removed Signal from stack */
 
                g_variant_get(param->parameters, "(&oas)", &obj_path, &iter);
-
+               DBG("InterfacesRemoved %s ", obj_path);
                while (g_variant_iter_loop(iter, "s", &str)) {
                        if (g_strcmp0(str, BT_HAL_PLAYER_CONTROL_INTERFACE) == 0)
                                _bt_hal_remove_control_device_path(obj_path);
@@ -1152,13 +1119,16 @@ static gboolean __bt_hal_event_manager(gpointer data)
        } else if (g_strcmp0(param->interface_name, BT_HAL_PROPERTIES_INTERFACE) == 0) {
                __bt_hal_handle_property_changed_event(param->parameters, param->object_path);
        } else if (g_strcmp0(param->interface_name, BT_HAL_ADAPTER_INTERFACE) == 0) {
+               DBG("Manager Event: Interface Name: BT_HAL_ADAPTER_INTERFACE");
                _bt_hal_handle_adapter_event(param->parameters, param->signal_name);
        } else if (g_strcmp0(param->interface_name, BT_HAL_INPUT_INTERFACE) == 0) {
+               DBG("Manager Event: Interface Name: BT_HAL_INPUT_INTERFACE");
                __bt_hal_handle_input_event(param->parameters, param->object_path);
        } else if (g_strcmp0(param->interface_name, BT_HAL_NETWORK_SERVER_INTERFACE) == 0) {
                /* TODO: Handle Network Server events from stack */
                DBG("Manager Event: Interface Name: BT_HAL_NETWORK_SERVER_INTERFACE");
        } else if (g_strcmp0(param->interface_name, BT_HAL_HEADSET_INTERFACE) == 0) {
+               DBG("Manager Event: Interface Name: BT_HAL_HEADSET_INTERFACE");
                __bt_hal_handle_headset_events(param->parameters, param->signal_name, param->object_path);
        } else if (g_strcmp0(param->interface_name, BT_HAL_SINK_INTERFACE) == 0) {
                /* TODO: Handle Sink interface events from stack */
@@ -1167,12 +1137,16 @@ static gboolean __bt_hal_event_manager(gpointer data)
                /* TODO: Handle Agent events from stack */
                DBG("Manager Event: Interface Name:BT_HAL_AGENT_INTERFACE");
        } else if (g_strcmp0(param->interface_name, BT_HAL_DEVICE_INTERFACE) == 0) {
+               DBG("Manager Event: Interface Name:BT_HAL_DEVICE_INTERFACE");
                __bt_hal_handle_device_specific_events(param->parameters, param->signal_name, param->object_path);
        } else if (g_strcmp0(param->interface_name, BT_HAL_PLAYER_CONTROL_INTERFACE) == 0) {
+               DBG("Manager Event: Interface Name: BT_HAL_PLAYER_CONTROL_INTERFACE");
                __bt_hal_handle_avrcp_ctrl_events(param->parameters, param->signal_name, param->object_path);
        } else if (g_strcmp0(param->interface_name, BT_HAL_MEDIATRANSPORT_INTERFACE) == 0) {
+               DBG("Manager Event: Interface Name: BT_HAL_MEDIATRANSPORT_INTERFACE");
                __bt_hal_handle_avrcp_transport_events(param->parameters, param->signal_name, param->object_path);
        } else if (g_strcmp0(param->interface_name, BT_HAL_GATT_CHAR_INTERFACE) == 0) {
+               DBG("Manager Event: Interface Name: BT_HAL_GATT_CHAR_INTERFACE");
                __bt_hal_handle_gatt_char_event(param->parameters, param->signal_name);
        } else if (g_strcmp0(param->interface_name, BT_HAL_GATT_SERVICE_INTERFACE) == 0) {
                DBG("Manager Event: Interface Name: BT_HAL_GATT_SERVICE_INTERFACE");
@@ -1296,8 +1270,6 @@ static int __bt_hal_register_manager_subscribe_signal(GDBusConnection *conn,
        static int subs_property_id = -1;
        static int subs_adapter_id = -1;
 
-       INFO_C("+");
-
        if (subscribe) {
                if (subs_interface_added_id == -1) {
                        subs_interface_added_id = g_dbus_connection_signal_subscribe(conn,
@@ -1361,7 +1333,6 @@ static int __bt_hal_register_manager_subscribe_signal(GDBusConnection *conn,
                }
        }
 
-       INFO_C("-");
        return 0;
 }
 
@@ -1370,7 +1341,6 @@ static int __bt_hal_register_device_subscribe_signal(GDBusConnection *conn,
 {
        static int subs_device_id = -1;
 
-       DBG("+");
        if (conn == NULL)
                return -1;
 
@@ -1390,7 +1360,6 @@ static int __bt_hal_register_device_subscribe_signal(GDBusConnection *conn,
                }
        }
 
-       DBG("-");
        return 0;
 }
 
@@ -1398,8 +1367,6 @@ static int __bt_hal_register_input_subscribe_signal(GDBusConnection *conn, int s
 {
        static int subs_input_id = -1;
 
-       DBG("+");
-
        if (conn == NULL)
                return -1;
 
@@ -1419,8 +1386,6 @@ static int __bt_hal_register_input_subscribe_signal(GDBusConnection *conn, int s
                }
        }
 
-       DBG("-");
-
        return 0;
 }
 
@@ -1465,8 +1430,6 @@ static int __bt_hal_register_gatt_subscribe_signal(GDBusConnection *conn,
 
 static int __bt_hal_register_service_event(GDBusConnection *g_conn, int event_type)
 {
-       DBG("+");
-
        if (g_conn == NULL)
                return  BT_HAL_ERROR_INTERNAL;
 
@@ -1572,8 +1535,6 @@ fail:
                manager_conn = NULL;
        }
 
-       DBG("-");
-
        return BT_HAL_ERROR_INTERNAL;
 }
 
@@ -1594,11 +1555,7 @@ int _bt_hal_initialize_event_receiver(handle_stack_msg cb)
 
        /*TODO: Initialize Obexd Event receiver */
 
-       /* Initialize event receiver for flight mode  */
-       _bt_hal_register_vconf_handler();
-
        event_cb = cb;
-       DBG("-");
 
        return BT_HAL_ERROR_NONE;
 }
@@ -1609,24 +1566,22 @@ static void __bt_hal_device_property_changed_event(GVariant *msg, const char *pa
        GVariant *value = NULL;
        char *key = NULL;
        g_variant_iter_init(&value_iter, msg);
-       DBG("+");
 
        while (g_variant_iter_loop(&value_iter, "{sv}", &key, &value)) {
                if (!g_strcmp0(key, "Connected")) {
                        guint connected = 0;
                        g_variant_get(value, "i", &connected);
-                       DBG("Device property changed : Connected [%d]", connected);
+                       INFO("Device property changed : Connected [%d]", connected);
                } else if (!g_strcmp0(key, "RSSI")) {
                        DBG("Device property changed : RSSI");
                        __bt_hal_dbus_device_found_properties(path);
                } else if (!g_strcmp0(key, "GattConnected")) {
-                       DBG("Device property changed : GattConnected");
                        gboolean gatt_connected = FALSE;
                        g_variant_get(value, "b", &gatt_connected);
+                       INFO_C("Device property changed : GattConnected [%d]", gatt_connected);
+
                        char *address = g_malloc0(BT_HAL_ADDRESS_STRING_SIZE);
                        _bt_hal_convert_device_path_to_address(path, address);
-                       DBG("@@gatt_connected: %d", gatt_connected);
-                       DBG("@@address: %s", address);
                        _bt_hal_gatt_connected_state_event(gatt_connected, address);
                        _bt_hal_handle_gattc_connected_event(address, gatt_connected);
                        g_free(address);
@@ -1648,10 +1603,8 @@ static void __bt_hal_device_property_changed_event(GVariant *msg, const char *pa
 
                        if (!event_cb) {
                                ERR("Bluetooth HAL event handler not registered");
-                       } else {
-                               DBG("Sending HAL_EV_BOND_STATE_CHANGED event");
+                       } else
                                event_cb(HAL_EV_BOND_STATE_CHANGED, (void*)&ev, sizeof(ev));
-                       }
                } else if (!g_strcmp0(key, "LegacyPaired")) {
                        DBG("Device property changed : LegacyPaired");
                } else if (!g_strcmp0(key, "Trusted")) {
@@ -1679,10 +1632,9 @@ static void __bt_hal_device_property_changed_event(GVariant *msg, const char *pa
                        DBG("Address: %s, TrustedProfiles: 0x%X", address, trust_val);
                        __bt_hal_send_device_trusted_profile_changed_event(trust_val, address);
                } else {
-                       ERR("Unhandled Property:[%s]", key);
+                       DBG("Unhandled Property:[%s]", key);
                }
        }
-       DBG("-");
 }
 
 static void __bt_hal_dbus_device_found_properties(const char *device_path)
@@ -1692,7 +1644,6 @@ static void __bt_hal_dbus_device_found_properties(const char *device_path)
        GDBusProxy *device_proxy;
        GDBusConnection *conn;
        GVariant *result;
-       DBG("+");
 
        if (!device_path) {
                ERR("Invalid device path");
@@ -1741,8 +1692,6 @@ static void __bt_hal_dbus_device_found_properties(const char *device_path)
 
        g_object_unref(device_proxy);
        g_free(address);
-
-       DBG("-");
 }
 
 static void __bt_hal_device_properties_lookup(GVariant *result, char *address)
@@ -1896,7 +1845,7 @@ static void __bt_hal_device_properties_lookup(GVariant *result, char *address)
                                        (BT_HAL_STACK_UUID_SIZE * uuid_count),
                                        uuids);
                        ev->num_props = num_props_tmp + 1;
-                       g_free(uuid_value);
+                       g_strfreev(uuid_value);
                }
                g_variant_unref(tmp_value);
 
@@ -1945,12 +1894,10 @@ static void __bt_hal_device_properties_lookup(GVariant *result, char *address)
                DBG("Send Device found event to HAL user, Num Prop [%d] total size [%zd]", ev->num_props, size);
                event_cb(HAL_EV_DEVICE_FOUND, (void*) buf, size);
        }
-       DBG("-");
 }
 
 static void __bt_hal_send_device_acl_connection_state_event(int status, gboolean connected, const char *address)
 {
-       DBG("+");
        struct hal_ev_acl_state_changed ev;
 
        ev.status = status;
@@ -1964,12 +1911,10 @@ static void __bt_hal_send_device_acl_connection_state_event(int status, gboolean
                ERR("Bluetooth HAL event handler not registered");
        else
                event_cb(HAL_EV_ACL_STATE_CHANGED, &ev, sizeof(ev));
-       DBG("-");
 }
 
 static void __bt_hal_send_device_le_connection_state_event(int status, gboolean connected, const char *address)
 {
-       DBG("+");
        struct hal_ev_le_conn_state_changed ev;
 
        ev.status = status;
@@ -1983,14 +1928,12 @@ static void __bt_hal_send_device_le_connection_state_event(int status, gboolean
                ERR("Bluetooth HAL event handler not registered");
        else
                event_cb(HAL_EV_LE_CONN_STATE_CHANGED, &ev, sizeof(ev));
-       DBG("-");
 }
 
 static void __bt_hal_send_device_trust_state_event(gboolean is_trusted,
                                const char *address)
 {
        struct hal_ev_device_trust_state_changed ev;
-       DBG("+");
 
        ev.trust = (is_trusted == TRUE) ?
                HAL_DEVICE_TRUSTED :
@@ -2002,14 +1945,12 @@ static void __bt_hal_send_device_trust_state_event(gboolean is_trusted,
                ERR("Bluetooth HAL event handler not registered");
        else
                event_cb(HAL_EV_DEVICE_TRUST_CHANGED, &ev, sizeof(ev));
-       DBG("-");
 }
 
 static void __bt_hal_send_device_trusted_profile_changed_event(
                uint32_t trust_val, const char *address)
 {
        struct hal_ev_device_trusted_profiles_changed ev;
-       DBG("+");
 
        _bt_hal_convert_addr_string_to_type(ev.bdaddr, address);
        ev.trust_val = trust_val;
@@ -2018,7 +1959,6 @@ static void __bt_hal_send_device_trusted_profile_changed_event(
                ERR("Bluetooth HAL event handler not registered");
        else
                event_cb(HAL_EV_DEVICE_TRUSTED_PROFILES_CHANGED, &ev, sizeof(ev));
-       DBG("-");
 }
 
 static void __bt_hal_handle_device_specific_events(GVariant *msg, const char *member,
@@ -2098,9 +2038,9 @@ static void __bt_hal_handle_device_specific_events(GVariant *msg, const char *me
                        disc_reason, _bt_hal_convert_disc_reason_to_string(disc_reason), address, name);
 
                if (!addr_type)
-                       __bt_hal_send_device_acl_connection_state_event(_bt_hal_convert_disc_reason_to_status(disc_reason), FALSE, address);
+                       __bt_hal_send_device_acl_connection_state_event(disc_reason, FALSE, address);
                else
-                       __bt_hal_send_device_le_connection_state_event(_bt_hal_convert_disc_reason_to_status(disc_reason), FALSE, address);
+                       __bt_hal_send_device_le_connection_state_event(disc_reason, FALSE, address);
                g_free(address);
        } else if (strcasecmp(member, "ProfileStateChanged") == 0) {
                int state = 0;
@@ -2110,7 +2050,6 @@ static void __bt_hal_handle_device_specific_events(GVariant *msg, const char *me
                address = g_malloc0(BT_HAL_ADDRESS_STRING_SIZE);
                _bt_hal_convert_device_path_to_address(path, address);
 
-               DBG("[%s] %s, state %d", address, profile_uuid, state);
                if (strncmp(profile_uuid, HID_UUID, strlen(HID_UUID)) == 0) {
                        DBG("HID Host Profile state: %d", state);
                        if (state == BT_HAL_PROFILE_STATE_CONNECTED)
@@ -2194,7 +2133,7 @@ static void __bt_hal_handle_device_specific_events(GVariant *msg, const char *me
                                DBG("AVRCP Controller Profile state changed: BT_HAL_PROFILE_STATE_CONNECTING");
                        }
                } else {
-                       DBG("Profile[%s] State changed status [%d] ", profile_uuid, state);
+                       DBG("Profile [%s] State changed [%d] [%s] ", profile_uuid, state, address);
                }
                g_free(address);
                g_free(profile_uuid);
@@ -2204,8 +2143,6 @@ static void __bt_hal_handle_device_specific_events(GVariant *msg, const char *me
 
                address = g_malloc0(BT_HAL_ADDRESS_STRING_SIZE);
 
-               DBG("Member: [%s]", member);
-
                _bt_hal_convert_device_path_to_address(path, address);
                g_variant_get(msg, "(q)", &mtu);
 
@@ -2277,12 +2214,9 @@ static void __bt_hal_handle_gatts_mtu_changed_event(char *address, int mtu)
        memset(buf, 0, sizeof(buf));
        size = sizeof(*ev);
 
-       DBG("Address: %s, mtu: %d", address, mtu);
-
        ev->conn_id = _bt_get_remote_gatt_client_conn_id(address);
        ev->mtu = mtu;
 
-       DBG("Send GATT server mtu changed event to HAL, size: [%zd]", size);
        gatt_event_cb(HAL_EV_GATT_SERVER_MTU_CHANGED, buf, size);
 }
 
@@ -2412,7 +2346,6 @@ static void __bt_avrcp_control_parse_properties(struct hal_ev_track_changed *ev,
        }
 
        ev->num_attr = i;
-       g_variant_iter_free(&iter);
        return;
 }
 
@@ -2546,9 +2479,6 @@ static void __bt_hal_handle_avrcp_ctrl_events(GVariant *msg, const char *member,
                        DBG("Property not handled");
                }
        }
-
-       g_free((char *)property);
-       g_variant_unref(value);
 }
 
 static void __bt_hal_handle_avrcp_transport_events(GVariant *msg, const char *member,
@@ -2589,20 +2519,28 @@ static void __bt_hal_handle_avrcp_transport_events(GVariant *msg, const char *me
 
                        /* Send event to application */
                        avrcp_tg_event_cb(HAL_EV_AVRCP_TG_DELAY_CHANGE, &ev, sizeof(ev));
+               } else if ((strcasecmp(property, "Volume") == 0)) {
+                       struct hal_ev_avrcp_tg_volume_changed ev;
+                       uint16_t val;
+
+                       memset(&ev, 0, sizeof(ev));
+                       _bt_hal_convert_addr_string_to_type(ev.bdaddr, address);
+
+                       val = g_variant_get_uint16(value);
+                       DBG("Value : %d", val);
+                       ev.volume = val;
+
+                       /* Send event to application */
+                       avrcp_tg_event_cb(HAL_EV_AVRCP_TG_VOLUME_CHANGE, &ev, sizeof(ev));
                } else {
                        DBG("Property not handled");
                }
        }
-
-       DBG("-");
-       g_free((char *)property);
-       g_variant_unref(value);
 }
 
 /* A2DP Src Role(Remote:Sink) Events */
 static void __bt_hal_send_av_connection_state_event(gboolean connected, const char *address)
 {
-       DBG("+");
        struct hal_ev_a2dp_conn_state ev;
 
        if (connected == TRUE)
@@ -2625,7 +2563,6 @@ static void __bt_hal_send_av_connection_state_event(gboolean connected, const ch
 /* A2DP Sink Role(Remote:Source) Events */
 static void __bt_hal_send_a2dp_sink_connection_state_event(gboolean connected, const char *address)
 {
-       DBG("+");
        struct hal_ev_a2dp_conn_state ev;
 
        if (connected == TRUE)
@@ -2649,7 +2586,6 @@ static void __bt_hal_send_a2dp_sink_connection_state_event(gboolean connected, c
 static void __bt_hal_send_hf_audio_connection_state_event(gboolean connected,
                                                const char *address)
 {
-       DBG("+");
        struct hal_ev_handsfree_audio_state ev;
 
        if (connected == TRUE)
@@ -2673,7 +2609,6 @@ static void __bt_hal_send_hf_audio_connection_state_event(gboolean connected,
 static void __bt_hal_send_hf_connection_state_event(gboolean connected,
                                                const char *address)
 {
-       DBG("+");
        struct hal_ev_handsfree_conn_state ev;
 
        if (connected == TRUE)