Loading system/gd/Android.bp +11 −5 Original line number Diff line number Diff line Loading @@ -763,11 +763,18 @@ cc_library_host_shared { rtti: true, } rust_protobuf { name: "libhci_layer_facade_proto", crate_name: "hci_layer_facade_proto", rust_grpcio { name: "libbt_hci_proto", crate_name: "bt_hci_proto", proto: "hci/facade/facade.proto", proto_flags: ["-Iexternal/protobuf/src/"], source_stem: "facade", host_supported: true, } rust_grpcio { name: "libbt_hal_proto", crate_name: "bt_hal_proto", proto: "hal/facade.proto", source_stem: "facade", host_supported: true, } Loading @@ -785,7 +792,6 @@ rust_protobuf { name: "libbt_facade_common_proto", crate_name: "bt_facade_common_proto", proto: "facade/common.proto", proto_flags: ["-Iexternal/protobuf/src/"], source_stem: "common", host_supported: true, } system/gd/hci/facade/le_advertising_manager_facade.cc +7 −4 Original line number Diff line number Diff line Loading @@ -127,16 +127,19 @@ class LeAdvertisingManagerFacadeService : public LeAdvertisingManagerFacade::Ser ::grpc::Status CreateAdvertiser(::grpc::ServerContext* context, const CreateAdvertiserRequest* request, CreateAdvertiserResponse* response) override { hci::AdvertisingConfig config = {}; hci::ExtendedAdvertisingConfig config = {}; if (!AdvertisingConfigFromProto(request->config(), &config)) { LOG_WARN("Error parsing advertising config %s", request->SerializeAsString().c_str()); response->set_advertiser_id(LeAdvertisingManager::kInvalidId); return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "Error while parsing advertising config"); } LeAdvertiser le_advertiser(config); auto advertiser_id = le_advertising_manager_->CreateAdvertiser( config, common::Bind(&LeAdvertiser::ScanCallback, common::Unretained(&le_advertiser)), common::Bind(&LeAdvertiser::TerminatedCallback, common::Unretained(&le_advertiser)), facade_handler_); auto advertiser_id = le_advertising_manager_->ExtendedCreateAdvertiser( -1, config, common::Bind(&LeAdvertiser::ScanCallback, common::Unretained(&le_advertiser)), common::Bind(&LeAdvertiser::TerminatedCallback, common::Unretained(&le_advertiser)), facade_handler_); if (advertiser_id != LeAdvertisingManager::kInvalidId) { le_advertiser.SetAdvertiserId(advertiser_id); le_advertisers_.push_back(le_advertiser); Loading system/gd/hci/le_advertising_manager.cc +23 −18 Original line number Diff line number Diff line Loading @@ -108,6 +108,10 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb return num_instances_; } AdvertisingApiType get_advertising_api_type() const { return advertising_api_type_; } void register_advertising_callback(AdvertisingCallback* advertising_callback) { advertising_callbacks_ = advertising_callback; } Loading Loading @@ -184,7 +188,9 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb } } void create_advertiser(AdvertiserId id, const AdvertisingConfig& config, void create_advertiser( AdvertiserId id, const AdvertisingConfig config, const common::Callback<void(Address, AddressType)>& scan_callback, const common::Callback<void(ErrorCode, uint8_t, uint8_t)>& set_terminated_callback, os::Handler* handler) { Loading Loading @@ -270,15 +276,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb enabled_sets_[id] = curr_set; } break; case (AdvertisingApiType::EXTENDED): { ExtendedAdvertisingConfig new_config = config; new_config.legacy_pdus = true; // sid must be in range 0x00 to 0x0F. Since no controller supports more than // 16 advertisers, it's safe to make sid equal to id. new_config.sid = id % kAdvertisingSetIdMask; // TODO remove, always call create_advertiser via create_extended_advertiser create_extended_advertiser(0x00, id, new_config, scan_callback, set_terminated_callback, handler); LOG_WARN("Unexpected AdvertisingApiType EXTENDED"); } break; } } Loading @@ -286,7 +284,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb void create_extended_advertiser( int reg_id, AdvertiserId id, const ExtendedAdvertisingConfig& config, const ExtendedAdvertisingConfig config, const common::Callback<void(Address, AddressType)>& scan_callback, const common::Callback<void(ErrorCode, uint8_t, uint8_t)>& set_terminated_callback, os::Handler* handler) { Loading Loading @@ -921,9 +919,11 @@ size_t LeAdvertisingManager::GetNumberOfAdvertisingInstances() const { return pimpl_->GetNumberOfAdvertisingInstances(); } AdvertiserId LeAdvertisingManager::CreateAdvertiser( const AdvertisingConfig& config, const common::Callback<void(Address, AddressType)>& scan_callback, const common::Callback<void(ErrorCode, uint8_t, uint8_t)>& set_terminated_callback, os::Handler* handler) { AdvertiserId LeAdvertisingManager::create_advertiser( const AdvertisingConfig config, const common::Callback<void(Address, AddressType)>& scan_callback, const common::Callback<void(ErrorCode, uint8_t, uint8_t)>& set_terminated_callback, os::Handler* handler) { if (config.peer_address == Address::kEmpty) { if (config.own_address_type == hci::OwnAddressType::RESOLVABLE_OR_PUBLIC_ADDRESS || config.own_address_type == hci::OwnAddressType::RESOLVABLE_OR_RANDOM_ADDRESS) { Loading @@ -947,10 +947,15 @@ AdvertiserId LeAdvertisingManager::CreateAdvertiser( AdvertiserId LeAdvertisingManager::ExtendedCreateAdvertiser( int reg_id, const ExtendedAdvertisingConfig& config, const ExtendedAdvertisingConfig config, const common::Callback<void(Address, AddressType)>& scan_callback, const common::Callback<void(ErrorCode, uint8_t, uint8_t)>& set_terminated_callback, os::Handler* handler) { AdvertisingApiType advertising_api_type = pimpl_->get_advertising_api_type(); if (advertising_api_type != AdvertisingApiType::EXTENDED) { return create_advertiser(config, scan_callback, set_terminated_callback, handler); }; if (config.directed) { if (config.peer_address == Address::kEmpty) { LOG_INFO("Peer address can not be empty for directed advertising"); Loading system/gd/hci/le_advertising_manager.h +7 −6 Original line number Diff line number Diff line Loading @@ -102,14 +102,9 @@ class LeAdvertisingManager : public bluetooth::Module { size_t GetNumberOfAdvertisingInstances() const; // Return -1 if the advertiser was not created, otherwise the advertiser ID. AdvertiserId CreateAdvertiser(const AdvertisingConfig& config, const common::Callback<void(Address, AddressType)>& scan_callback, const common::Callback<void(ErrorCode, uint8_t, uint8_t)>& set_terminated_callback, os::Handler* handler); AdvertiserId ExtendedCreateAdvertiser( int reg_id, const ExtendedAdvertisingConfig& config, const ExtendedAdvertisingConfig config, const common::Callback<void(Address, AddressType)>& scan_callback, const common::Callback<void(ErrorCode, uint8_t, uint8_t)>& set_terminated_callback, os::Handler* handler); Loading Loading @@ -145,6 +140,12 @@ class LeAdvertisingManager : public bluetooth::Module { std::string ToString() const override; private: // Return -1 if the advertiser was not created, otherwise the advertiser ID. AdvertiserId create_advertiser( const AdvertisingConfig config, const common::Callback<void(Address, AddressType)>& scan_callback, const common::Callback<void(ErrorCode, uint8_t, uint8_t)>& set_terminated_callback, os::Handler* handler); struct impl; std::unique_ptr<impl> pimpl_; DISALLOW_COPY_AND_ASSIGN(LeAdvertisingManager); Loading system/gd/hci/le_advertising_manager_mock.h +1 −8 Original line number Diff line number Diff line Loading @@ -33,18 +33,11 @@ using hci::LeAdvertisingManager; class MockLeAdvertisingManager : public LeAdvertisingManager { public: MOCK_METHOD(size_t, GetNumberOfAdvertisingInstances, (), (const)); MOCK_METHOD( AdvertiserId, CreateAdvertiser, (const AdvertisingConfig&, const common::Callback<void(Address, AddressType)>&, const common::Callback<void(ErrorCode, uint8_t, uint8_t)>&, os::Handler*)); MOCK_METHOD( AdvertiserId, ExtendedCreateAdvertiser, (int regId, const ExtendedAdvertisingConfig&, const ExtendedAdvertisingConfig, const common::Callback<void(Address, AddressType)>&, const common::Callback<void(ErrorCode, uint8_t, uint8_t)>&, os::Handler*)); Loading Loading
system/gd/Android.bp +11 −5 Original line number Diff line number Diff line Loading @@ -763,11 +763,18 @@ cc_library_host_shared { rtti: true, } rust_protobuf { name: "libhci_layer_facade_proto", crate_name: "hci_layer_facade_proto", rust_grpcio { name: "libbt_hci_proto", crate_name: "bt_hci_proto", proto: "hci/facade/facade.proto", proto_flags: ["-Iexternal/protobuf/src/"], source_stem: "facade", host_supported: true, } rust_grpcio { name: "libbt_hal_proto", crate_name: "bt_hal_proto", proto: "hal/facade.proto", source_stem: "facade", host_supported: true, } Loading @@ -785,7 +792,6 @@ rust_protobuf { name: "libbt_facade_common_proto", crate_name: "bt_facade_common_proto", proto: "facade/common.proto", proto_flags: ["-Iexternal/protobuf/src/"], source_stem: "common", host_supported: true, }
system/gd/hci/facade/le_advertising_manager_facade.cc +7 −4 Original line number Diff line number Diff line Loading @@ -127,16 +127,19 @@ class LeAdvertisingManagerFacadeService : public LeAdvertisingManagerFacade::Ser ::grpc::Status CreateAdvertiser(::grpc::ServerContext* context, const CreateAdvertiserRequest* request, CreateAdvertiserResponse* response) override { hci::AdvertisingConfig config = {}; hci::ExtendedAdvertisingConfig config = {}; if (!AdvertisingConfigFromProto(request->config(), &config)) { LOG_WARN("Error parsing advertising config %s", request->SerializeAsString().c_str()); response->set_advertiser_id(LeAdvertisingManager::kInvalidId); return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "Error while parsing advertising config"); } LeAdvertiser le_advertiser(config); auto advertiser_id = le_advertising_manager_->CreateAdvertiser( config, common::Bind(&LeAdvertiser::ScanCallback, common::Unretained(&le_advertiser)), common::Bind(&LeAdvertiser::TerminatedCallback, common::Unretained(&le_advertiser)), facade_handler_); auto advertiser_id = le_advertising_manager_->ExtendedCreateAdvertiser( -1, config, common::Bind(&LeAdvertiser::ScanCallback, common::Unretained(&le_advertiser)), common::Bind(&LeAdvertiser::TerminatedCallback, common::Unretained(&le_advertiser)), facade_handler_); if (advertiser_id != LeAdvertisingManager::kInvalidId) { le_advertiser.SetAdvertiserId(advertiser_id); le_advertisers_.push_back(le_advertiser); Loading
system/gd/hci/le_advertising_manager.cc +23 −18 Original line number Diff line number Diff line Loading @@ -108,6 +108,10 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb return num_instances_; } AdvertisingApiType get_advertising_api_type() const { return advertising_api_type_; } void register_advertising_callback(AdvertisingCallback* advertising_callback) { advertising_callbacks_ = advertising_callback; } Loading Loading @@ -184,7 +188,9 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb } } void create_advertiser(AdvertiserId id, const AdvertisingConfig& config, void create_advertiser( AdvertiserId id, const AdvertisingConfig config, const common::Callback<void(Address, AddressType)>& scan_callback, const common::Callback<void(ErrorCode, uint8_t, uint8_t)>& set_terminated_callback, os::Handler* handler) { Loading Loading @@ -270,15 +276,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb enabled_sets_[id] = curr_set; } break; case (AdvertisingApiType::EXTENDED): { ExtendedAdvertisingConfig new_config = config; new_config.legacy_pdus = true; // sid must be in range 0x00 to 0x0F. Since no controller supports more than // 16 advertisers, it's safe to make sid equal to id. new_config.sid = id % kAdvertisingSetIdMask; // TODO remove, always call create_advertiser via create_extended_advertiser create_extended_advertiser(0x00, id, new_config, scan_callback, set_terminated_callback, handler); LOG_WARN("Unexpected AdvertisingApiType EXTENDED"); } break; } } Loading @@ -286,7 +284,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb void create_extended_advertiser( int reg_id, AdvertiserId id, const ExtendedAdvertisingConfig& config, const ExtendedAdvertisingConfig config, const common::Callback<void(Address, AddressType)>& scan_callback, const common::Callback<void(ErrorCode, uint8_t, uint8_t)>& set_terminated_callback, os::Handler* handler) { Loading Loading @@ -921,9 +919,11 @@ size_t LeAdvertisingManager::GetNumberOfAdvertisingInstances() const { return pimpl_->GetNumberOfAdvertisingInstances(); } AdvertiserId LeAdvertisingManager::CreateAdvertiser( const AdvertisingConfig& config, const common::Callback<void(Address, AddressType)>& scan_callback, const common::Callback<void(ErrorCode, uint8_t, uint8_t)>& set_terminated_callback, os::Handler* handler) { AdvertiserId LeAdvertisingManager::create_advertiser( const AdvertisingConfig config, const common::Callback<void(Address, AddressType)>& scan_callback, const common::Callback<void(ErrorCode, uint8_t, uint8_t)>& set_terminated_callback, os::Handler* handler) { if (config.peer_address == Address::kEmpty) { if (config.own_address_type == hci::OwnAddressType::RESOLVABLE_OR_PUBLIC_ADDRESS || config.own_address_type == hci::OwnAddressType::RESOLVABLE_OR_RANDOM_ADDRESS) { Loading @@ -947,10 +947,15 @@ AdvertiserId LeAdvertisingManager::CreateAdvertiser( AdvertiserId LeAdvertisingManager::ExtendedCreateAdvertiser( int reg_id, const ExtendedAdvertisingConfig& config, const ExtendedAdvertisingConfig config, const common::Callback<void(Address, AddressType)>& scan_callback, const common::Callback<void(ErrorCode, uint8_t, uint8_t)>& set_terminated_callback, os::Handler* handler) { AdvertisingApiType advertising_api_type = pimpl_->get_advertising_api_type(); if (advertising_api_type != AdvertisingApiType::EXTENDED) { return create_advertiser(config, scan_callback, set_terminated_callback, handler); }; if (config.directed) { if (config.peer_address == Address::kEmpty) { LOG_INFO("Peer address can not be empty for directed advertising"); Loading
system/gd/hci/le_advertising_manager.h +7 −6 Original line number Diff line number Diff line Loading @@ -102,14 +102,9 @@ class LeAdvertisingManager : public bluetooth::Module { size_t GetNumberOfAdvertisingInstances() const; // Return -1 if the advertiser was not created, otherwise the advertiser ID. AdvertiserId CreateAdvertiser(const AdvertisingConfig& config, const common::Callback<void(Address, AddressType)>& scan_callback, const common::Callback<void(ErrorCode, uint8_t, uint8_t)>& set_terminated_callback, os::Handler* handler); AdvertiserId ExtendedCreateAdvertiser( int reg_id, const ExtendedAdvertisingConfig& config, const ExtendedAdvertisingConfig config, const common::Callback<void(Address, AddressType)>& scan_callback, const common::Callback<void(ErrorCode, uint8_t, uint8_t)>& set_terminated_callback, os::Handler* handler); Loading Loading @@ -145,6 +140,12 @@ class LeAdvertisingManager : public bluetooth::Module { std::string ToString() const override; private: // Return -1 if the advertiser was not created, otherwise the advertiser ID. AdvertiserId create_advertiser( const AdvertisingConfig config, const common::Callback<void(Address, AddressType)>& scan_callback, const common::Callback<void(ErrorCode, uint8_t, uint8_t)>& set_terminated_callback, os::Handler* handler); struct impl; std::unique_ptr<impl> pimpl_; DISALLOW_COPY_AND_ASSIGN(LeAdvertisingManager); Loading
system/gd/hci/le_advertising_manager_mock.h +1 −8 Original line number Diff line number Diff line Loading @@ -33,18 +33,11 @@ using hci::LeAdvertisingManager; class MockLeAdvertisingManager : public LeAdvertisingManager { public: MOCK_METHOD(size_t, GetNumberOfAdvertisingInstances, (), (const)); MOCK_METHOD( AdvertiserId, CreateAdvertiser, (const AdvertisingConfig&, const common::Callback<void(Address, AddressType)>&, const common::Callback<void(ErrorCode, uint8_t, uint8_t)>&, os::Handler*)); MOCK_METHOD( AdvertiserId, ExtendedCreateAdvertiser, (int regId, const ExtendedAdvertisingConfig&, const ExtendedAdvertisingConfig, const common::Callback<void(Address, AddressType)>&, const common::Callback<void(ErrorCode, uint8_t, uint8_t)>&, os::Handler*)); Loading