Loading system/btif/src/btif_dm.cc +38 −3 Original line number Diff line number Diff line Loading @@ -101,8 +101,6 @@ const Uuid UUID_BASS = Uuid::FromString("184F"); const Uuid UUID_BATTERY = Uuid::FromString("180F"); const bool enable_address_consolidate = true; // TODO remove #define COD_MASK 0x07FF #define COD_UNCLASSIFIED ((0x1F) << 8) #define COD_HID_KEYBOARD 0x0540 #define COD_HID_POINTING 0x0580 Loading @@ -115,6 +113,8 @@ const bool enable_address_consolidate = true; // TODO remove #define COD_AV_PORTABLE_AUDIO 0x041C #define COD_AV_HIFI_AUDIO 0x0428 #define COD_CLASS_LE_AUDIO (1 << 14) #define BTIF_DM_MAX_SDP_ATTEMPTS_AFTER_PAIRING 2 #ifndef PROPERTY_CLASS_OF_DEVICE Loading Loading @@ -470,7 +470,7 @@ static uint32_t get_cod(const RawAddress* remote_bdaddr) { if (btif_storage_get_remote_device_property( (RawAddress*)remote_bdaddr, &prop_name) == BT_STATUS_SUCCESS) { LOG_INFO("%s remote_cod = 0x%08x", __func__, remote_cod); return remote_cod & COD_MASK; return remote_cod; } return 0; Loading @@ -488,6 +488,9 @@ bool check_cod_hid(const RawAddress& bd_addr) { return (get_cod(&bd_addr) & COD_HID_MASK) == COD_HID_MAJOR; } bool check_cod_le_audio(const RawAddress& bd_addr) { return (get_cod(&bd_addr) & COD_CLASS_LE_AUDIO) == COD_CLASS_LE_AUDIO; } /***************************************************************************** * * Function check_sdp_bl Loading Loading @@ -682,6 +685,33 @@ static void btif_update_remote_properties(const RawAddress& bdaddr, properties); } /* If device is LE Audio capable, we prefer LE connection first, this speeds * up LE profile connection, and limits all possible service discovery * ordering issues (first Classic, GATT over SDP, etc) */ static bool is_device_le_audio_capable(const RawAddress bd_addr) { if (!LeAudioClient::IsLeAudioClientRunning() || !check_cod_le_audio(bd_addr)) { return false; } tBT_DEVICE_TYPE tmp_dev_type; tBLE_ADDR_TYPE addr_type = BLE_ADDR_PUBLIC; BTM_ReadDevInfo(bd_addr, &tmp_dev_type, &addr_type); if (tmp_dev_type & BT_DEVICE_TYPE_BLE) { return true; } int device_type = 0; std::string addrstr = bd_addr.ToString(); const char* bdstr = addrstr.c_str(); btif_config_get_int(bdstr, "DevType", &device_type); if ((device_type & BT_DEVICE_TYPE_BLE) == BT_DEVICE_TYPE_BLE) { return true; } return false; } /******************************************************************************* * * Function btif_dm_cb_create_bond Loading @@ -697,6 +727,11 @@ static void btif_dm_cb_create_bond(const RawAddress bd_addr, bool is_hid = check_cod(&bd_addr, COD_HID_POINTING); bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_BONDING); if (transport == BT_TRANSPORT_AUTO && is_device_le_audio_capable(bd_addr)) { LOG_INFO("LE Audio && advertising over LE, use LE transport for Bonding"); transport = BT_TRANSPORT_LE; } int device_type = 0; tBLE_ADDR_TYPE addr_type = BLE_ADDR_PUBLIC; std::string addrstr = bd_addr.ToString(); Loading Loading
system/btif/src/btif_dm.cc +38 −3 Original line number Diff line number Diff line Loading @@ -101,8 +101,6 @@ const Uuid UUID_BASS = Uuid::FromString("184F"); const Uuid UUID_BATTERY = Uuid::FromString("180F"); const bool enable_address_consolidate = true; // TODO remove #define COD_MASK 0x07FF #define COD_UNCLASSIFIED ((0x1F) << 8) #define COD_HID_KEYBOARD 0x0540 #define COD_HID_POINTING 0x0580 Loading @@ -115,6 +113,8 @@ const bool enable_address_consolidate = true; // TODO remove #define COD_AV_PORTABLE_AUDIO 0x041C #define COD_AV_HIFI_AUDIO 0x0428 #define COD_CLASS_LE_AUDIO (1 << 14) #define BTIF_DM_MAX_SDP_ATTEMPTS_AFTER_PAIRING 2 #ifndef PROPERTY_CLASS_OF_DEVICE Loading Loading @@ -470,7 +470,7 @@ static uint32_t get_cod(const RawAddress* remote_bdaddr) { if (btif_storage_get_remote_device_property( (RawAddress*)remote_bdaddr, &prop_name) == BT_STATUS_SUCCESS) { LOG_INFO("%s remote_cod = 0x%08x", __func__, remote_cod); return remote_cod & COD_MASK; return remote_cod; } return 0; Loading @@ -488,6 +488,9 @@ bool check_cod_hid(const RawAddress& bd_addr) { return (get_cod(&bd_addr) & COD_HID_MASK) == COD_HID_MAJOR; } bool check_cod_le_audio(const RawAddress& bd_addr) { return (get_cod(&bd_addr) & COD_CLASS_LE_AUDIO) == COD_CLASS_LE_AUDIO; } /***************************************************************************** * * Function check_sdp_bl Loading Loading @@ -682,6 +685,33 @@ static void btif_update_remote_properties(const RawAddress& bdaddr, properties); } /* If device is LE Audio capable, we prefer LE connection first, this speeds * up LE profile connection, and limits all possible service discovery * ordering issues (first Classic, GATT over SDP, etc) */ static bool is_device_le_audio_capable(const RawAddress bd_addr) { if (!LeAudioClient::IsLeAudioClientRunning() || !check_cod_le_audio(bd_addr)) { return false; } tBT_DEVICE_TYPE tmp_dev_type; tBLE_ADDR_TYPE addr_type = BLE_ADDR_PUBLIC; BTM_ReadDevInfo(bd_addr, &tmp_dev_type, &addr_type); if (tmp_dev_type & BT_DEVICE_TYPE_BLE) { return true; } int device_type = 0; std::string addrstr = bd_addr.ToString(); const char* bdstr = addrstr.c_str(); btif_config_get_int(bdstr, "DevType", &device_type); if ((device_type & BT_DEVICE_TYPE_BLE) == BT_DEVICE_TYPE_BLE) { return true; } return false; } /******************************************************************************* * * Function btif_dm_cb_create_bond Loading @@ -697,6 +727,11 @@ static void btif_dm_cb_create_bond(const RawAddress bd_addr, bool is_hid = check_cod(&bd_addr, COD_HID_POINTING); bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_BONDING); if (transport == BT_TRANSPORT_AUTO && is_device_le_audio_capable(bd_addr)) { LOG_INFO("LE Audio && advertising over LE, use LE transport for Bonding"); transport = BT_TRANSPORT_LE; } int device_type = 0; tBLE_ADDR_TYPE addr_type = BLE_ADDR_PUBLIC; std::string addrstr = bd_addr.ToString(); Loading