Loading system/bta/ras/ras_client.cc +5 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include "stack/include/bt_types.h" #include "stack/include/btm_ble_addr.h" #include "stack/include/gap_api.h" #include "stack/include/main_thread.h" using namespace bluetooth; using namespace ::ras; Loading Loading @@ -102,6 +103,10 @@ public: }; void Initialize() override { do_in_main_thread(base::BindOnce(&RasClientImpl::do_initialize, base::Unretained(this))); } void do_initialize() { auto controller = bluetooth::shim::GetController(); if (controller && !controller->SupportsBleChannelSounding()) { log::info("controller does not support channel sounding."); Loading system/bta/ras/ras_server.cc +5 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include "os/logging/log_adapter.h" #include "stack/include/bt_types.h" #include "stack/include/btm_ble_addr.h" #include "stack/include/main_thread.h" using namespace bluetooth; using namespace ::ras; Loading Loading @@ -77,6 +78,10 @@ public: }; void Initialize() override { do_in_main_thread(base::BindOnce(&RasServerImpl::do_initialize, base::Unretained(this))); } void do_initialize() { auto controller = bluetooth::shim::GetController(); if (controller && !controller->SupportsBleChannelSounding()) { log::info("controller does not support channel sounding."); Loading system/main/shim/distance_measurement_manager.cc +25 −17 Original line number Diff line number Diff line Loading @@ -41,8 +41,10 @@ public: void Init() { // Register callback bluetooth::shim::GetDistanceMeasurementManager()->RegisterDistanceMeasurementCallbacks(this); bluetooth::ras::GetRasServer()->RegisterCallbacks(this); bluetooth::ras::GetRasClient()->RegisterCallbacks(this); do_in_main_thread(base::BindOnce(&bluetooth::ras::RasServer::RegisterCallbacks, base::Unretained(bluetooth::ras::GetRasServer()), this)); do_in_main_thread(base::BindOnce(&bluetooth::ras::RasClient::RegisterCallbacks, base::Unretained(bluetooth::ras::GetRasClient()), this)); } /** Loading @@ -50,7 +52,8 @@ public: * @param bd_addr could be random, rpa or identity address. * @return BLE ACL handle */ uint16_t GetConnectionHandleAndRole(const RawAddress& bd_addr, hci::Role* hci_role = nullptr) { static uint16_t GetConnectionHandleAndRole(const RawAddress& bd_addr, hci::Role* hci_role = nullptr) { tBTM_SEC_DEV_REC* p_sec_dev_rec = btm_find_dev(bd_addr); if (p_sec_dev_rec != nullptr) { if (hci_role != nullptr) { Loading @@ -71,8 +74,7 @@ public: } void DoStartDistanceMeasurement(RawAddress identity_addr, uint16_t interval, uint8_t method) { DistanceMeasurementMethod distance_measurement_method = static_cast<DistanceMeasurementMethod>(method); auto distance_measurement_method = static_cast<DistanceMeasurementMethod>(method); hci::Role local_hci_role; uint16_t connection_handle = GetConnectionHandleAndRole(identity_addr, &local_hci_role); bluetooth::shim::GetDistanceMeasurementManager()->StartDistanceMeasurement( Loading Loading @@ -134,13 +136,15 @@ public: } void OnRasFragmentReady(bluetooth::hci::Address address, uint16_t procedure_counter, bool is_last, std::vector<uint8_t> raw_data) { bluetooth::ras::GetRasServer()->PushProcedureData(bluetooth::ToRawAddress(address), procedure_counter, is_last, raw_data); std::vector<uint8_t> raw_data) override { do_in_main_thread(base::BindOnce(&bluetooth::ras::RasServer::PushProcedureData, base::Unretained(bluetooth::ras::GetRasServer()), bluetooth::ToRawAddress(address), procedure_counter, is_last, std::move(raw_data))); } void OnVendorSpecificCharacteristics(std::vector<bluetooth::hal::VendorSpecificCharacteristic> vendor_specific_characteristics) { vendor_specific_characteristics) override { std::vector<bluetooth::ras::VendorSpecificCharacteristic> ras_vendor_specific_characteristics; for (auto& characteristic : vendor_specific_characteristics) { bluetooth::ras::VendorSpecificCharacteristic vendor_specific_characteristic; Loading @@ -149,13 +153,14 @@ public: vendor_specific_characteristic.value_ = characteristic.value_; ras_vendor_specific_characteristics.emplace_back(vendor_specific_characteristic); } bluetooth::ras::GetRasServer()->SetVendorSpecificCharacteristic( ras_vendor_specific_characteristics); do_in_main_thread(base::BindOnce(&bluetooth::ras::RasServer::SetVendorSpecificCharacteristic, base::Unretained(bluetooth::ras::GetRasServer()), std::move(ras_vendor_specific_characteristics))); } void OnVendorSpecificReply(bluetooth::hci::Address address, std::vector<bluetooth::hal::VendorSpecificCharacteristic> vendor_specific_characteristics) { vendor_specific_characteristics) override { std::vector<bluetooth::ras::VendorSpecificCharacteristic> ras_vendor_specific_characteristics; for (auto& characteristic : vendor_specific_characteristics) { bluetooth::ras::VendorSpecificCharacteristic vendor_specific_characteristic; Loading @@ -164,13 +169,16 @@ public: vendor_specific_characteristic.value_ = characteristic.value_; ras_vendor_specific_characteristics.emplace_back(vendor_specific_characteristic); } bluetooth::ras::GetRasClient()->SendVendorSpecificReply(bluetooth::ToRawAddress(address), ras_vendor_specific_characteristics); do_in_main_thread(base::BindOnce(&bluetooth::ras::RasClient::SendVendorSpecificReply, base::Unretained(bluetooth::ras::GetRasClient()), bluetooth::ToRawAddress(address), std::move(ras_vendor_specific_characteristics))); } void OnHandleVendorSpecificReplyComplete(bluetooth::hci::Address address, bool success) { bluetooth::ras::GetRasServer()->HandleVendorSpecificReplyComplete( bluetooth::ToRawAddress(address), success); void OnHandleVendorSpecificReplyComplete(bluetooth::hci::Address address, bool success) override { do_in_main_thread(base::BindOnce(&bluetooth::ras::RasServer::HandleVendorSpecificReplyComplete, base::Unretained(bluetooth::ras::GetRasServer()), bluetooth::ToRawAddress(address), success)); } // Must be called from main_thread Loading Loading
system/bta/ras/ras_client.cc +5 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include "stack/include/bt_types.h" #include "stack/include/btm_ble_addr.h" #include "stack/include/gap_api.h" #include "stack/include/main_thread.h" using namespace bluetooth; using namespace ::ras; Loading Loading @@ -102,6 +103,10 @@ public: }; void Initialize() override { do_in_main_thread(base::BindOnce(&RasClientImpl::do_initialize, base::Unretained(this))); } void do_initialize() { auto controller = bluetooth::shim::GetController(); if (controller && !controller->SupportsBleChannelSounding()) { log::info("controller does not support channel sounding."); Loading
system/bta/ras/ras_server.cc +5 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include "os/logging/log_adapter.h" #include "stack/include/bt_types.h" #include "stack/include/btm_ble_addr.h" #include "stack/include/main_thread.h" using namespace bluetooth; using namespace ::ras; Loading Loading @@ -77,6 +78,10 @@ public: }; void Initialize() override { do_in_main_thread(base::BindOnce(&RasServerImpl::do_initialize, base::Unretained(this))); } void do_initialize() { auto controller = bluetooth::shim::GetController(); if (controller && !controller->SupportsBleChannelSounding()) { log::info("controller does not support channel sounding."); Loading
system/main/shim/distance_measurement_manager.cc +25 −17 Original line number Diff line number Diff line Loading @@ -41,8 +41,10 @@ public: void Init() { // Register callback bluetooth::shim::GetDistanceMeasurementManager()->RegisterDistanceMeasurementCallbacks(this); bluetooth::ras::GetRasServer()->RegisterCallbacks(this); bluetooth::ras::GetRasClient()->RegisterCallbacks(this); do_in_main_thread(base::BindOnce(&bluetooth::ras::RasServer::RegisterCallbacks, base::Unretained(bluetooth::ras::GetRasServer()), this)); do_in_main_thread(base::BindOnce(&bluetooth::ras::RasClient::RegisterCallbacks, base::Unretained(bluetooth::ras::GetRasClient()), this)); } /** Loading @@ -50,7 +52,8 @@ public: * @param bd_addr could be random, rpa or identity address. * @return BLE ACL handle */ uint16_t GetConnectionHandleAndRole(const RawAddress& bd_addr, hci::Role* hci_role = nullptr) { static uint16_t GetConnectionHandleAndRole(const RawAddress& bd_addr, hci::Role* hci_role = nullptr) { tBTM_SEC_DEV_REC* p_sec_dev_rec = btm_find_dev(bd_addr); if (p_sec_dev_rec != nullptr) { if (hci_role != nullptr) { Loading @@ -71,8 +74,7 @@ public: } void DoStartDistanceMeasurement(RawAddress identity_addr, uint16_t interval, uint8_t method) { DistanceMeasurementMethod distance_measurement_method = static_cast<DistanceMeasurementMethod>(method); auto distance_measurement_method = static_cast<DistanceMeasurementMethod>(method); hci::Role local_hci_role; uint16_t connection_handle = GetConnectionHandleAndRole(identity_addr, &local_hci_role); bluetooth::shim::GetDistanceMeasurementManager()->StartDistanceMeasurement( Loading Loading @@ -134,13 +136,15 @@ public: } void OnRasFragmentReady(bluetooth::hci::Address address, uint16_t procedure_counter, bool is_last, std::vector<uint8_t> raw_data) { bluetooth::ras::GetRasServer()->PushProcedureData(bluetooth::ToRawAddress(address), procedure_counter, is_last, raw_data); std::vector<uint8_t> raw_data) override { do_in_main_thread(base::BindOnce(&bluetooth::ras::RasServer::PushProcedureData, base::Unretained(bluetooth::ras::GetRasServer()), bluetooth::ToRawAddress(address), procedure_counter, is_last, std::move(raw_data))); } void OnVendorSpecificCharacteristics(std::vector<bluetooth::hal::VendorSpecificCharacteristic> vendor_specific_characteristics) { vendor_specific_characteristics) override { std::vector<bluetooth::ras::VendorSpecificCharacteristic> ras_vendor_specific_characteristics; for (auto& characteristic : vendor_specific_characteristics) { bluetooth::ras::VendorSpecificCharacteristic vendor_specific_characteristic; Loading @@ -149,13 +153,14 @@ public: vendor_specific_characteristic.value_ = characteristic.value_; ras_vendor_specific_characteristics.emplace_back(vendor_specific_characteristic); } bluetooth::ras::GetRasServer()->SetVendorSpecificCharacteristic( ras_vendor_specific_characteristics); do_in_main_thread(base::BindOnce(&bluetooth::ras::RasServer::SetVendorSpecificCharacteristic, base::Unretained(bluetooth::ras::GetRasServer()), std::move(ras_vendor_specific_characteristics))); } void OnVendorSpecificReply(bluetooth::hci::Address address, std::vector<bluetooth::hal::VendorSpecificCharacteristic> vendor_specific_characteristics) { vendor_specific_characteristics) override { std::vector<bluetooth::ras::VendorSpecificCharacteristic> ras_vendor_specific_characteristics; for (auto& characteristic : vendor_specific_characteristics) { bluetooth::ras::VendorSpecificCharacteristic vendor_specific_characteristic; Loading @@ -164,13 +169,16 @@ public: vendor_specific_characteristic.value_ = characteristic.value_; ras_vendor_specific_characteristics.emplace_back(vendor_specific_characteristic); } bluetooth::ras::GetRasClient()->SendVendorSpecificReply(bluetooth::ToRawAddress(address), ras_vendor_specific_characteristics); do_in_main_thread(base::BindOnce(&bluetooth::ras::RasClient::SendVendorSpecificReply, base::Unretained(bluetooth::ras::GetRasClient()), bluetooth::ToRawAddress(address), std::move(ras_vendor_specific_characteristics))); } void OnHandleVendorSpecificReplyComplete(bluetooth::hci::Address address, bool success) { bluetooth::ras::GetRasServer()->HandleVendorSpecificReplyComplete( bluetooth::ToRawAddress(address), success); void OnHandleVendorSpecificReplyComplete(bluetooth::hci::Address address, bool success) override { do_in_main_thread(base::BindOnce(&bluetooth::ras::RasServer::HandleVendorSpecificReplyComplete, base::Unretained(bluetooth::ras::GetRasServer()), bluetooth::ToRawAddress(address), success)); } // Must be called from main_thread Loading