Merge "Fix alloc free mismatch coverty issue in bt-otp" into tizen
authorPyun DoHyun <dh79.pyun@samsung.com>
Mon, 17 Feb 2020 01:01:29 +0000 (01:01 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Mon, 17 Feb 2020 01:01:29 +0000 (01:01 +0000)
37 files changed:
bt-api/bt-audio.c
bt-api/bt-device.c
bt-api/bt-event-handler.c
bt-api/bt-gatt-client.c
bt-core/bt-core-adapter.c
bt-oal/bluez_hal/src/bt-hal-adapter-dbus-handler.c
bt-oal/bluez_hal/src/bt-hal-agent.c
bt-oal/bluez_hal/src/bt-hal-bluetooth.c
bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.c
bt-oal/bluez_hal/src/bt-hal-device-dbus-handler.c
bt-oal/bluez_hal/src/bt-hal-device-dbus-handler.h
bt-oal/bluez_hal/src/bt-hal-event-receiver.c
bt-oal/bluez_hal/src/bt-hal-gatt-client.c
bt-oal/bluez_hal/src/bt-hal-gatt-client.h
bt-oal/bluez_hal/src/bt-hal-gatt-server.c
bt-oal/bluez_hal/src/bt-hal-gatt-server.h
bt-oal/bluez_hal/src/bt-hal-gatt.c
bt-oal/bluez_hal/src/bt-hal-hdp-dbus-handler.c
bt-oal/hardware/bluetooth.h
bt-oal/include/oal-device-mgr.h
bt-oal/oal-device-mgr.c
bt-otp/bt-otpserver.c
bt-service-adaptation/services/adapter/bt-service-core-adapter-le.c
bt-service-adaptation/services/bt-request-handler.c
bt-service-adaptation/services/bt-service-common.c
bt-service-adaptation/services/bt-service-event-receiver.c
bt-service-adaptation/services/bt-service-event-sender.c
bt-service-adaptation/services/device/bt-service-core-device.c
bt-service-adaptation/services/gatt/bt-service-gatt.c
bt-service-adaptation/services/include/bt-service-core-device.h
bt-service-adaptation/services/ipsp/bt-service-ipsp-event-receiver.c
bt-service-adaptation/services/obex/bt-service-obex-event-receiver.c
bt-service-adaptation/services/obex/bt-service-obex-server.c
bt-service/bt-service-adapter.c
bt-service/bt-service-common.c
bt-service/bt-service-device.c
bt-service/bt-service-event-receiver.c

index 1b12414..46c29fc 100644 (file)
@@ -565,6 +565,8 @@ static int __bt_hf_agent_read_call_list(GVariant *reply,
                (*call_list)->list = g_list_append((*call_list)->list,
                                                        (gpointer)call_info);
        }
+
+       g_variant_unref(var_temp);
        BT_DBG("-");
        return BLUETOOTH_ERROR_NONE;
 }
index ebbb4c6..8b80037 100644 (file)
@@ -430,7 +430,7 @@ BT_EXPORT_API int bluetooth_disconnect_le(const bluetooth_device_address_t *devi
 
        g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
 #ifdef TIZEN_GATT_CLIENT
-       BT_INFO("Send GATT disconnect using Client Interface [%d]", client_id);
+       BT_DBG("Send GATT disconnect using Client Interface [%d]", client_id);
        g_array_append_vals(in_param2, &client_id, sizeof(int));
 #endif
        user_info = _bt_get_user_data(BT_COMMON);
index 91108b4..ea3d35e 100644 (file)
@@ -2247,6 +2247,7 @@ void __bt_map_client_event_filter(GDBusConnection *connection,
                }
                g_free(folders_struct.names);
 
+               g_variant_iter_free(iter);
                g_variant_unref(folder_list_var);
 
        } else if (strcasecmp(signal_name, BT_MAP_FILTER_FIELDS_COMPLETE) == 0) {
@@ -2275,6 +2276,7 @@ void __bt_map_client_event_filter(GDBusConnection *connection,
                                fields_info.fields[i] = strdup(field);
                                i++;
                        }
+                       g_variant_iter_free(iter);
                }
 
                _bt_common_event_cb(BLUETOOTH_EVENT_MAP_LIST_FILTER_FIELD_COMPLETE,
@@ -2405,9 +2407,12 @@ void __bt_map_client_event_filter(GDBusConnection *connection,
                                        messages_struct.message_items[i].is_protected = value_bool ? 1 : 0;
                                        BT_DBG("  Protected: %s", value_bool ? "true" : "false");
                                }
+
+                               g_free(value_string);
                        }
                        ++i;
                }
+               g_variant_iter_free(iter);
 
                _bt_common_event_cb(BLUETOOTH_EVENT_MAP_LIST_MESSAGES_COMPLETE,
                                result, &messages_struct,
index ca6709d..140cd3a 100644 (file)
@@ -50,8 +50,6 @@ static GSList *service_monitor_list = NULL;
 
 BT_EXPORT_API int bluetooth_gatt_free_service_property(bt_gatt_service_property_t *svc_pty)
 {
-       BT_DBG("+");
-
        BT_CHECK_PARAMETER(svc_pty, return);
 
 #ifdef TIZEN_GATT_CLIENT
@@ -65,14 +63,11 @@ BT_EXPORT_API int bluetooth_gatt_free_service_property(bt_gatt_service_property_
 
        memset(svc_pty, 0, sizeof(bt_gatt_service_property_t));
 
-       BT_DBG("-");
        return BLUETOOTH_ERROR_NONE;
 }
 
 BT_EXPORT_API int bluetooth_gatt_free_char_property(bt_gatt_char_property_t *char_pty)
 {
-       BT_DBG("+");
-
        BT_CHECK_PARAMETER(char_pty, return);
 
        g_free(char_pty->uuid);
@@ -86,14 +81,11 @@ BT_EXPORT_API int bluetooth_gatt_free_char_property(bt_gatt_char_property_t *cha
 
        memset(char_pty, 0, sizeof(bt_gatt_char_property_t));
 
-       BT_DBG("-");
        return BLUETOOTH_ERROR_NONE;
 }
 
 BT_EXPORT_API int bluetooth_gatt_free_desc_property(bt_gatt_char_descriptor_property_t *desc_pty)
 {
-       BT_DBG("+");
-
        BT_CHECK_PARAMETER(desc_pty, return);
 
        g_free(desc_pty->uuid);
@@ -104,7 +96,6 @@ BT_EXPORT_API int bluetooth_gatt_free_desc_property(bt_gatt_char_descriptor_prop
 
        memset(desc_pty, 0, sizeof(bt_gatt_char_descriptor_property_t));
 
-       BT_DBG("-");
        return BLUETOOTH_ERROR_NONE;
 }
 
@@ -439,6 +430,13 @@ BT_EXPORT_API int bluetooth_gatt_get_service_from_uuid(bluetooth_device_address_
                                                g_strstr_len(service->uuid, -1,
                                                                service_uuid)) {
                                        ret = BLUETOOTH_ERROR_NONE;
+
+                                       /* release resources */
+                                       g_free(object_path);
+                                       g_variant_iter_free(interface_iter);
+                                       g_free(interface_str);
+                                       g_variant_iter_free(svc_iter);
+
                                        goto done;
                                }
                        }
@@ -515,6 +513,7 @@ static void __bluetooth_internal_get_char_cb(GDBusProxy *proxy,
        g_variant_iter_free(char_iter);
        g_variant_unref(value);
        g_object_unref(proxy);
+       g_variant_unref(char_value);
 }
 
 BT_EXPORT_API int bluetooth_gatt_discover_service_characteristics(
@@ -1476,10 +1475,11 @@ static void bluetooth_gatt_get_char_desc_cb(GDBusProxy *proxy,
 
        g_variant_iter_free(char_iter);
        g_variant_unref(value);
+       g_variant_unref(char_value);
        BT_DBG("-");
 }
 
-BT_EXPORT_API int bluetooth_gatt_discover_characteristic_descriptor(
+BT_EXPORT_API int bltooth_gatt_discover_characteristic_descriptor(
                        const char *characteristic_handle)
 {
        GDBusProxy *properties_proxy = NULL;
@@ -2357,7 +2357,7 @@ BT_EXPORT_API int bluetooth_gatt_client_watch_characteristics(
                        int fd = -1;
 
                        fd_list_array = g_unix_fd_list_steal_fds(out_fd_list, &len);
-                       BT_INFO("Num fds in fd_list is : %d, fd_list[0]: %d", len, fd_list_array[0]);
+                       BT_DBG("Num fds in fd_list is : %d, fd_list[0]: %d", len, fd_list_array[0]);
                        fd = fd_list_array[0];
                        mtu =  g_array_index(out_param, int, 0);
 
index 27fdeaf..47bd80b 100644 (file)
@@ -795,13 +795,18 @@ gboolean _bt_core_set_transfer_value(gboolean value)
 
 gboolean _bt_core_factory_test_mode(const char *type, const char *arg)
 {
+       int ret;
        BT_DBG("Test item : %s", type);
 
 #ifdef TIZEN_FEATURE_ACTD
        if (g_strcmp0(type, "Enable_RF_Test") == 0) {
-               __bt_call_systemact_service(BT_SYSTEMACT_EDUTM_ON);
+               ret = __bt_call_systemact_service(BT_SYSTEMACT_EDUTM_ON);
+               if (ret < 0)
+                       BT_ERR("Failed to call systemact service");
        } else if (g_strcmp0(type, "Disable_RF_Test") == 0) {
-               __bt_call_systemact_service(BT_SYSTEMACT_EDUTM_OFF);
+               ret = __bt_call_systemact_service(BT_SYSTEMACT_EDUTM_OFF);
+               if (ret < 0)
+                       BT_ERR("Failed to call systemact service");
        } else {
                BT_DBG("Terminate bt-core process");
                g_timeout_add(BT_CORE_IDLE_TERM_TIME, __bt_core_idle_terminate, NULL);
index 1bed8e3..3f594c6 100644 (file)
@@ -744,6 +744,7 @@ static gboolean __bt_adapter_all_properties_cb(gpointer user_data)
        }
 done:
        g_variant_unref(result);
+       g_variant_iter_free(property_iter);
        return FALSE;
 }
 
index 09f395e..bc72fdf 100644 (file)
@@ -364,6 +364,8 @@ void __bt_hal_get_auth_info(GVariant *reply, char *auth_info)
                                g_variant_get(tmp_value, "ay", &value_iter);
                                while (g_variant_iter_loop(value_iter, "y", &m_value))
                                        manufacturer_data[i++] = m_value;
+
+                               g_variant_iter_free(value_iter);
                        }
                        g_variant_unref(tmp_value);
                } else {
index 1cba249..3e8752e 100644 (file)
@@ -383,6 +383,12 @@ static int get_trusted_profile(bt_bdaddr_t *bd_addr, bt_trusted_profile_t profil
        return _bt_hal_device_get_trusted_profile(bd_addr, profile, trusted);
 }
 
+static int get_device_ida(bt_bdaddr_t *bd_addr, bt_bdaddr_t *id_addr)
+{
+       DBG("");
+       return _bt_hal_device_get_ida(bd_addr, id_addr);
+}
+
 static int get_connected_link_rssi_strength(bt_bdaddr_t *bd_addr, uint32_t conn_link_type)
 {
        DBG("");
@@ -481,6 +487,7 @@ static const bt_interface_t bluetooth_if = {
        .unregister_agent_osp_server = unregister_agent_osp_server,
        .set_trusted_profile = set_trusted_profile,
        .get_trusted_profile = get_trusted_profile,
+       .get_device_ida = get_device_ida,
        .enable_rssi_monitoring = enable_rssi_monitoring,
        .get_connected_link_rssi_strength = get_connected_link_rssi_strength,
        .enable_gap_auth_notifications = enable_gap_auth_notifications,
@@ -762,12 +769,10 @@ static void __bt_hal_handle_device_le_conn_state_changed_event(void *buf, uint16
        bt_bdaddr_t bd_addr;
 
        memcpy(bd_addr.address, ev->bdaddr, 6);
-       /* BD address */
-       DBG("Address: [%02X:%02X:%02X:%02X:%02X:%02X]", bd_addr.address[0],
-                       bd_addr.address[1], bd_addr.address[2], bd_addr.address[3],
-                       bd_addr.address[4], bd_addr.address[5]);
-       DBG("LE conn Status [0x%x]", ev->status);
-       DBG("LE conn State  [0x%x]", ev->state);
+
+       DBG("LE conn Status [0x%x] State [0x%x] [%02X:%02X:%02X:%02X:%02X:%02X]", ev->status, ev->state,
+                       bd_addr.address[0], bd_addr.address[1], bd_addr.address[2],
+                       bd_addr.address[3], bd_addr.address[4], bd_addr.address[5]);
 
 #ifdef TIZEN_BT_HAL
        if (!bt_hal_cbacks->le_conn_state_changed_cb) {
index 71dee23..730fde4 100644 (file)
@@ -273,17 +273,23 @@ static char *__bt_hal_extract_control_device_path(GVariantIter *iter, char *addr
 {
        char *object_path = NULL;
        char *interface_str = NULL;
+       GVariantIter *interface_iter;
        char device_address[BT_HAL_ADDRESS_STRING_SIZE] = { 0 };
 
        /* Parse the signature: oa{sa{sv}}} */
-       while (g_variant_iter_loop(iter, "{&oa{sa{sv}}}", &object_path, &interface_str)) {
+       while (g_variant_iter_loop(iter, "{&oa{sa{sv}}}", &object_path, &interface_iter)) {
                if (object_path == NULL)
-                       return  NULL;
+                       continue;
 
-               if (g_strcmp0(interface_str, BT_HAL_PLAYER_CONTROL_INTERFACE) == 0) {
-                       _bt_hal_convert_device_path_to_address(object_path, device_address);
-                       if (g_strcmp0(address, device_address) == 0)
-                               return g_strdup(object_path);
+               while(g_variant_iter_loop(interface_iter, "{&sa{sv}}", &interface_str, NULL)) {
+                       if (g_strcmp0(interface_str, BT_HAL_PLAYER_CONTROL_INTERFACE) == 0) {
+                               _bt_hal_convert_device_path_to_address(object_path, device_address);
+                               if (g_strcmp0(address, device_address) == 0) {
+                                       DBG("Object Path: %s", object_path);
+                                       g_variant_iter_free(interface_iter);
+                                       return g_strdup(object_path);
+                               }
+                       }
                }
        }
        return NULL;
@@ -293,17 +299,23 @@ static char *__bt_hal_extract_transport_device_path(GVariantIter *iter, char *ad
 {
        char *object_path = NULL;
        char *interface_str = NULL;
+       GVariantIter *interface_iter;
        char device_address[BT_HAL_ADDRESS_STRING_SIZE] = { 0 };
 
        /* Parse the signature: oa{sa{sv}}} */
-       while (g_variant_iter_loop(iter, "{&oa{sa{sv}}}", &object_path, &interface_str)) {
+       while (g_variant_iter_loop(iter, "{&oa{sa{sv}}}", &object_path, &interface_iter)) {
                if (object_path == NULL)
-                       return  NULL;
+                       continue;
 
-               if (g_strcmp0(interface_str, BT_HAL_MEDIATRANSPORT_INTERFACE) == 0) {
-                       _bt_hal_convert_device_path_to_address(object_path, device_address);
-                       if (g_strcmp0(address, device_address) == 0)
-                               return g_strdup(object_path);
+               while(g_variant_iter_loop(interface_iter, "{&sa{sv}}", &interface_str, NULL)) {
+                       if (g_strcmp0(interface_str, BT_HAL_MEDIATRANSPORT_INTERFACE) == 0) {
+                               _bt_hal_convert_device_path_to_address(object_path, device_address);
+                               if (g_strcmp0(address, device_address) == 0) {
+                                       DBG("Object Path: %s", object_path);
+                                       g_variant_iter_free(interface_iter);
+                                       return g_strdup(object_path);
+                               }
+                       }
                }
        }
        return NULL;
@@ -1967,7 +1979,7 @@ gboolean _bt_hal_is_service_enabled(const char *uuid)
                return FALSE;
        }
 
-       while (g_variant_iter_loop(iter, "s", &uuid_str)) {
+       while (g_variant_iter_loop(iter, "&s", &uuid_str)) {
                DBG("UUID string [%s]\n", uuid_str);
                if (!strncasecmp(uuid, uuid_str, strlen(uuid))) {
                        ret = TRUE;
index c705a9e..bff47c4 100644 (file)
@@ -636,6 +636,7 @@ static void __bt_device_parse_services(GVariant *result)
        event_cb(HAL_EV_REMOTE_DEVICE_PROPS, (void*) buf, size);
 
        g_variant_unref(result);
+       g_variant_iter_free(property_iter);
 }
 
 int __bt_hal_dbus_enquire_remote_device_services(char *address)
@@ -937,6 +938,8 @@ static gboolean __bt_device_bonded_device_info_cb(gpointer user_data)
                        while (g_variant_iter_loop(char_value_iter, "y", &char_value))
                                g_byte_array_append(manufacturer_data, &char_value, 1);
 
+                       g_variant_iter_free(char_value_iter);
+
                        if (manufacturer_data) {
                                if (manufacturer_data->len > 0) {
                                        size += __bt_insert_hal_properties(
@@ -981,6 +984,7 @@ static gboolean __bt_device_bonded_device_info_cb(gpointer user_data)
 
 done:
        g_variant_unref(result);
+       g_variant_iter_free(property_iter);
        return FALSE;
 }
 
@@ -1596,6 +1600,75 @@ int _bt_hal_device_get_trusted_profile(const bt_bdaddr_t *bd_addr,
                        trusted_flag, trusted);
 }
 
+int _bt_hal_device_get_ida(bt_bdaddr_t *bd_addr, bt_bdaddr_t *id_addr)
+{
+       char address[BT_HAL_ADDRESS_STRING_SIZE] = { 0 };
+       gchar *device_path = NULL;
+       const gchar *idaddress = NULL;
+       GDBusProxy *device_proxy;
+       GError *error = NULL;
+       GVariant *result = NULL;
+       GDBusConnection *conn;
+       int ret = BT_STATUS_SUCCESS;
+
+       if (bd_addr == NULL)
+               return BT_STATUS_PARM_INVALID;
+
+       conn = _bt_hal_get_system_gconn();
+
+       if (!conn) {
+               ERR("_bt_hal_get_system_gconn failed");
+               return BT_STATUS_FAIL;
+       }
+
+       _bt_hal_convert_addr_type_to_string(address, bd_addr->address);
+
+       DBG("The device_address is: [%s]", address);
+
+       device_path = _bt_hal_get_device_object_path(address);
+
+       if (!device_path) {
+               ERR("_bt_hal_get_device_object_path failed");
+               return BT_STATUS_FAIL;
+       }
+
+       device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                       NULL, BT_HAL_BLUEZ_NAME, device_path,
+                       BT_HAL_DEVICE_INTERFACE,  NULL, NULL);
+       g_free(device_path);
+       if (!device_proxy) {
+               ERR("Unable to get proxy");
+               return BT_STATUS_FAIL;
+       }
+
+       result = g_dbus_proxy_call_sync(device_proxy, "GetIDAddress", NULL,
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+       if (result == NULL) {
+               ERR("Failed to get device ID address");
+
+               ret = BT_STATUS_FAIL;
+               if (error != NULL) {
+                       g_dbus_error_strip_remote_error(error);
+                       ERR("Error occured in Proxy call [%s]", error->message);
+                       if (g_strcmp0(error->message, "Does Not Exist") == 0)
+                               ERR("Device does not exist");
+                       g_error_free(error);
+               }
+               g_object_unref(device_proxy);
+               return ret;
+       }
+
+       g_variant_get(result , "(&s)", &idaddress);
+
+       DBG_SECURE("ID Address : %s", idaddress);
+       _bt_hal_convert_addr_string_to_type(id_addr->address, idaddress);
+
+       g_variant_unref(result);
+       g_object_unref(device_proxy);
+
+       return ret;
+}
+
 int _bt_hal_device_enable_rssi_monitoring(bt_bdaddr_t *bd_addr, uint32_t link_type,
                    int low_threshold, int in_range_threshold, int high_threshold)
 {
index 9cea7bb..9aaf84a 100644 (file)
@@ -75,6 +75,8 @@ int _bt_hal_device_set_trusted_profile(const bt_bdaddr_t *bd_addr,
 int _bt_hal_device_get_trusted_profile(const bt_bdaddr_t *bd_addr,
                bt_trusted_profile_t profile, uint32_t *trusted);
 
+int _bt_hal_device_get_ida(bt_bdaddr_t *bd_addr, bt_bdaddr_t *id_addr);
+
 int _bt_hal_device_enable_rssi_monitoring(bt_bdaddr_t *bd_addr, uint32_t conn_link_type,
                    int low_threshold, int in_range_threshold, int high_threshold);
 
index bf962ff..46a172b 100644 (file)
@@ -445,7 +445,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");
@@ -1556,13 +1556,12 @@ static void __bt_hal_device_property_changed_event(GVariant *msg, const char *pa
                        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("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);
@@ -1584,10 +1583,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")) {
@@ -1899,7 +1896,6 @@ static void __bt_hal_send_device_acl_connection_state_event(int status, gboolean
 
 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;
@@ -1919,7 +1915,6 @@ 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 :
@@ -1937,7 +1932,6 @@ 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;
@@ -2037,7 +2031,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)
@@ -2121,7 +2114,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);
@@ -2131,8 +2124,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);
 
@@ -2204,12 +2195,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);
 }
 
@@ -2472,9 +2460,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,
@@ -2519,9 +2504,6 @@ static void __bt_hal_handle_avrcp_transport_events(GVariant *msg, const char *me
                        DBG("Property not handled");
                }
        }
-
-       g_free((char *)property);
-       g_variant_unref(value);
 }
 
 /* A2DP Src Role(Remote:Sink) Events */
index 91e07f0..81b28d7 100644 (file)
@@ -146,7 +146,12 @@ static guint pending_le_conn_timer_id = 0;
 static int bt_conn_id = 0;
 static int bt_inst_id = 0;
 
-#define BT_GATTC_CL_MAX 32
+/* Should match the range with bt-service-gatt.c's MAX_APPS_SUPPORTED */
+/* TODO: Adjust MAX Client after modifying MAX app handle logic */
+#define BT_GATTC_CL_MAX 11
+
+static int assigned_if = 0;
+static gboolean client_if_used[BT_GATTC_CL_MAX];
 
 typedef struct {
        int conn_id;
@@ -163,8 +168,6 @@ typedef struct {
 
 static GSList * hal_gattc_client_app_list = NULL;
 
-static int bt_client_if = 0;
-
 struct conn_mtu_s {
        int conn_id;
        int mtu;
@@ -185,6 +188,48 @@ static hal_gattc_server_info_t *__bt_find_gatt_conn_info(const bt_bdaddr_t *serv
 static hal_gattc_client_info_t *__bt_find_gatt_client_info(bt_bdaddr_t *serv_addr);
 static hal_gattc_client_info_t *__bt_find_gatt_client_info_from_conn_id(int conn_id);
 
+void _bt_hal_gatt_client_init(void)
+{
+       assigned_if = 0;
+       memset(client_if_used, 0x00, sizeof(client_if_used));
+}
+
+static int __bt_hal_gatt_assign_if(void)
+{
+       int index;
+
+       index = assigned_if + 1;
+
+       if (index >= BT_GATTC_CL_MAX)
+               index = 1;
+
+       while (client_if_used[index] == TRUE) {
+               if (index == assigned_if) {
+                       /* No available ID */
+                       ERR("All interface ID is used");
+                       return -1;
+               }
+
+               index++;
+
+               if (index >= BT_GATTC_CL_MAX)
+                       index = 1;
+       }
+
+       assigned_if = index;
+       client_if_used[index] = TRUE;
+
+       return assigned_if;
+}
+
+static void __bt_hal_gatt_delete_if(int client_if)
+{
+       if (client_if >= BT_GATTC_CL_MAX || client_if < 0)
+               return;
+
+       client_if_used[client_if] = FALSE;
+}
+
 
 /* To send stack event to hal-av handler */
 void _bt_hal_register_gatt_client_handler_cb(handle_stack_msg cb)
@@ -226,14 +271,10 @@ static gboolean __bt_hal_register_client_cb(gpointer user_data)
        return FALSE;
 }
 
-static int __hal_generate_client_id()
-{
-       return ++bt_client_if;
-}
-
 static hal_gatt_client_app *__hal_gattc_add_client_app(bt_uuid_t *app_uuid)
 {
        GSList *l;
+       int client_if = 0;
        hal_gatt_client_app *info = NULL;
        hal_gatt_client_app *gattc_app = NULL;
 
@@ -249,11 +290,17 @@ static hal_gatt_client_app *__hal_gattc_add_client_app(bt_uuid_t *app_uuid)
                }
        }
 
+       client_if = __bt_hal_gatt_assign_if();
+       if (client_if == -1) {
+               ERR("Fail to allocate the client if");
+               return NULL;
+       }
+
        DBG("adding the gatt client app");
 
        //add client app
        gattc_app = g_malloc0(sizeof(hal_gatt_client_app));
-       gattc_app->client_if = __hal_generate_client_id();
+       gattc_app->client_if = client_if;
        memcpy(&gattc_app->app_uuid, app_uuid, sizeof(bt_uuid_t));
 
        hal_gattc_client_app_list = g_slist_append(hal_gattc_client_app_list, gattc_app);
@@ -337,6 +384,9 @@ bt_status_t __hal_gattc_unregister_client(int client_if)
 
                if (info->client_if == client_if) {
                        DBG("gatt client app found");
+
+                       __bt_hal_gatt_delete_if(client_if);
+
                        hal_gattc_client_app_list = g_slist_remove(hal_gattc_client_app_list, info);
                        g_free(info);
                }
@@ -610,9 +660,8 @@ static hal_gattc_service_t* _hal_gatt_client_add_service(hal_gattc_server_info_t
        _bt_hal_convert_uuid_string_to_type(gattc_service->svc_uuid.uu, uuid_str);
        gattc_service->is_primary = is_primary;
 
-       INFO("[%d] [%s] [%s]", g_slist_length(conn_info->gatt_list_services), object_path + 15, uuid_str);
-
        conn_info->gatt_list_services = g_slist_append(conn_info->gatt_list_services, gattc_service);
+       INFO("Toatal svc [%d] Added [%s] [%s]", g_slist_length(conn_info->gatt_list_services), object_path + 15, uuid_str);
 
        return gattc_service;
 }
@@ -1072,11 +1121,13 @@ static bt_status_t _hal_gattc_get_characteristic_info(hal_gattc_char_t *gattc_ch
                                char_permission |= _hal_get_permission_flag(permission);
                        }
                        __hal_convert_permission_flag_to_str(char_permission);
+                       g_variant_iter_free(char_perm_iter);
                } else if (!g_strcmp0(key, "Descriptors")) {
                        g_variant_get(value, "ao", &char_desc_iter);
                        while (g_variant_iter_loop(char_desc_iter, "&o", &char_desc_handle)) {
                                g_ptr_array_add(gp_desc_array, (gpointer)char_desc_handle);
                        }
+                       g_variant_iter_free(char_desc_iter);
                }
        }
 
@@ -1217,6 +1268,9 @@ static bt_status_t _hal_gattc_get_descriptor_info(hal_gattc_desc_t *gattc_desc)
                if (!g_strcmp0(key, "UUID")) {
                        desc_uuid_str = g_variant_get_string(value, &len);
                        _hal_gattc_update_desc_property(gattc_desc, desc_uuid_str);
+
+                       g_free((gchar *)key);
+                       g_variant_unref(value);
                        break;
                }
        }
@@ -3337,8 +3391,6 @@ static bt_status_t __bt_connect_le_device_internal(int client_if, const bt_bdadd
        int ret = BT_STATUS_SUCCESS;
        hal_gattc_client_info_t *gattc_data;
 
-       DBG("+");
-
        if (NULL == bd_addr) {
                ERR("bd_addr is NULL");
                return BT_STATUS_PARM_INVALID;
@@ -3358,7 +3410,6 @@ static bt_status_t __bt_connect_le_device_internal(int client_if, const bt_bdadd
                ret = BT_STATUS_FAIL;
                return ret;
        }
-       ERR("device_path:%s", device_path);
 
        device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
                        NULL, BT_HAL_BLUEZ_NAME,
@@ -3373,7 +3424,7 @@ static bt_status_t __bt_connect_le_device_internal(int client_if, const bt_bdadd
        memcpy(gattc_data->bd_addr.address, bd_addr->address,
                                        BT_HAL_ADDRESS_LENGTH_MAX);
 
-       DBG("Connect LE [%s]", device_address);
+       DBG("ConnectLE [%s]", device_address);
 
        gattc_data->client_if = client_if;
 
@@ -3449,8 +3500,6 @@ static void __le_connection_req_cb(GDBusProxy *proxy, GAsyncResult *res,
        struct hal_ev_gatt_client_connected ev;
        hal_gattc_server_info_t *gatt_conn_info = NULL;
 
-       DBG("+");
-
        reply = g_dbus_proxy_call_finish(proxy, res, &g_error);
        g_object_unref(proxy);
        if (reply == NULL) {
@@ -3464,7 +3513,7 @@ static void __le_connection_req_cb(GDBusProxy *proxy, GAsyncResult *res,
        g_variant_unref(reply);
 
        if (NULL == gattc_data) {
-               ERR("server_data is NULL");
+               ERR("gattc_data is NULL");
                return;
        }
 
@@ -3487,7 +3536,7 @@ static void __le_connection_req_cb(GDBusProxy *proxy, GAsyncResult *res,
                goto fail;
        }
 
-       DBG("adding the server conn info in list");
+       DBG("LE connected. Adding the gattc server/client conn info in list");
        gattc_data->conn_id = __hal_generate_conn_id() ;
        gattc_data->inst_id = __hal_generate_server_instance_id();
 
@@ -3500,7 +3549,6 @@ static void __le_connection_req_cb(GDBusProxy *proxy, GAsyncResult *res,
        gatt_conn_info->inst_id = gattc_data->inst_id;
        hal_gattc_server_info_list = g_slist_append(hal_gattc_server_info_list, gatt_conn_info);
 
-       DBG("-");
        return;
 
 fail:
@@ -3616,7 +3664,6 @@ void _bt_hal_handle_gattc_connected_event(char* address, gboolean gatt_connected
        if (!event_cb) {
                ERR("gatt client callback not registered");
        } else {
-               DBG("sending gatt client connected status  event");
                event_cb(event, (void *)&ev, sizeof(ev));
        }
 
@@ -3834,10 +3881,8 @@ static bt_status_t __hal_gattc_get_service_info(hal_gattc_server_info_t *server_
        while (g_variant_iter_loop(property_iter, "{sv}", &key, &value)) {
                if (g_strcmp0(key, "UUID") == 0) {
                        uuid_str = g_variant_get_string(value, &len);
-                       DBG("UUID: %s", uuid_str);
                } else if (g_strcmp0(key, "Primary") == 0) {
                        is_primary = g_variant_get_boolean(value);
-                       DBG("is_primary: %s", is_primary ? "TRUE" : "FALSE");
                } else if (g_strcmp0(key, "Characteristics") == 0) {
                        g_variant_get(value, "ao", &char_iter);
                        if (char_iter != NULL) {
@@ -3846,6 +3891,7 @@ static bt_status_t __hal_gattc_get_service_info(hal_gattc_server_info_t *server_
                                        DBG("char_handle: %s", char_handle);
                                        g_ptr_array_add(gp_char_array, (gpointer)char_handle);
                                }
+                               g_variant_iter_free(char_iter);
                        }
                }
        }
@@ -3862,7 +3908,7 @@ done:
        g_variant_iter_free(property_iter);
        g_variant_unref(result);
        g_object_unref(properties_proxy);
-       DBG("-");
+
        return BT_STATUS_SUCCESS;
 }
 
index 09b78ec..1d90fe8 100644 (file)
@@ -35,6 +35,8 @@
 extern "C" {
 #endif
 
+void _bt_hal_gatt_client_init(void);
+
 void _bt_hal_register_gatt_client_handler_cb(handle_stack_msg cb);
 void _bt_hal_unregister_gatt_client_handler_cb(void);
 
index 54de27a..0d7dba2 100644 (file)
@@ -195,7 +195,14 @@ struct hal_gatts_server_register_info_t {
 
 static GSList * hal_gatts_server_register_list;
 
-static int g_server_inst_id = 0;
+
+/* Should match the range with bt-service-gatt.c's MAX_APPS_SUPPORTED */
+/* TODO: Adjust MAX Server after modifying MAX app handle logic */
+#define BT_GATTS_MAX 11
+
+static int assigned_id = 0;
+
+static gboolean instance_id_used[BT_GATTS_MAX];
 
 #define CHECK_BTGATT_INIT() if (bt_gatt_callbacks == NULL)\
 {\
@@ -335,6 +342,48 @@ static const gchar manager_introspection_xml[] =
 "  </interface>"
 "</node>";
 
+void _bt_hal_gatt_server_init(void)
+{
+       assigned_id = 0;
+       memset(instance_id_used, 0x00, sizeof(instance_id_used));
+}
+
+static int __bt_hal_gatt_assign_id(void)
+{
+       int index;
+
+       index = assigned_id + 1;
+
+       if (index >= BT_GATTS_MAX)
+               index = 1;
+
+       while (instance_id_used[index] == TRUE) {
+               if (index == assigned_id) {
+                       /* No available ID */
+                       ERR("All interface ID is used");
+                       return -1;
+               }
+
+               index++;
+
+               if (index >= BT_GATTS_MAX)
+                       index = 1;
+       }
+
+       assigned_id = index;
+       instance_id_used[index] = TRUE;
+
+       return assigned_id;
+}
+
+static void __bt_hal_gatt_delete_id(int instance_id)
+{
+       if (instance_id >= BT_GATTS_MAX || instance_id < 0)
+               return;
+
+       instance_id_used[instance_id] = FALSE;
+}
+
 static GSList *_bt_get_service_list_from_server(int instance)
 {
        GSList *l;
@@ -1770,11 +1819,6 @@ static int bt_hal_gatts_get_gatt_server_instance()
        return -1;
 }
 
-int bt_hal_gatts_generate_server_id()
-{
-       return ++g_server_inst_id;
-}
-
 static struct hal_gatts_server_register_info_t * bt_hal_gatts_find_server_register_info_from_uuid(bt_uuid_t *app_uuid)
 {
        DBG("+");
@@ -1841,6 +1885,7 @@ static struct hal_gatts_server_register_info_t * bt_hal_gatts_find_server_regist
 static struct hal_gatts_server_register_info_t * bt_hal_gatts_add_server_app(bt_uuid_t *app_uuid)
 {
        struct hal_gatts_server_register_info_t * server_register_info = NULL;
+       int instance_id = 0;
 
        server_register_info = bt_hal_gatts_find_server_register_info_from_uuid(app_uuid);
        if (server_register_info != NULL) {
@@ -1848,8 +1893,14 @@ static struct hal_gatts_server_register_info_t * bt_hal_gatts_add_server_app(bt_
                return server_register_info;
        }
 
+       instance_id = __bt_hal_gatt_assign_id();
+       if (instance_id == -1) {
+               ERR("Fail to allocate the server if");
+               return NULL;
+       }
+
        server_register_info = g_malloc0(sizeof(struct hal_gatts_server_register_info_t));
-       server_register_info->server_if = bt_hal_gatts_generate_server_id();
+       server_register_info->server_if = instance_id;
 
        DBG("Adding the gatt server app. server_if:[%d]", server_register_info->server_if);
 
@@ -1866,9 +1917,13 @@ static bt_status_t gatt_server_register_app(bt_uuid_t *uuid)
        struct hal_gatts_server_register_info_t *server_register_info = NULL;
 
        DBG("Register server instance request");
-       hal_register_server_data *user_data = g_malloc0(sizeof(hal_register_server_data));
-
        server_register_info = bt_hal_gatts_add_server_app(uuid);
+       if (server_register_info == NULL) {
+               ERR("Fail to register the server app");
+               return BT_STATUS_FAIL;
+       }
+
+       hal_register_server_data *user_data = g_malloc0(sizeof(hal_register_server_data));
        user_data->instance_data = server_register_info->server_if;
 
        /*
@@ -1936,6 +1991,8 @@ static bt_status_t gatt_server_unregister_app(int server_if)
        hal_gatts_server_register_list = g_slist_remove(hal_gatts_server_register_list, server_register_info);
        g_free(server_register_info);
 
+       __bt_hal_gatt_delete_id(server_if);
+
        /* If server_if belongs to a GATT Server, then delete the GATT server from List */
        _bt_hal_remove_gatt_server_from_list(server_if);
        return BT_STATUS_SUCCESS;
index ffae6d5..8e0093c 100644 (file)
@@ -35,6 +35,8 @@
 extern "C" {
 #endif
 
+void _bt_hal_gatt_server_init(void);
+
 void _bt_hal_register_gatt_server_handler_cb(handle_stack_msg cb);
 
 void _bt_hal_unregister_gatt_server_handler_cb(void);
index 15fed96..e6b6d34 100644 (file)
@@ -841,12 +841,16 @@ static void __bt_hal_handle_gatt_client_mtu_exchange_completed(void *buf, uint16
 static bt_status_t gatt_init(const btgatt_callbacks_t* callbacks)
 {
        bt_gatt_callbacks = callbacks;
+
        DBG("Register A2DP Src events callback function");
        _bt_hal_register_gatt_le_dbus_handler_cb(__bt_hal_gatt_events);
        _bt_hal_register_gatt_server_handler_cb(__bt_hal_gatt_events);
        _bt_hal_register_gatt_client_handler_cb(__bt_hal_gatt_events);
        _bt_hal_register_event_handler_cb(HAL_GATT, __bt_hal_gatt_events);
 
+       _bt_hal_gatt_server_init();
+       _bt_hal_gatt_client_init();
+
        return BT_STATUS_SUCCESS;
 }
 
index 9bf3321..4061a42 100644 (file)
@@ -479,13 +479,14 @@ static void __hdp_handle_property_changed(GVariant *parameters)
                        INFO("Property MainChannel received");
                        obj_main_channel_path = g_variant_dup_string(value, &len);
                        DBG("Main Channel  Path = %s", obj_main_channel_path);
+
+                       g_free(property);
+                       g_variant_unref(value);
+                       g_free(obj_main_channel_path);
                        break;
                }
        }
        g_variant_iter_free(property_iter);
-       g_free(property);
-       g_variant_unref(value);
-       g_free(obj_main_channel_path);
 
        DBG("-");
 }
index b365a20..e9515c3 100644 (file)
@@ -882,6 +882,11 @@ typedef struct {
        int (*get_trusted_profile)(bt_bdaddr_t *bd_addr, bt_trusted_profile_t profile, uint32_t *trusted);
 
        /**
+        * Gets the identity address of the remote device
+        */
+       int (*get_device_ida)(bt_bdaddr_t *bd_addr, bt_bdaddr_t *id_addr);
+
+       /**
         * Get raw RSSI strength of remote device for connected link type
         * conn_link_type: (0 = BR/EDR link, 1 = LE link, 0xFF = Any (Default))
         */
index 2d1d583..dca40dc 100755 (executable)
@@ -379,6 +379,19 @@ oal_status_t device_unregister_osp_server(oal_osp_server_type_e type, char *uuid
 oal_status_t device_set_trust_profile(bt_address_t *addr, oal_trusted_profile_e profile, gboolean trust);
 
 /**
+ * @brief Gets the identity address for remote device
+ *
+ * @details This API is used to get the identity address for the remote device
+ *
+ * @param[in] device_address: Remote device address.
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS  Successful
+ *
+ */
+oal_status_t device_get_ida(bt_address_t *addr, bt_address_t *id_addr);
+
+/**
  * @brief Set profile trust info for remote device
  *
  * @details This API is used to set profile as trusted/blocked for remote device
index aedbd1a..d3da0d3 100755 (executable)
@@ -179,6 +179,25 @@ oal_status_t device_stop_bond(bt_address_t * addr)
        return OAL_STATUS_SUCCESS;
 }
 
+oal_status_t device_get_ida(bt_address_t *device_address, bt_address_t *id_address)
+{
+       int res;
+
+       CHECK_OAL_INITIALIZED();
+
+       OAL_CHECK_PARAMETER(device_address, return);
+
+       API_TRACE();
+
+       res = blued_api->get_device_ida((bt_bdaddr_t*) device_address, (bt_bdaddr_t*) id_address);
+
+       if (res != BT_STATUS_SUCCESS)
+               BT_ERR("get_device_IDA failed: [%s]",status2string(res));
+
+       res = convert_to_oal_status(res);
+       return res;
+}
+
 oal_status_t device_accept_pin_request(bt_address_t * addr, const char * pin)
 {
        int res;
index 23a2b9f..ae40cef 100644 (file)
@@ -1971,6 +1971,7 @@ void _bt_otp_gatt_char_property_changed_event(GVariant *msg,
                                } else {
                                        BT_ERR("Array Len 0");
                                }
+                               g_variant_unref(val);
                        } else {
                                BT_ERR("var==NULL");
                        }
@@ -2132,6 +2133,7 @@ void _bt_otp_device_property_event_filter(GDBusConnection *connection,
                        }
                }
        }
+       g_variant_unref(val);
 }
 
 int _bt_otp_init_event_receiver()
index fbe1660..2b39e01 100644 (file)
@@ -2096,14 +2096,18 @@ int _bt_stop_le_scan(const char *sender)
 
        /* Check scanning is in progress or not */
        scanner = __bt_find_scanner_from_list(sender);
-       if (scanner == NULL || scanner->is_scanning == FALSE)
+       if (scanner == NULL)
+               return BLUETOOTH_ERROR_NOT_IN_OPERATION;
+
+       if (scanner->is_scanning == FALSE)
                return BLUETOOTH_ERROR_NOT_IN_OPERATION;
 
        scanner->is_scanning = FALSE;
 
        for (l = scanner_list; l != NULL; l = g_slist_next(l)) {
-               scanner = l->data;
-               if (scanner->is_scanning == TRUE)
+               bt_adapter_le_scanner_t *scanner_iter = l->data;
+
+               if (scanner_iter->is_scanning == TRUE)
                        next_scanning = TRUE;
        }
 
@@ -2131,7 +2135,6 @@ int _bt_stop_le_scan(const char *sender)
 
        _bt_unregister_all_scan_filters(sender);
 
-       scanner = __bt_find_scanner_from_list(sender);
        scanner_list = g_slist_remove(scanner_list, scanner);
        __bt_free_le_scanner(scanner);
 
index cdd32e6..a24c73c 100644 (file)
@@ -369,7 +369,7 @@ static void __bt_service_method(GDBusConnection *connection,
 
                if (request_type == BT_ASYNC_REQ ||
                                __bt_is_sync_function(service_function)) {
-                       BT_INFO("Do not send reply to bt-api over dbus,"
+                       BT_DBG("Do not send reply to bt-api over dbus,"
                                " Invocation context is already saved in service_function");
                        goto done;
                }
@@ -2644,6 +2644,21 @@ int __bt_bluez_request(int function_name,
                }
                break;
        }
+       case BT_GET_DEVICE_IDA: {
+               bluetooth_device_address_t address = { {0} };
+               bluetooth_device_address_t id_addr = { {0} };
+
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
+
+               result = _bt_device_get_ida(&address, &id_addr);
+
+               if (result == BLUETOOTH_ERROR_NONE) {
+                       g_array_append_vals(*out_param1, &id_addr,
+                                       sizeof(bluetooth_device_address_t));
+               }
+               break;
+       }
        case BT_SET_LE_STATIC_RANDOM_ADDRESS: {
                gboolean is_enable;
 
@@ -2746,20 +2761,17 @@ int __bt_bluez_request(int function_name,
                __bt_service_get_parameters(in_param3,
                                &client_id, sizeof(int));
 
-               BT_INFO("GATT Client: client_id[%d]", client_id);
+               BT_DBG("GATT Client: client_id[%d]", client_id);
                result = _bt_connect_le_device(&address, auto_connect, client_id);
                if (BLUETOOTH_ERROR_NONE == result) {
-
                        addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
-                       BT_INFO("GATT Client: Save Invocation data Connect LE app[%s]", sender);
-
                        _bt_convert_addr_type_to_string(addr, address.addr);
 
                        /* Save the informations to invocation */
                        _bt_save_invocation_context(context, result, sender,
                                        function_name, (gpointer)addr);
                } else {
-                       BT_ERR("GATT Client: gatt connect failed");
+                       BT_ERR("GATT Client: gatt connect failed. client_id[%d]", client_id);
                        g_array_append_vals(*out_param1, &address,
                                        sizeof(bluetooth_device_address_t));
                }
index 008003c..d6ed3b7 100644 (file)
@@ -534,7 +534,6 @@ int _bt_copy_utf8_string(char *dest, const char *src, unsigned int length)
 
 gboolean _bt_utf8_validate(char *name)
 {
-       BT_DBG("+");
        gunichar2 *u16;
        glong items_written = 0;
 
@@ -550,7 +549,6 @@ gboolean _bt_utf8_validate(char *name)
        if (items_written != g_utf8_strlen(name, -1))
                return FALSE;
 
-       BT_DBG("-");
        return TRUE;
 }
 
@@ -1395,8 +1393,6 @@ invocation_info_t* _bt_get_request_info_data(int service_function, char *address
        GSList *l;
        invocation_info_t *req_info = NULL;
 
-       BT_DBG("+");
-
        retv_if(NULL == address, NULL);
 
        /* Get method invocation context */
@@ -1409,7 +1405,6 @@ invocation_info_t* _bt_get_request_info_data(int service_function, char *address
                        return req_info;
        }
 
-       BT_DBG("-");
        return NULL;
 }
 
index 9c4e3d7..0299e49 100644 (file)
@@ -412,7 +412,7 @@ void _bt_service_oal_event_receiver(int event_type, gpointer event_data, gsize l
 {
        bt_service_oal_event_data_t *oal_event = g_new0(bt_service_oal_event_data_t, 1);
 
-       BT_INFO("event_type: [%d], data size: [%zu]", event_type, len);
+       BT_DBG("event_type: [%d], data size: [%zu]", event_type, len);
 
        oal_event->type = event_type;
        if (event_data)
index 9da97fa..f4083b9 100644 (file)
@@ -450,15 +450,19 @@ int _bt_send_event(int event_type, int event, GVariant *param)
 #ifdef TIZEN_GATT_CLIENT
        case BLUETOOTH_EVENT_GATT_SERVER_CONNECTED: /* GATT Server and Client */
                signal = BT_GATT_SERVER_CONNECTED;
+               BT_INFO_C("### Connected [GATT server]");
                break;
        case BLUETOOTH_EVENT_GATT_SERVER_DISCONNECTED: /* GATT Client and Server */
                signal = BT_GATT_SERVER_DISCONNECTED;
+               BT_INFO_C("### Disconnected [GATT server]");
                break;
        case BLUETOOTH_EVENT_GATT_CLIENT_CONNECTED: /* GATT Server and Client */
                signal = BT_GATT_CLIENT_CONNECTED;
+               BT_INFO_C("### Connected [GATT client]");
                break;
        case BLUETOOTH_EVENT_GATT_CLIENT_DISCONNECTED: /* GATT Client and Server */
                signal = BT_GATT_CLIENT_DISCONNECTED;
+               BT_INFO_C("### Disconnected [GATT client]");
                break;
 #else
        case BLUETOOTH_EVENT_GATT_CONNECTED:
index c20d330..d0ce179 100644 (file)
@@ -1028,7 +1028,7 @@ static void __bt_device_dbfw_plus_info_callback(event_dev_dbfw_plus_info_t *dbfw
 static void __bt_device_event_handler(int event_type, gpointer event_data)
 {
        int eventcheck = OAL_EVENT_DEVICE_PROPERTIES;
-       BT_INFO("event [%d] Event check = [%d]", event_type, eventcheck);
+       BT_DBG("event [%d] Event check = [%d]", event_type, eventcheck);
 
        switch (event_type) {
        case OAL_EVENT_ADAPTER_INQUIRY_RESULT_BREDR_ONLY: {
@@ -1507,13 +1507,12 @@ static void __bt_device_acl_state_changed_callback(event_dev_conn_status_t *acl_
        GVariant *param = NULL;
        bt_device_conn_info_t conn_info;
 
-       BT_DBG("+");
        _bt_convert_addr_type_to_string(address, acl_event->address.addr);
 
        _bt_logging_connection(connected, type);
 
        result = __bt_oal_status_to_bt_error(acl_event->status);
-       BT_INFO("Result [0x%x]", result);
+       BT_DBG("Result [0x%x]", result);
 
        if (connected) {
                param = g_variant_new("(isy)", result, address, type);
@@ -1536,13 +1535,10 @@ static void __bt_device_acl_state_changed_callback(event_dev_conn_status_t *acl_
 
 #ifdef TIZEN_GATT_CLIENT
        /*handle LE connected device info*/
-       if (type) {
-               BT_DBG("handle LE connected device info");
+       if (type)
                _bt_handle_le_connected_dev_info(address, connected);
-       }
 #endif
 
-       BT_DBG("-");
 }
 
 static void __bt_device_remote_device_found_callback(gpointer event_data, gboolean is_ble)
@@ -2309,6 +2305,25 @@ int _bt_unset_pin_code(bluetooth_device_address_t *device_address)
        return BLUETOOTH_ERROR_NONE;
 }
 
+int _bt_device_get_ida(bluetooth_device_address_t *device_address, bluetooth_device_address_t *id_address)
+{
+       int result = BLUETOOTH_ERROR_NONE;
+       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+
+       _bt_convert_addr_type_to_string(address, device_address->addr);
+
+       BT_DBG("getting IDA for remote device: [%s]", address);
+
+       result = device_get_ida((bt_address_t*)device_address, (bt_address_t*)id_address);
+
+       if (result != OAL_STATUS_SUCCESS) {
+               BT_ERR("device_get_ida Failed %d", result);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       return result;
+}
+
 #ifdef TIZEN_GATT_CLIENT
 static bt_connected_le_dev_t *__bt_get_le_connected_dev_info(const char *address)
 {
@@ -2370,10 +2385,9 @@ static void _bt_remove_le_connected_dev_info(const char *address)
        return;
 }
 
-
 static void _bt_handle_le_connected_dev_info(const char *address, gboolean connected)
 {
-       BT_DBG("+");
+       BT_DBG("update le_connected_dev_list");
 
        if (connected)
                _bt_add_le_connected_dev_info(address);
index d59d769..2a93723 100644 (file)
@@ -237,9 +237,14 @@ static struct gatt_server_req_info *__bt_gatt_server_find_request_info(int reque
 static int __bt_gatt_send_indication_to_all_connected_clients(bluetooth_gatt_att_data_t *data,
                bluetooth_gatt_server_indication_params_t *param);
 
-static void __bt_remove_all_service_handles(int instance_id);
+static void __bt_remove_all_service_handles(bt_service_app_info_t *app_info);
+
 static void __bt_free_service_info(bt_gatt_service_info_t *service_info);
 
+static int __bt_unregister_gatt_client_instance(int client_if);
+
+static void __bt_service_reset_gatt_data(void);
+
 #ifdef TIZEN_GATT_CLIENT
 static void __bt_handle_client_instance_registered(event_gattc_register_t *data);
 static void __bt_handle_client_connected(event_gattc_conn_t *event_data);
@@ -295,11 +300,16 @@ static void __bt_handle_server_instance_registered(event_gatts_register_t *data)
 
 static void __bt_gatt_event_handler(int event_type, gpointer event_data);
 
+typedef enum {
+       BT_GATT_SERVER = 1,
+       BT_GATT_CLIENT,
+} bt_gatt_type_e;
+
 void _bt_check_adv_app_termination(const char *name)
 {
        bt_service_app_info_t *app = NULL;
        int k;
-       int apps[MAX_APPS_SUPPORTED];
+       int apps[MAX_APPS_SUPPORTED] = { 0, };
 
        ret_if(NULL == name);
 
@@ -312,29 +322,43 @@ void _bt_check_adv_app_termination(const char *name)
                if (!strncasecmp(app->sender, name, strlen(name)) && app->is_initialized == TRUE) {
                        BT_DBG("Match found, name: %s", name);
 
-                       /* Unregister all service handles with stack */
-                       __bt_remove_all_service_handles(app->instance_id);
-
-                       /* If Advertising is enabled, stop it */
-                       if (app->adv_handle > 0) {
-                               BT_INFO("Stop advertising on instance ID [%d]", app->instance_id);
-                               /* Disable adv if running */
-                               BT_INFO("Disable Advertising Adv Handle [%d] sender [%s]",
-                                               app->adv_handle, name);
-                               _bt_set_advertising(app->sender, app->adv_handle, FALSE, FALSE);
-                       }
+                       /* TODO 2: Need to manage app info as list, not array.
+                                  This loop always run for MAX count if any apps are terminated.
+                        */
 
                        /* Save instances of all apps that need to be unregistered */
-                       apps[app->instance_id] = 1;
+                       if (app->instance_id != -1) {
+                               /* GATT server */
+                               /* Unregister all service handles with stack */
+                               __bt_remove_all_service_handles(app);
+
+                               /* If Advertising is enabled, stop it */
+                               if (app->adv_handle > 0) {
+                                       BT_INFO("Stop advertising on instance ID [%d]", app->instance_id);
+                                       /* Disable adv if running */
+                                       BT_INFO("Disable Advertising Adv Handle [%d] sender [%s]",
+                                                       app->adv_handle, name);
+                                       _bt_set_advertising(app->sender, app->adv_handle, FALSE, FALSE);
+                               }
+
+                               apps[app->instance_id] = BT_GATT_SERVER;  /* App holds a GATT server Instance */
+                       } else if (app->client_id != -1) {
+                               /* GATT client */
+                               apps[app->client_id] = BT_GATT_CLIENT;    /* App holds a GATT client Instance */
+                       }
                }
        }
 
        /* Unregister all apps one by one */
        for (k = 1; k < MAX_APPS_SUPPORTED; k++) {
-               if (apps[k] == 1) {
-                       BT_INFO("Unregister app[%d]", k);
+               if (apps[k] == BT_GATT_SERVER) {
+                       BT_INFO("Unregister server app[%d]", k);
                        /* Unregister server instance */
                        __bt_unregister_gatt_server_instance(k);
+               } else if (apps[k] == BT_GATT_CLIENT) {
+                       BT_INFO("Unregister client app[%d]", k);
+                       /* Unregister client instance */
+                       __bt_unregister_gatt_client_instance(k);
                }
        }
 }
@@ -425,6 +449,8 @@ static void __bt_register_default_gatt_client()
 
 int _bt_gatt_init(void)
 {
+       const char *stack_name = NULL;
+
        BT_DBG("+");
 
        if (OAL_STATUS_SUCCESS != gatt_enable()) {
@@ -434,15 +460,21 @@ int _bt_gatt_init(void)
 
        /* Register gatt event handler */
        _bt_service_register_event_handler_callback(BT_GATT_MODULE, __bt_gatt_event_handler);
-#ifdef TIZEN_GATT_CLIENT
-       /*In bluedroid product, defacult gatt client is handled differently*/
-       __bt_register_default_gatt_client();
-#endif
+
+       __bt_service_reset_gatt_data();
+
+       stack_name = oal_get_stack_name();
+
+       if (stack_name && g_strcmp0(stack_name, "bluez") == 0) {
+               /*In the platform, defacult gatt client should be registered */
+               __bt_register_default_gatt_client();
+       }
+
        BT_DBG("-");
        return BLUETOOTH_ERROR_NONE;
 }
 
-static void __bt_service_reset_gatt_data()
+static void __bt_service_reset_gatt_data(void)
 {
        int k;
 
@@ -460,6 +492,11 @@ static void __bt_service_reset_gatt_data()
                        memset(numapps[k].scan_rsp.data, 0x00, BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX);
                        numapps[k].adv_data_len = 0;
                        numapps[k].scan_rsp_len = 0;
+
+                       /* GATT client */
+                       numapps[k].client_id = -1;
+                       memset(numapps[k].address.addr, 0x00, BLUETOOTH_ADDRESS_LENGTH);
+                       numapps[k].is_watcher_enabled = FALSE;
        }
 }
 
@@ -608,6 +645,35 @@ void _bt_get_previous_scan_rsp_data(bluetooth_scan_resp_data_t *scan, int *len,
        }
 }
 
+static int __bt_unregister_gatt_client_instance(int client_if)
+{
+       int ret = OAL_STATUS_SUCCESS;
+       int k;
+
+       BT_INFO("DeAllocate client instance ID [%d]", client_if);
+
+       /* Reset data: instance_id parameter could be either for GATT Server or for GATT client  */
+       for (k = 1; k < MAX_APPS_SUPPORTED; k++) {
+               if (numapps[k].client_id == client_if) {
+                       BT_INFO("This is a GATT client app, unregister: Slot [%d] vacant", k);
+                       numapps[k].client_id = -1;
+                       numapps[k].is_initialized = FALSE;
+                       memset(numapps[k].sender, 0x00, sizeof(numapps[k].sender));
+                       memset(numapps[k].uuid, 0x00, sizeof(numapps[k].uuid));
+                       memset(&numapps[k].address.addr, 0x00, sizeof(bluetooth_device_address_t));
+
+                       /* Its a GATT Client Instance */
+                       ret = gattc_deregister(client_if);
+                       if (ret != OAL_STATUS_SUCCESS) {
+                               BT_ERR("DeAllocate GATT Client instance with stack Fail ret: %d", ret);
+                               return BLUETOOTH_ERROR_INTERNAL;
+                       }
+                       break;
+               }
+       }
+       return BLUETOOTH_ERROR_NONE;
+}
+
 static int __bt_unregister_gatt_server_instance(int server_instance)
 {
        int ret = OAL_STATUS_SUCCESS;
@@ -641,34 +707,37 @@ static int __bt_unregister_gatt_server_instance(int server_instance)
        return BLUETOOTH_ERROR_NONE;
 }
 
-static void __bt_remove_all_service_handles(int instance_id)
+static void __bt_remove_all_service_handles(bt_service_app_info_t *app_info)
 {
        GSList *l;
        int *handle = NULL;
        int ret = OAL_STATUS_SUCCESS;
        int count;
 
-       count = g_slist_length(numapps[instance_id].service_handles);
+       if (app_info == NULL)
+               return;
+
+       count = g_slist_length(app_info->service_handles);
        BT_INFO("Before handle removal: current count [%d]", count);
 
-       for (l = numapps[instance_id].service_handles; l != NULL;) {
+       for (l = app_info->service_handles; l != NULL;) {
                handle = l->data;
                l = g_slist_next(l);
 
                if (handle) {
-                       BT_INFO("Server Handle to be Removed [%d] Instance ID [%d]", *handle, instance_id);
-                       if (_bt_gatt_server_stop_service(numapps[instance_id].sender, *handle, instance_id) != BLUETOOTH_ERROR_NONE)
+                       BT_INFO("Server Handle to be Removed [%d] Instance ID [%d]", *handle, app_info->instance_id);
+                       if (_bt_gatt_server_stop_service(app_info->sender, *handle, app_info->instance_id) != BLUETOOTH_ERROR_NONE)
                                continue;
 
-                       ret = gatts_delete_service(instance_id, *handle);
+                       ret = gatts_delete_service(app_info->instance_id, *handle);
                        if (ret != OAL_STATUS_SUCCESS) {
                                BT_ERR("ret: %d", ret);
                                continue;
                        } else {
-                               numapps[instance_id].service_handles = g_slist_remove(numapps[instance_id].service_handles, handle);
+                               app_info->service_handles = g_slist_remove(app_info->service_handles, handle);
                                g_free(handle);
                                handle = NULL;
-                               count = g_slist_length(numapps[instance_id].service_handles);
+                               count = g_slist_length(app_info->service_handles);
                                BT_INFO("After deleting current count [%d]", count);
                        }
                }
@@ -697,7 +766,7 @@ int _bt_unregister_server_instance(const char *sender, int adv_handle)
                        if (!g_strcmp0(info->sender, sender)) {
                                BT_INFO("Unregister GATT server instance [%d]", info->instance_id);
                                /* Unregister all service handles with stack */
-                               __bt_remove_all_service_handles(info->instance_id);
+                               __bt_remove_all_service_handles(info);
 
                                /* Disable adv if running */
                                BT_INFO("Disable Advertising Adv Handle [%d] sender [%s]",
@@ -812,7 +881,7 @@ static void __bt_gatt_handle_pending_request_info(int result,
 #ifndef GATT_DIRECT
                case BT_GATT_SERVER_REGISTER: {
                        bt_service_app_info_t *param = (bt_service_app_info_t*)data;
-                       BT_INFO("Sender [%s] Request Sender [%s]", param->sender, req_info->sender);
+                       BT_DBG("Sender [%s] Request Sender [%s]", param->sender, req_info->sender);
                        if (!g_strcmp0(req_info->sender, param->sender)) {
                                BT_DBG("GATT Server app found [%s]", req_info->sender);
 
@@ -829,7 +898,7 @@ static void __bt_gatt_handle_pending_request_info(int result,
                case BT_GATT_SERVER_START_SERVICE:
                case BT_GATT_SERVER_DELETE_SERVICE: {
                        bt_service_app_info_t *param = (bt_service_app_info_t*)data;
-                       BT_INFO("Sender [%s] Request Sender [%s]", param->sender, req_info->sender);
+                       BT_DBG("Sender [%s] Request Sender [%s]", param->sender, req_info->sender);
 
                        int *saved_instance_id = (int*)req_info->user_data;
                        if (!g_strcmp0(req_info->sender, param->sender) && param->instance_id == *saved_instance_id) {
@@ -850,7 +919,7 @@ static void __bt_gatt_handle_pending_request_info(int result,
                case BT_GATT_SERVER_ADD_DESCRIPTOR:
                case BT_GATT_SERVER_ADD_CHARACTERISTIC: {
                        int *handle = (int*)data;
-                       BT_INFO("Characteristic added: Handle [%d]", *handle);
+                       BT_DBG("Characteristic added: Handle [%d]", *handle);
                        out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
 
                        g_array_append_vals(out_param, handle, sizeof(int));
@@ -899,7 +968,7 @@ static void __bt_gatt_handle_pending_request_info(int result,
 #ifdef TIZEN_GATT_CLIENT
                case BT_GATT_CLIENT_REGISTER: {
                        bt_service_app_info_t *param = (bt_service_app_info_t*)data;
-                       BT_INFO("Sender [%s] Request Sender [%s]", param->sender, req_info->sender);
+                       BT_DBG("Sender [%s] Request Sender [%s]", param->sender, req_info->sender);
                        if (!g_strcmp0(req_info->sender, param->sender)) {
                                BT_DBG("GATT Client app found [%s] created client ID [%d]",
                                                req_info->sender, param->client_id);
@@ -920,7 +989,7 @@ static void __bt_gatt_handle_pending_request_info(int result,
                        _bt_convert_addr_type_to_string(address,
                                        (unsigned char *)(&param->device_addr.addr));
 
-                       BT_INFO("Request Sender [%s] address [%s]", req_info->sender, address);
+                       BT_DBG("Request Sender [%s] address [%s]", req_info->sender, address);
 
                        /* Match address to determine same request */
                        if (!g_strcmp0((char*)req_info->user_data, address)) {
@@ -945,7 +1014,7 @@ static void __bt_gatt_handle_pending_request_info(int result,
                        bt_char_browse_info_t param;
                        memcpy((void*)&param, data, sizeof(bt_char_browse_info_t));
                        //bt_char_browse_info_t *param = (bt_char_browse_info_t*)data;
-                       BT_INFO("Request Sender [%s]", req_info->sender);
+                       BT_DBG("Request Sender [%s]", req_info->sender);
                        bluetooth_gatt_client_svc_prop_info_t *prop = (bluetooth_gatt_client_svc_prop_info_t*)req_info->user_data;
 
                        /* Match both address and service properties to determine same request */
@@ -954,7 +1023,7 @@ static void __bt_gatt_handle_pending_request_info(int result,
                                        sizeof(bluetooth_device_address_t)) &&
                                        !memcmp(param.svc_uuid, prop->svc.uuid, BLUETOOTH_UUID_HEX_MAX_LEN) &&
                                        param.svc_inst_id == prop->svc.instance_id) {
-                               BT_INFO("Returning Service properties");
+                               BT_DBG("Returning Service properties");
 
                                out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
                                g_array_append_vals(out_param, &param, sizeof(bt_char_browse_info_t));
@@ -969,7 +1038,7 @@ static void __bt_gatt_handle_pending_request_info(int result,
                case BT_GATT_GET_CHARACTERISTIC_PROPERTIES: {
                        bt_descriptor_browse_info_t *param = (bt_descriptor_browse_info_t*)data;
 
-                       BT_INFO("Request Sender [%s]", req_info->sender);
+                       BT_DBG("Request Sender [%s]", req_info->sender);
                        bluetooth_gatt_client_char_prop_info_t *prop = (bluetooth_gatt_client_char_prop_info_t*)req_info->user_data;
 
                        /* Match both address, service properties &char properties to determine same request */
@@ -980,7 +1049,7 @@ static void __bt_gatt_handle_pending_request_info(int result,
                                        param->svc_inst_id == prop->svc.instance_id &&
                                        !memcmp(param->char_uuid, prop->characteristic.uuid, BLUETOOTH_UUID_HEX_MAX_LEN) &&
                                        param->char_inst_id == prop->characteristic.instance_id) {
-                               BT_INFO("Returning Characteristic properties");
+                               BT_DBG("Returning Characteristic properties");
                                out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
                                                g_array_append_vals(out_param, param, sizeof(bt_descriptor_browse_info_t));
                                _bt_service_method_return(req_info->context, out_param, result);
@@ -994,7 +1063,7 @@ static void __bt_gatt_handle_pending_request_info(int result,
                case BT_GATT_WATCH_CHARACTERISTIC: {
                        bt_gatt_notif_reg_info_t *param = (bt_gatt_notif_reg_info_t*)data;
                        bluetooth_gatt_client_char_prop_info_t *prop = (bluetooth_gatt_client_char_prop_info_t*)req_info->user_data;
-                       BT_INFO("Request Sender [%s]", req_info->sender);
+                       BT_DBG("Request Sender [%s]", req_info->sender);
                        /* Match both address, service properties &char properties to determine same request */
                        if (!memcmp(param->addr.addr,
                                        prop->device_address.addr,
@@ -1017,14 +1086,14 @@ static void __bt_gatt_handle_pending_request_info(int result,
                case BT_GATT_READ_CHARACTERISTIC:
                case BT_GATT_WRITE_CHARACTERISTIC_VALUE_BY_TYPE: {
                         bluetooth_gatt_client_char_prop_info_t *param = (bluetooth_gatt_client_char_prop_info_t*)data;
-                        BT_INFO("Request Sender [%s]", req_info->sender);
+                        BT_DBG("Request Sender [%s]", req_info->sender);
 
                         char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
                         bluetooth_gatt_client_char_prop_info_t *prop = (bluetooth_gatt_client_char_prop_info_t*)req_info->user_data;
                         _bt_convert_addr_type_to_string(addr, prop->device_address.addr);
 
                         if (!memcmp(param, prop, sizeof(bluetooth_gatt_client_char_prop_info_t))) {
-                                BT_INFO("Gatt Char read or write request matched for address [%s]", addr);
+                                BT_DBG("Gatt Char read or write request matched for address [%s]", addr);
                                 out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
                                 g_array_append_vals(out_param, param, sizeof(bluetooth_gatt_client_char_prop_info_t));
                                 _bt_service_method_return(req_info->context, out_param, result);
@@ -1039,14 +1108,14 @@ static void __bt_gatt_handle_pending_request_info(int result,
                case BT_GATT_READ_DESCRIPTOR_VALUE:
                case BT_GATT_WRITE_DESCRIPTOR_VALUE: {
                         bluetooth_gatt_client_desc_prop_info_t *param = (bluetooth_gatt_client_desc_prop_info_t*)data;
-                        BT_INFO("Request Sender [%s]", req_info->sender);
+                        BT_DBG("Request Sender [%s]", req_info->sender);
 
                         char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
                         bluetooth_gatt_client_desc_prop_info_t *prop = (bluetooth_gatt_client_desc_prop_info_t*)req_info->user_data;
                         _bt_convert_addr_type_to_string(addr, prop->device_address.addr);
 
                         if (!memcmp(param, prop, sizeof(bluetooth_gatt_client_desc_prop_info_t))) {
-                                BT_INFO("Descriptor read or write request matched for address [%s]", addr);
+                                BT_DBG("Descriptor read or write request matched for address [%s]", addr);
                                 out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
                                 g_array_append_vals(out_param, param, sizeof(bluetooth_gatt_client_desc_prop_info_t));
                                 _bt_service_method_return(req_info->context, out_param, result);
@@ -1063,7 +1132,7 @@ static void __bt_gatt_handle_pending_request_info(int result,
                        bluetooth_device_address_t address;
 
                        if (!g_strcmp0(addr, (char*)data)) {
-                               BT_INFO("GATT Client BT_REQ_ATT_MTU call pending for app [%s] addr [%s]",
+                               BT_DBG("GATT Client BT_REQ_ATT_MTU call pending for app [%s] addr [%s]",
                                                req_info->sender, addr);
                                out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
                                _bt_convert_addr_string_to_type(address.addr, addr);
@@ -1082,7 +1151,6 @@ static void __bt_gatt_handle_pending_request_info(int result,
                        break;
                }
        }
-       BT_DBG("-");
 }
 
 static void __bt_handle_server_instance_registered(event_gatts_register_t *data)
@@ -1965,7 +2033,6 @@ static void __bt_handle_gatt_mtu_changed_event(event_gatts_mtu_changed_t *event)
        struct gatt_client_info_t *conn_info = NULL;
        GVariant *param = NULL;
        guint8 status = 0;
-       BT_INFO("GATT Server MTU changed event");
 
        conn_info = __bt_find_remote_gatt_client_info_from_conn_id(event->conn_id);
        if (conn_info == NULL) {
@@ -3080,10 +3147,9 @@ static void __bt_handle_client_connected(event_gattc_conn_t *event_data)
                        conn_info = g_new0(struct gatt_server_info_t, 1);
                        conn_info->addr = g_strdup(address);
                        conn_info->client_id = event_data->client_if;
-                       BT_INFO("Added GATT server addr[%s]", conn_info->addr);
                        conn_info->connection_id = event_data->conn_id;
                        gatt_server_info_list = g_slist_append(gatt_server_info_list, conn_info);
-                       BT_INFO("Total num of connected Remote GATT server devices [%d]",
+                       BT_DBG("Total num of connected Remote GATT server devices [%d]",
                                        g_slist_length(gatt_server_info_list));
 
 #if 0
@@ -4178,7 +4244,7 @@ int _bt_connect_le_device(bluetooth_device_address_t *address,
 
        addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
        _bt_convert_addr_type_to_string(addr, address->addr);
-       BT_INFO("GATT Client connect request for address [%s] client instance [%d]",
+       BT_DBG("GATT Client connect request for address [%s] client instance [%d]",
                        addr, client_id);
 
 
@@ -4187,7 +4253,7 @@ int _bt_connect_le_device(bluetooth_device_address_t *address,
        if (req_info) {
                remote_address = (char*)req_info->user_data;
                if (remote_address && !strcasecmp(remote_address, addr)) {/* Address matched */
-                       BT_INFO("Already Connection ongoing for same remote GATT Server address [%s]", remote_address);
+                       BT_DBG("Already Connection ongoing for same remote GATT Server address [%s]", remote_address);
                        /* Return and wait for events to be sent to all apps */
                        g_free(addr);
                        return BLUETOOTH_ERROR_IN_PROGRESS;
@@ -4206,9 +4272,8 @@ int _bt_connect_le_device(bluetooth_device_address_t *address,
 
        /* Check if app sent 0 client id for connection, in such case, use default gatt client ID */
        if (client_id == 0) {
-               BT_INFO("GATT CLient connect request sent by an app without any client instance [%d]",
-                               client_id);
-               BT_INFO("Assign default GATT client id [%d]", gatt_default_client);
+               /* GATT CLient connect request sent by an app without any client instance [0] */
+               BT_DBG("Assign default GATT client id [%d]", gatt_default_client);
                client_id = gatt_default_client;
        }
 
@@ -4216,7 +4281,7 @@ int _bt_connect_le_device(bluetooth_device_address_t *address,
        ret = gattc_connect(client_id, (bt_address_t*)(address), auto_connect);
 
        if (ret != OAL_STATUS_SUCCESS) {
-               BT_ERR("ret: %d", ret);
+               BT_ERR("gattc_connect is failed. ret: %d", ret);
                g_free(addr);
                return BLUETOOTH_ERROR_INTERNAL;
        }
@@ -4238,7 +4303,7 @@ int _bt_gatt_get_primary_services(char *address)
        struct gatt_server_info_t *conn_info = NULL;
        invocation_info_t *req_info = NULL;
        int ret = OAL_STATUS_SUCCESS;
-       BT_INFO("+");
+       BT_DBG("+");
 
        /* Check if any app is already browsing primary services on the same remote GATT Server */
        req_info = _bt_get_request_info_data(BT_GATT_GET_PRIMARY_SERVICES, address);
@@ -4829,8 +4894,6 @@ int _bt_disconnect_le_device(bluetooth_device_address_t *address,
 
        BT_CHECK_PARAMETER(address, return);
 
-       BT_INFO("+");
-
        addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
        _bt_convert_addr_type_to_string(addr, address->addr);
        BT_INFO("GATT Client Disconnect request for address [%s]", addr);
@@ -4840,7 +4903,7 @@ int _bt_disconnect_le_device(bluetooth_device_address_t *address,
        if (req_info) {
                remote_address = (char*)req_info->user_data;
                if (remote_address && !strcasecmp(remote_address, addr)) {/* Address matched */
-                       BT_INFO("Already DisConnection ongoing for same remote GATT Server address [%s]", remote_address);
+                       BT_DBG("Already DisConnection ongoing for same remote GATT Server address [%s]", remote_address);
                        /* Return success and wait for events to be sent to all apps */
                        g_free(addr);
                        return BLUETOOTH_ERROR_IN_PROGRESS;
index 301cdb6..f9a6a93 100755 (executable)
@@ -125,6 +125,8 @@ int _bt_disconnect_device(bluetooth_device_address_t *device_addr);
 
 int _bt_get_le_connection_parameter(bluetooth_le_connection_mode_t mode,
                bluetooth_le_connection_param_t *param);
+int _bt_device_get_ida(bluetooth_device_address_t *device_address,
+               bluetooth_device_address_t *id_address);
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 9a35cb9..51629b9 100644 (file)
@@ -44,8 +44,6 @@ static void __bt_ipsp_property_changed_event(GVariant *msg, const char *path);
 
 static void __bt_device_property_changed_event(GVariant *msg, const char *path)
 {
-       BT_DBG("+");
-
        int event;
        int result = BLUETOOTH_ERROR_NONE;
        GVariantIter value_iter;
@@ -82,7 +80,7 @@ static void __bt_device_property_changed_event(GVariant *msg, const char *path)
                } else if (strcasecmp(property, "IpspBtInterfaceInfo") == 0) {
                        char *ifname = NULL;
 
-                       g_variant_get(val, "s", &ifname);
+                       g_variant_get(val, "&s", &ifname);
 
                        address = g_malloc0(BT_ADDRESS_STRING_SIZE);
 
@@ -99,7 +97,6 @@ static void __bt_device_property_changed_event(GVariant *msg, const char *path)
                        g_free(address);
                }
        }
-       BT_DBG("-");
 }
 
 void _bt_handle_ipsp_device_event(GVariant *msg, const char *member, const char *path)
index 7e897c1..37769ff 100644 (file)
@@ -421,7 +421,6 @@ char *_bt_get_bonded_device_name(char *address)
 void _bt_handle_device_event(GVariant *msg, const char *member, const char *path)
 {
        char *address;
-       char secure_address[BT_ADDRESS_STRING_SIZE] = { 0 };
        ret_if(path == NULL);
 
        if (strcasecmp(member, "Disconnected") == 0) {
@@ -448,21 +447,6 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                }
                g_free(address);
                g_free(dev_name);
-       } else if (strcasecmp(member, "ProfileStateChanged") == 0) {
-               int state = 0;
-               char *profile_uuid = NULL;
-               bluetooth_device_address_t bd_addr;
-
-               g_variant_get(msg, "(si)", &profile_uuid, &state);
-
-               address = g_malloc0(BT_ADDRESS_STRING_SIZE);
-
-               _bt_convert_device_path_to_address(path, address);
-               _bt_convert_addr_string_to_type(bd_addr.addr, address);
-
-               _bt_convert_addr_string_to_secure_string(secure_address, address);
-               BT_DBG("[%s] [%s] [%d]", secure_address, profile_uuid, state);
-               g_free(address);
        }
 }
 
index 2225bb4..cc9fc62 100644 (file)
@@ -359,6 +359,8 @@ void __bt_get_auth_info(GVariant *reply, char *auth_info)
                                g_variant_get(tmp_value, "ay", &value_iter);
                                while (g_variant_iter_loop(value_iter, "y", &m_value))
                                        manufacturer_data[i++] = m_value;
+
+                               g_variant_iter_free(value_iter);
                        }
                        g_variant_unref(tmp_value);
                } else {
index 078bca7..888b792 100644 (file)
@@ -1928,6 +1928,7 @@ int _bt_is_service_used(char *service_uuid, gboolean *used)
        }
        g_variant_iter_free(iter);
        g_variant_unref(result);
+       g_variant_unref(temp);
 
        BT_DBG("Service Used? %d", *used);
 
index fd531ab..bbfe207 100644 (file)
@@ -1511,6 +1511,8 @@ void __bt_get_auth_info(GVariant *reply, char *auth_info)
                                g_variant_get(tmp_value, "ay", &value_iter);
                                while (g_variant_iter_loop(value_iter, "y", &m_value))
                                        manufacturer_data[i++] = m_value;
+
+                               g_variant_iter_free(value_iter);
                        }
                        g_variant_unref(tmp_value);
                } else {
index 4709e9d..7a87ed7 100644 (file)
@@ -492,6 +492,8 @@ bt_remote_dev_info_t *_bt_get_remote_device_info_by_object_path(
                                g_variant_get(tmp_value, "ay", &value_iter);
                                while (g_variant_iter_loop(value_iter, "y", &m_value))
                                        dev_info->manufacturer_data[i++] = m_value;
+
+                               g_variant_iter_free(value_iter);
                        }
                        g_variant_unref(tmp_value);
                } else {
index fc97873..73efe11 100644 (file)
@@ -1222,7 +1222,7 @@ static void __bt_device_property_changed_event(GVariant *msg, const char *path)
                } else if (strcasecmp(property, "IpspBtInterfaceInfo") == 0) {
                        char *ifname = NULL;
 
-                       g_variant_get(val, "s", &ifname);
+                       g_variant_get(val, "&s", &ifname);
 
                        address = g_malloc0(BT_ADDRESS_STRING_SIZE);