Loading system/btif/include/btif_dm.h +1 −1 Original line number Diff line number Diff line Loading @@ -139,7 +139,7 @@ void btif_dm_get_ble_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK* p_key_mask, Octet16* p_er, tBTA_BLE_LOCAL_ID_KEYS* p_id_keys); void btif_dm_update_ble_remote_properties(const RawAddress& bd_addr, BD_NAME bd_name, BD_NAME bd_name, DEV_CLASS dev_class, tBT_DEVICE_TYPE dev_type); bool check_cod_hid(const RawAddress& bd_addr); Loading system/btif/src/btif_dm.cc +11 −9 Original line number Diff line number Diff line Loading @@ -3279,9 +3279,9 @@ static void btif_dm_ble_key_notif_evt(tBTA_DM_SP_KEY_NOTIF* p_ssp_key_notif) { if (!btif_get_device_type(p_ssp_key_notif->bd_addr, &dev_type)) { dev_type = BT_DEVICE_TYPE_BLE; } btif_dm_update_ble_remote_properties(p_ssp_key_notif->bd_addr, p_ssp_key_notif->bd_name, (tBT_DEVICE_TYPE)dev_type); btif_dm_update_ble_remote_properties( p_ssp_key_notif->bd_addr, p_ssp_key_notif->bd_name, nullptr /* dev_class */, (tBT_DEVICE_TYPE)dev_type); bd_addr = p_ssp_key_notif->bd_addr; memcpy(bd_name.name, p_ssp_key_notif->bd_name, BD_NAME_LEN); bd_name.name[BD_NAME_LEN] = '\0'; Loading Loading @@ -3516,6 +3516,7 @@ static void btif_dm_ble_sec_req_evt(tBTA_DM_BLE_SEC_REQ* p_ble_req, dev_type = BT_DEVICE_TYPE_BLE; } btif_dm_update_ble_remote_properties(p_ble_req->bd_addr, p_ble_req->bd_name, nullptr /* dev_class */, (tBT_DEVICE_TYPE)dev_type); RawAddress bd_addr = p_ble_req->bd_addr; Loading Loading @@ -3555,6 +3556,7 @@ static void btif_dm_ble_passkey_req_evt(tBTA_DM_PIN_REQ* p_pin_req) { dev_type = BT_DEVICE_TYPE_BLE; } btif_dm_update_ble_remote_properties(p_pin_req->bd_addr, p_pin_req->bd_name, nullptr /* dev_class */, (tBT_DEVICE_TYPE)dev_type); RawAddress bd_addr = p_pin_req->bd_addr; Loading @@ -3575,7 +3577,7 @@ static void btif_dm_ble_key_nc_req_evt(tBTA_DM_SP_KEY_NOTIF* p_notif_req) { /* Remote name update */ btif_update_remote_properties(p_notif_req->bd_addr, p_notif_req->bd_name, NULL, BT_DEVICE_TYPE_BLE); nullptr /* dev_class */, BT_DEVICE_TYPE_BLE); RawAddress bd_addr = p_notif_req->bd_addr; Loading Loading @@ -3614,7 +3616,7 @@ static void btif_dm_ble_oob_req_evt(tBTA_DM_SP_RMT_OOB* req_oob_type) { /* Remote name update */ btif_update_remote_properties(req_oob_type->bd_addr, req_oob_type->bd_name, NULL, BT_DEVICE_TYPE_BLE); nullptr /* dev_class */, BT_DEVICE_TYPE_BLE); bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_BONDING); pairing_cb.is_ssp = false; Loading Loading @@ -3671,8 +3673,8 @@ static void btif_dm_ble_sc_oob_req_evt(tBTA_DM_SP_RMT_OOB* req_oob_type) { /* Remote name update */ btif_update_remote_properties(req_oob_type->bd_addr, oob_data_to_use.device_name, NULL, BT_DEVICE_TYPE_BLE); oob_data_to_use.device_name, nullptr /* dev_class */, BT_DEVICE_TYPE_BLE); bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_BONDING); pairing_cb.is_ssp = false; Loading @@ -3684,9 +3686,9 @@ static void btif_dm_ble_sc_oob_req_evt(tBTA_DM_SP_RMT_OOB* req_oob_type) { } void btif_dm_update_ble_remote_properties(const RawAddress& bd_addr, BD_NAME bd_name, BD_NAME bd_name, DEV_CLASS dev_class, tBT_DEVICE_TYPE dev_type) { btif_update_remote_properties(bd_addr, bd_name, NULL, dev_type); btif_update_remote_properties(bd_addr, bd_name, dev_class, dev_type); } void btif_dm_on_disable() { Loading system/main/shim/le_scanning_manager.cc +18 −6 Original line number Diff line number Diff line Loading @@ -126,13 +126,17 @@ void btm_ble_process_adv_pkt_cont_for_inquiry( uint8_t advertising_sid, int8_t tx_power, int8_t rssi, uint16_t periodic_adv_int, std::vector<uint8_t> advertising_data); void btif_dm_update_ble_remote_properties(const RawAddress& bd_addr, extern void btif_dm_update_ble_remote_properties(const RawAddress& bd_addr, BD_NAME bd_name, DEV_CLASS dev_class, tBT_DEVICE_TYPE dev_type); void btm_ble_process_adv_addr(RawAddress& raw_address, tBLE_ADDR_TYPE* address_type); extern bool btm_ble_get_appearance_as_cod(std::vector<uint8_t> const& data, DEV_CLASS dev_class); using bluetooth::shim::BleScannerInterfaceImpl; void BleScannerInterfaceImpl::Init() { Loading Loading @@ -758,6 +762,8 @@ void BleScannerInterfaceImpl::handle_remote_properties( advertising_data, HCI_EIR_SHORTENED_LOCAL_NAME_TYPE, &remote_name_len); } bt_bdname_t bdname = {0}; // update device name if (p_eir_remote_name) { if (!address_cache_.find(bd_addr)) { Loading @@ -772,15 +778,21 @@ void BleScannerInterfaceImpl::handle_remote_properties( return; } bt_bdname_t bdname; memcpy(bdname.name, p_eir_remote_name, remote_name_len); if (remote_name_len < BD_NAME_LEN + 1) bdname.name[remote_name_len] = '\0'; btif_dm_update_ble_remote_properties(bd_addr, bdname.name, device_type); btif_dm_update_ble_remote_properties(bd_addr, bdname.name, NULL, device_type); } } } DEV_CLASS dev_class; if (btm_ble_get_appearance_as_cod(advertising_data, dev_class)) { btif_dm_update_ble_remote_properties(bd_addr, bdname.name, dev_class, device_type); } auto* storage_module = bluetooth::shim::GetStorage(); bluetooth::hci::Address address = ToGdAddress(bd_addr); Loading system/stack/btm/btm_ble_gap.cc +37 −29 Original line number Diff line number Diff line Loading @@ -2375,6 +2375,42 @@ static void btm_ble_appearance_to_cod(uint16_t appearance, uint8_t* dev_class) { }; } bool btm_ble_get_appearance_as_cod(std::vector<uint8_t> const& data, DEV_CLASS dev_class) { /* Check to see the BLE device has the Appearance UUID in the advertising * data. If it does then try to convert the appearance value to a class of * device value Fluoride can use. Otherwise fall back to trying to infer if * it is a HID device based on the service class. */ uint8_t len; const uint8_t* p_uuid16 = AdvertiseDataParser::GetFieldByType( data, BTM_BLE_AD_TYPE_APPEARANCE, &len); if (p_uuid16 && len == 2) { btm_ble_appearance_to_cod((uint16_t)p_uuid16[0] | (p_uuid16[1] << 8), dev_class); return true; } p_uuid16 = AdvertiseDataParser::GetFieldByType( data, BTM_BLE_AD_TYPE_16SRV_CMPL, &len); if (p_uuid16 == NULL) { return false; } for (uint8_t i = 0; i + 2 <= len; i = i + 2) { /* if this BLE device supports HID over LE, set HID Major in class of * device */ if ((p_uuid16[i] | (p_uuid16[i + 1] << 8)) == UUID_SERVCLASS_LE_HID) { dev_class[0] = 0; dev_class[1] = BTM_COD_MAJOR_PERIPHERAL; dev_class[2] = 0; return true; } } return false; } /** * Update adv packet information into inquiry result. */ Loading Loading @@ -2423,35 +2459,7 @@ void btm_ble_update_inq_result(tINQ_DB_ENT* p_i, uint8_t addr_type, p_cur->flag = *p_flag; } /* Check to see the BLE device has the Appearance UUID in the advertising * data. If it does * then try to convert the appearance value to a class of device value * Bluedroid can use. * Otherwise fall back to trying to infer if it is a HID device based on the * service class. */ const uint8_t* p_uuid16 = AdvertiseDataParser::GetFieldByType( data, BTM_BLE_AD_TYPE_APPEARANCE, &len); if (p_uuid16 && len == 2) { btm_ble_appearance_to_cod((uint16_t)p_uuid16[0] | (p_uuid16[1] << 8), p_cur->dev_class); } else { p_uuid16 = AdvertiseDataParser::GetFieldByType( data, BTM_BLE_AD_TYPE_16SRV_CMPL, &len); if (p_uuid16 != NULL) { uint8_t i; for (i = 0; i + 2 <= len; i = i + 2) { /* if this BLE device support HID over LE, set HID Major in class of * device */ if ((p_uuid16[i] | (p_uuid16[i + 1] << 8)) == UUID_SERVCLASS_LE_HID) { p_cur->dev_class[0] = 0; p_cur->dev_class[1] = BTM_COD_MAJOR_PERIPHERAL; p_cur->dev_class[2] = 0; break; } } } } btm_ble_get_appearance_as_cod(data, p_cur->dev_class); const uint8_t* p_rsi = AdvertiseDataParser::GetFieldByType(data, BTM_BLE_AD_TYPE_RSI, &len); Loading system/test/mock/mock_btif_dm.cc +1 −1 Original line number Diff line number Diff line Loading @@ -141,7 +141,7 @@ void btif_dm_ssp_reply(const RawAddress bd_addr, bt_ssp_variant_t variant, } void btif_dm_start_discovery(void) { inc_func_call_count(__func__); } void btif_dm_update_ble_remote_properties(const RawAddress& bd_addr, BD_NAME bd_name, BD_NAME bd_name, DEV_CLASS dev_class, tBT_DEVICE_TYPE dev_type) { inc_func_call_count(__func__); } Loading Loading
system/btif/include/btif_dm.h +1 −1 Original line number Diff line number Diff line Loading @@ -139,7 +139,7 @@ void btif_dm_get_ble_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK* p_key_mask, Octet16* p_er, tBTA_BLE_LOCAL_ID_KEYS* p_id_keys); void btif_dm_update_ble_remote_properties(const RawAddress& bd_addr, BD_NAME bd_name, BD_NAME bd_name, DEV_CLASS dev_class, tBT_DEVICE_TYPE dev_type); bool check_cod_hid(const RawAddress& bd_addr); Loading
system/btif/src/btif_dm.cc +11 −9 Original line number Diff line number Diff line Loading @@ -3279,9 +3279,9 @@ static void btif_dm_ble_key_notif_evt(tBTA_DM_SP_KEY_NOTIF* p_ssp_key_notif) { if (!btif_get_device_type(p_ssp_key_notif->bd_addr, &dev_type)) { dev_type = BT_DEVICE_TYPE_BLE; } btif_dm_update_ble_remote_properties(p_ssp_key_notif->bd_addr, p_ssp_key_notif->bd_name, (tBT_DEVICE_TYPE)dev_type); btif_dm_update_ble_remote_properties( p_ssp_key_notif->bd_addr, p_ssp_key_notif->bd_name, nullptr /* dev_class */, (tBT_DEVICE_TYPE)dev_type); bd_addr = p_ssp_key_notif->bd_addr; memcpy(bd_name.name, p_ssp_key_notif->bd_name, BD_NAME_LEN); bd_name.name[BD_NAME_LEN] = '\0'; Loading Loading @@ -3516,6 +3516,7 @@ static void btif_dm_ble_sec_req_evt(tBTA_DM_BLE_SEC_REQ* p_ble_req, dev_type = BT_DEVICE_TYPE_BLE; } btif_dm_update_ble_remote_properties(p_ble_req->bd_addr, p_ble_req->bd_name, nullptr /* dev_class */, (tBT_DEVICE_TYPE)dev_type); RawAddress bd_addr = p_ble_req->bd_addr; Loading Loading @@ -3555,6 +3556,7 @@ static void btif_dm_ble_passkey_req_evt(tBTA_DM_PIN_REQ* p_pin_req) { dev_type = BT_DEVICE_TYPE_BLE; } btif_dm_update_ble_remote_properties(p_pin_req->bd_addr, p_pin_req->bd_name, nullptr /* dev_class */, (tBT_DEVICE_TYPE)dev_type); RawAddress bd_addr = p_pin_req->bd_addr; Loading @@ -3575,7 +3577,7 @@ static void btif_dm_ble_key_nc_req_evt(tBTA_DM_SP_KEY_NOTIF* p_notif_req) { /* Remote name update */ btif_update_remote_properties(p_notif_req->bd_addr, p_notif_req->bd_name, NULL, BT_DEVICE_TYPE_BLE); nullptr /* dev_class */, BT_DEVICE_TYPE_BLE); RawAddress bd_addr = p_notif_req->bd_addr; Loading Loading @@ -3614,7 +3616,7 @@ static void btif_dm_ble_oob_req_evt(tBTA_DM_SP_RMT_OOB* req_oob_type) { /* Remote name update */ btif_update_remote_properties(req_oob_type->bd_addr, req_oob_type->bd_name, NULL, BT_DEVICE_TYPE_BLE); nullptr /* dev_class */, BT_DEVICE_TYPE_BLE); bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_BONDING); pairing_cb.is_ssp = false; Loading Loading @@ -3671,8 +3673,8 @@ static void btif_dm_ble_sc_oob_req_evt(tBTA_DM_SP_RMT_OOB* req_oob_type) { /* Remote name update */ btif_update_remote_properties(req_oob_type->bd_addr, oob_data_to_use.device_name, NULL, BT_DEVICE_TYPE_BLE); oob_data_to_use.device_name, nullptr /* dev_class */, BT_DEVICE_TYPE_BLE); bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_BONDING); pairing_cb.is_ssp = false; Loading @@ -3684,9 +3686,9 @@ static void btif_dm_ble_sc_oob_req_evt(tBTA_DM_SP_RMT_OOB* req_oob_type) { } void btif_dm_update_ble_remote_properties(const RawAddress& bd_addr, BD_NAME bd_name, BD_NAME bd_name, DEV_CLASS dev_class, tBT_DEVICE_TYPE dev_type) { btif_update_remote_properties(bd_addr, bd_name, NULL, dev_type); btif_update_remote_properties(bd_addr, bd_name, dev_class, dev_type); } void btif_dm_on_disable() { Loading
system/main/shim/le_scanning_manager.cc +18 −6 Original line number Diff line number Diff line Loading @@ -126,13 +126,17 @@ void btm_ble_process_adv_pkt_cont_for_inquiry( uint8_t advertising_sid, int8_t tx_power, int8_t rssi, uint16_t periodic_adv_int, std::vector<uint8_t> advertising_data); void btif_dm_update_ble_remote_properties(const RawAddress& bd_addr, extern void btif_dm_update_ble_remote_properties(const RawAddress& bd_addr, BD_NAME bd_name, DEV_CLASS dev_class, tBT_DEVICE_TYPE dev_type); void btm_ble_process_adv_addr(RawAddress& raw_address, tBLE_ADDR_TYPE* address_type); extern bool btm_ble_get_appearance_as_cod(std::vector<uint8_t> const& data, DEV_CLASS dev_class); using bluetooth::shim::BleScannerInterfaceImpl; void BleScannerInterfaceImpl::Init() { Loading Loading @@ -758,6 +762,8 @@ void BleScannerInterfaceImpl::handle_remote_properties( advertising_data, HCI_EIR_SHORTENED_LOCAL_NAME_TYPE, &remote_name_len); } bt_bdname_t bdname = {0}; // update device name if (p_eir_remote_name) { if (!address_cache_.find(bd_addr)) { Loading @@ -772,15 +778,21 @@ void BleScannerInterfaceImpl::handle_remote_properties( return; } bt_bdname_t bdname; memcpy(bdname.name, p_eir_remote_name, remote_name_len); if (remote_name_len < BD_NAME_LEN + 1) bdname.name[remote_name_len] = '\0'; btif_dm_update_ble_remote_properties(bd_addr, bdname.name, device_type); btif_dm_update_ble_remote_properties(bd_addr, bdname.name, NULL, device_type); } } } DEV_CLASS dev_class; if (btm_ble_get_appearance_as_cod(advertising_data, dev_class)) { btif_dm_update_ble_remote_properties(bd_addr, bdname.name, dev_class, device_type); } auto* storage_module = bluetooth::shim::GetStorage(); bluetooth::hci::Address address = ToGdAddress(bd_addr); Loading
system/stack/btm/btm_ble_gap.cc +37 −29 Original line number Diff line number Diff line Loading @@ -2375,6 +2375,42 @@ static void btm_ble_appearance_to_cod(uint16_t appearance, uint8_t* dev_class) { }; } bool btm_ble_get_appearance_as_cod(std::vector<uint8_t> const& data, DEV_CLASS dev_class) { /* Check to see the BLE device has the Appearance UUID in the advertising * data. If it does then try to convert the appearance value to a class of * device value Fluoride can use. Otherwise fall back to trying to infer if * it is a HID device based on the service class. */ uint8_t len; const uint8_t* p_uuid16 = AdvertiseDataParser::GetFieldByType( data, BTM_BLE_AD_TYPE_APPEARANCE, &len); if (p_uuid16 && len == 2) { btm_ble_appearance_to_cod((uint16_t)p_uuid16[0] | (p_uuid16[1] << 8), dev_class); return true; } p_uuid16 = AdvertiseDataParser::GetFieldByType( data, BTM_BLE_AD_TYPE_16SRV_CMPL, &len); if (p_uuid16 == NULL) { return false; } for (uint8_t i = 0; i + 2 <= len; i = i + 2) { /* if this BLE device supports HID over LE, set HID Major in class of * device */ if ((p_uuid16[i] | (p_uuid16[i + 1] << 8)) == UUID_SERVCLASS_LE_HID) { dev_class[0] = 0; dev_class[1] = BTM_COD_MAJOR_PERIPHERAL; dev_class[2] = 0; return true; } } return false; } /** * Update adv packet information into inquiry result. */ Loading Loading @@ -2423,35 +2459,7 @@ void btm_ble_update_inq_result(tINQ_DB_ENT* p_i, uint8_t addr_type, p_cur->flag = *p_flag; } /* Check to see the BLE device has the Appearance UUID in the advertising * data. If it does * then try to convert the appearance value to a class of device value * Bluedroid can use. * Otherwise fall back to trying to infer if it is a HID device based on the * service class. */ const uint8_t* p_uuid16 = AdvertiseDataParser::GetFieldByType( data, BTM_BLE_AD_TYPE_APPEARANCE, &len); if (p_uuid16 && len == 2) { btm_ble_appearance_to_cod((uint16_t)p_uuid16[0] | (p_uuid16[1] << 8), p_cur->dev_class); } else { p_uuid16 = AdvertiseDataParser::GetFieldByType( data, BTM_BLE_AD_TYPE_16SRV_CMPL, &len); if (p_uuid16 != NULL) { uint8_t i; for (i = 0; i + 2 <= len; i = i + 2) { /* if this BLE device support HID over LE, set HID Major in class of * device */ if ((p_uuid16[i] | (p_uuid16[i + 1] << 8)) == UUID_SERVCLASS_LE_HID) { p_cur->dev_class[0] = 0; p_cur->dev_class[1] = BTM_COD_MAJOR_PERIPHERAL; p_cur->dev_class[2] = 0; break; } } } } btm_ble_get_appearance_as_cod(data, p_cur->dev_class); const uint8_t* p_rsi = AdvertiseDataParser::GetFieldByType(data, BTM_BLE_AD_TYPE_RSI, &len); Loading
system/test/mock/mock_btif_dm.cc +1 −1 Original line number Diff line number Diff line Loading @@ -141,7 +141,7 @@ void btif_dm_ssp_reply(const RawAddress bd_addr, bt_ssp_variant_t variant, } void btif_dm_start_discovery(void) { inc_func_call_count(__func__); } void btif_dm_update_ble_remote_properties(const RawAddress& bd_addr, BD_NAME bd_name, BD_NAME bd_name, DEV_CLASS dev_class, tBT_DEVICE_TYPE dev_type) { inc_func_call_count(__func__); } Loading