Loading system/btif/src/btif_bqr.cc +25 −27 Original line number Original line Diff line number Diff line Loading @@ -24,25 +24,26 @@ #include <cerrno> #include <cerrno> #include <cstdint> #include <cstdint> #include "btif/include/btif_bqr.h" #include "btif/include/btif_common.h" #include "btif/include/btif_storage.h" #include "btif/include/core_callbacks.h" #include "btif/include/stack_manager_t.h" #include "btif/include/stack_manager_t.h" #include "btif_bqr.h" #include "btif_common.h" #include "btif_storage.h" #include "common/leaky_bonded_queue.h" #include "common/leaky_bonded_queue.h" #include "common/postable_context.h" #include "common/postable_context.h" #include "common/time_util.h" #include "common/time_util.h" #include "core_callbacks.h" #include "hardware/bluetooth.h" #include "hci/hci_interface.h" #include "hci/hci_interface.h" #include "hci/hci_packets.h" #include "hci/hci_packets.h" #include "internal_include/bt_trace.h" #include "internal_include/bt_trace.h" #include "main/shim/entry.h" #include "main/shim/entry.h" #include "osi/include/properties.h" #include "osi/include/properties.h" #include "packet/raw_builder.h" #include "packet/raw_builder.h" #include "raw_address.h" #include "stack/btm/btm_dev.h" #include "stack/btm/btm_dev.h" #include "stack/include/bt_types.h" #include "stack/include/bt_types.h" #include "stack/include/btm_ble_api.h" #include "stack/include/btm_ble_api.h" #include "stack/include/btm_client_interface.h" #include "stack/include/btm_client_interface.h" #include "types/raw_address.h" namespace bluetooth { namespace bluetooth { namespace bqr { namespace bqr { Loading Loading @@ -665,7 +666,7 @@ static void AddLinkQualityEventToQueue(uint8_t length, const uint8_t* p_link_qua } } if (!bd_addr.IsEmpty()) { if (!bd_addr.IsEmpty()) { bqrItf->bqr_delivery_event(bd_addr, (uint8_t*)p_link_quality_event, length); bqrItf->bqr_delivery_event(bd_addr, p_link_quality_event, length); } else { } else { log::warn("failed to deliver BQR, bdaddr is empty"); log::warn("failed to deliver BQR, bdaddr is empty"); } } Loading Loading @@ -780,10 +781,7 @@ void DebugDump(int fd) { dprintf(fd, "\n"); dprintf(fd, "\n"); } } static void btif_get_remote_version(const RawAddress& bd_addr, uint8_t& lmp_version, static bt_remote_version_t btif_get_remote_version(const RawAddress& bd_addr) { uint16_t& manufacturer, uint16_t& lmp_sub_version) { bt_property_t prop; bt_remote_version_t info; uint8_t tmp_lmp_ver = 0; uint8_t tmp_lmp_ver = 0; uint16_t tmp_manufacturer = 0; uint16_t tmp_manufacturer = 0; uint16_t tmp_lmp_subver = 0; uint16_t tmp_lmp_subver = 0; Loading @@ -791,21 +789,24 @@ static void btif_get_remote_version(const RawAddress& bd_addr, uint8_t& lmp_vers const bool status = get_btm_client_interface().peer.BTM_ReadRemoteVersion( const bool status = get_btm_client_interface().peer.BTM_ReadRemoteVersion( bd_addr, &tmp_lmp_ver, &tmp_manufacturer, &tmp_lmp_subver); bd_addr, &tmp_lmp_ver, &tmp_manufacturer, &tmp_lmp_subver); if (status && (tmp_lmp_ver || tmp_manufacturer || tmp_lmp_subver)) { if (status && (tmp_lmp_ver || tmp_manufacturer || tmp_lmp_subver)) { lmp_version = tmp_lmp_ver; return { manufacturer = tmp_manufacturer; .version = tmp_lmp_ver, lmp_sub_version = tmp_lmp_subver; .sub_ver = tmp_lmp_subver, return; .manufacturer = tmp_manufacturer, }; } } prop.type = BT_PROPERTY_REMOTE_VERSION_INFO; bt_remote_version_t info{}; prop.len = sizeof(bt_remote_version_t); bt_property_t prop{ prop.val = (void*)&info; .type = BT_PROPERTY_REMOTE_VERSION_INFO, .len = sizeof(bt_remote_version_t), .val = reinterpret_cast<void*>(&info), }; if (btif_storage_get_remote_device_property(&bd_addr, &prop) == BT_STATUS_SUCCESS) { if (btif_storage_get_remote_device_property(&bd_addr, &prop) == BT_STATUS_SUCCESS) { lmp_version = (uint8_t)info.version; return info; manufacturer = (uint16_t)info.manufacturer; lmp_sub_version = (uint16_t)info.sub_ver; } } return {}; } } class BluetoothQualityReportInterfaceImpl : public bluetooth::bqr::BluetoothQualityReportInterface { class BluetoothQualityReportInterfaceImpl : public bluetooth::bqr::BluetoothQualityReportInterface { Loading Loading @@ -836,13 +837,10 @@ class BluetoothQualityReportInterfaceImpl : public bluetooth::bqr::BluetoothQual raw_data.insert(it, kVersion5_0ParamsTotalLen, 0); raw_data.insert(it, kVersion5_0ParamsTotalLen, 0); } } uint8_t lmp_ver = 0; bt_remote_version_t info = btif_get_remote_version(bd_addr); uint16_t lmp_subver = 0; uint16_t manufacturer_id = 0; btif_get_remote_version(bd_addr, lmp_ver, manufacturer_id, lmp_subver); log::info("len: {}, addr: {}, lmp_ver: {}, manufacturer_id: {}, lmp_subver: {}", log::info("len: {}, addr: {}, lmp_ver: {}, manufacturer_id: {}, lmp_subver: {}", bqr_raw_data_len, bd_addr, lmp_ver, manufacturer_id, lmp_subver); bqr_raw_data_len, bd_addr, info.version, info.manufacturer, info.sub_ver); if (callbacks == nullptr) { if (callbacks == nullptr) { log::error("callbacks is nullptr"); log::error("callbacks is nullptr"); Loading @@ -851,8 +849,8 @@ class BluetoothQualityReportInterfaceImpl : public bluetooth::bqr::BluetoothQual do_in_jni_thread( do_in_jni_thread( base::BindOnce(&bluetooth::bqr::BluetoothQualityReportCallbacks::bqr_delivery_callback, base::BindOnce(&bluetooth::bqr::BluetoothQualityReportCallbacks::bqr_delivery_callback, base::Unretained(callbacks), bd_addr, lmp_ver, lmp_subver, base::Unretained(callbacks), bd_addr, info.version, info.sub_ver, manufacturer_id, std::move(raw_data))); info.manufacturer, std::move(raw_data))); } } private: private: Loading Loading
system/btif/src/btif_bqr.cc +25 −27 Original line number Original line Diff line number Diff line Loading @@ -24,25 +24,26 @@ #include <cerrno> #include <cerrno> #include <cstdint> #include <cstdint> #include "btif/include/btif_bqr.h" #include "btif/include/btif_common.h" #include "btif/include/btif_storage.h" #include "btif/include/core_callbacks.h" #include "btif/include/stack_manager_t.h" #include "btif/include/stack_manager_t.h" #include "btif_bqr.h" #include "btif_common.h" #include "btif_storage.h" #include "common/leaky_bonded_queue.h" #include "common/leaky_bonded_queue.h" #include "common/postable_context.h" #include "common/postable_context.h" #include "common/time_util.h" #include "common/time_util.h" #include "core_callbacks.h" #include "hardware/bluetooth.h" #include "hci/hci_interface.h" #include "hci/hci_interface.h" #include "hci/hci_packets.h" #include "hci/hci_packets.h" #include "internal_include/bt_trace.h" #include "internal_include/bt_trace.h" #include "main/shim/entry.h" #include "main/shim/entry.h" #include "osi/include/properties.h" #include "osi/include/properties.h" #include "packet/raw_builder.h" #include "packet/raw_builder.h" #include "raw_address.h" #include "stack/btm/btm_dev.h" #include "stack/btm/btm_dev.h" #include "stack/include/bt_types.h" #include "stack/include/bt_types.h" #include "stack/include/btm_ble_api.h" #include "stack/include/btm_ble_api.h" #include "stack/include/btm_client_interface.h" #include "stack/include/btm_client_interface.h" #include "types/raw_address.h" namespace bluetooth { namespace bluetooth { namespace bqr { namespace bqr { Loading Loading @@ -665,7 +666,7 @@ static void AddLinkQualityEventToQueue(uint8_t length, const uint8_t* p_link_qua } } if (!bd_addr.IsEmpty()) { if (!bd_addr.IsEmpty()) { bqrItf->bqr_delivery_event(bd_addr, (uint8_t*)p_link_quality_event, length); bqrItf->bqr_delivery_event(bd_addr, p_link_quality_event, length); } else { } else { log::warn("failed to deliver BQR, bdaddr is empty"); log::warn("failed to deliver BQR, bdaddr is empty"); } } Loading Loading @@ -780,10 +781,7 @@ void DebugDump(int fd) { dprintf(fd, "\n"); dprintf(fd, "\n"); } } static void btif_get_remote_version(const RawAddress& bd_addr, uint8_t& lmp_version, static bt_remote_version_t btif_get_remote_version(const RawAddress& bd_addr) { uint16_t& manufacturer, uint16_t& lmp_sub_version) { bt_property_t prop; bt_remote_version_t info; uint8_t tmp_lmp_ver = 0; uint8_t tmp_lmp_ver = 0; uint16_t tmp_manufacturer = 0; uint16_t tmp_manufacturer = 0; uint16_t tmp_lmp_subver = 0; uint16_t tmp_lmp_subver = 0; Loading @@ -791,21 +789,24 @@ static void btif_get_remote_version(const RawAddress& bd_addr, uint8_t& lmp_vers const bool status = get_btm_client_interface().peer.BTM_ReadRemoteVersion( const bool status = get_btm_client_interface().peer.BTM_ReadRemoteVersion( bd_addr, &tmp_lmp_ver, &tmp_manufacturer, &tmp_lmp_subver); bd_addr, &tmp_lmp_ver, &tmp_manufacturer, &tmp_lmp_subver); if (status && (tmp_lmp_ver || tmp_manufacturer || tmp_lmp_subver)) { if (status && (tmp_lmp_ver || tmp_manufacturer || tmp_lmp_subver)) { lmp_version = tmp_lmp_ver; return { manufacturer = tmp_manufacturer; .version = tmp_lmp_ver, lmp_sub_version = tmp_lmp_subver; .sub_ver = tmp_lmp_subver, return; .manufacturer = tmp_manufacturer, }; } } prop.type = BT_PROPERTY_REMOTE_VERSION_INFO; bt_remote_version_t info{}; prop.len = sizeof(bt_remote_version_t); bt_property_t prop{ prop.val = (void*)&info; .type = BT_PROPERTY_REMOTE_VERSION_INFO, .len = sizeof(bt_remote_version_t), .val = reinterpret_cast<void*>(&info), }; if (btif_storage_get_remote_device_property(&bd_addr, &prop) == BT_STATUS_SUCCESS) { if (btif_storage_get_remote_device_property(&bd_addr, &prop) == BT_STATUS_SUCCESS) { lmp_version = (uint8_t)info.version; return info; manufacturer = (uint16_t)info.manufacturer; lmp_sub_version = (uint16_t)info.sub_ver; } } return {}; } } class BluetoothQualityReportInterfaceImpl : public bluetooth::bqr::BluetoothQualityReportInterface { class BluetoothQualityReportInterfaceImpl : public bluetooth::bqr::BluetoothQualityReportInterface { Loading Loading @@ -836,13 +837,10 @@ class BluetoothQualityReportInterfaceImpl : public bluetooth::bqr::BluetoothQual raw_data.insert(it, kVersion5_0ParamsTotalLen, 0); raw_data.insert(it, kVersion5_0ParamsTotalLen, 0); } } uint8_t lmp_ver = 0; bt_remote_version_t info = btif_get_remote_version(bd_addr); uint16_t lmp_subver = 0; uint16_t manufacturer_id = 0; btif_get_remote_version(bd_addr, lmp_ver, manufacturer_id, lmp_subver); log::info("len: {}, addr: {}, lmp_ver: {}, manufacturer_id: {}, lmp_subver: {}", log::info("len: {}, addr: {}, lmp_ver: {}, manufacturer_id: {}, lmp_subver: {}", bqr_raw_data_len, bd_addr, lmp_ver, manufacturer_id, lmp_subver); bqr_raw_data_len, bd_addr, info.version, info.manufacturer, info.sub_ver); if (callbacks == nullptr) { if (callbacks == nullptr) { log::error("callbacks is nullptr"); log::error("callbacks is nullptr"); Loading @@ -851,8 +849,8 @@ class BluetoothQualityReportInterfaceImpl : public bluetooth::bqr::BluetoothQual do_in_jni_thread( do_in_jni_thread( base::BindOnce(&bluetooth::bqr::BluetoothQualityReportCallbacks::bqr_delivery_callback, base::BindOnce(&bluetooth::bqr::BluetoothQualityReportCallbacks::bqr_delivery_callback, base::Unretained(callbacks), bd_addr, lmp_ver, lmp_subver, base::Unretained(callbacks), bd_addr, info.version, info.sub_ver, manufacturer_id, std::move(raw_data))); info.manufacturer, std::move(raw_data))); } } private: private: Loading