Loading system/gd/hci/le_periodic_sync_manager.h +12 −6 Original line number Diff line number Diff line Loading @@ -272,13 +272,19 @@ class PeriodicSyncManager { } auto address_with_type = AddressWithType(event_view.GetAdvertiserAddress(), event_view.GetAdvertiserAddressType()); auto temp_address_type = address_with_type.GetAddressType(); // If the create sync command uses 0x01, Random or Random ID, the result can be 0x01, 0x02, or 0x03, // because a Random Address, if it is an RPA, can be resolved to either Public Identity or Random Identity. if (temp_address_type != AddressType::PUBLIC_DEVICE_ADDRESS) { auto peer_address_type = address_with_type.GetAddressType(); AddressType temp_address_type; switch (peer_address_type) { case AddressType::PUBLIC_DEVICE_ADDRESS: case AddressType::PUBLIC_IDENTITY_ADDRESS: temp_address_type = AddressType::PUBLIC_DEVICE_ADDRESS; break; case AddressType::RANDOM_DEVICE_ADDRESS: case AddressType::RANDOM_IDENTITY_ADDRESS: temp_address_type = AddressType::RANDOM_DEVICE_ADDRESS; break; } auto periodic_sync = GetSyncFromAddressWithTypeAndSid( AddressWithType(event_view.GetAdvertiserAddress(), temp_address_type), event_view.GetAdvertisingSid()); if (periodic_sync == periodic_syncs_.end()) { Loading system/gd/hci/le_periodic_sync_manager_test.cc +42 −0 Original line number Diff line number Diff line Loading @@ -279,6 +279,48 @@ TEST_F(PeriodicSyncManagerTest, handle_advertising_sync_established_test) { sync_handler(); } TEST_F(PeriodicSyncManagerTest, handle_advertising_sync_established_with_public_identity_address_test) { uint16_t sync_handle = 0x12; uint8_t advertiser_sid = 0x02; // start scan Address address; Address::FromString("00:11:22:33:44:55", address); AddressWithType address_with_type = AddressWithType(address, AddressType::PUBLIC_DEVICE_ADDRESS); PeriodicSyncStates request{ .request_id = 0x01, .advertiser_sid = advertiser_sid, .address_with_type = address_with_type, .sync_handle = sync_handle, .sync_state = PeriodicSyncState::PERIODIC_SYNC_STATE_IDLE, }; test_le_scanning_interface_->SetCommandFuture(); periodic_sync_manager_->StartSync(request, 0x04, 0x0A); auto packet = test_le_scanning_interface_->GetCommand(OpCode::LE_PERIODIC_ADVERTISING_CREATE_SYNC); auto temp_view = LePeriodicAdvertisingCreateSyncView::Create(LeScanningCommandView::Create(packet)); ASSERT_TRUE(temp_view.IsValid()); // Get command status test_le_scanning_interface_->CommandStatusCallback( LePeriodicAdvertisingCreateSyncStatusBuilder::Create(ErrorCode::SUCCESS, 0x00)); EXPECT_CALL(mock_callbacks_, OnPeriodicSyncStarted); // Get LePeriodicAdvertisingSyncEstablished with AddressType::PUBLIC_IDENTITY_ADDRESS auto builder = LePeriodicAdvertisingSyncEstablishedBuilder::Create( ErrorCode::SUCCESS, sync_handle, advertiser_sid, AddressType::PUBLIC_IDENTITY_ADDRESS, address_with_type.GetAddress(), SecondaryPhyType::LE_1M, 0xFF, ClockAccuracy::PPM_250); auto event_view = LePeriodicAdvertisingSyncEstablishedView::Create( LeMetaEventView::Create(EventView::Create(GetPacketView(std::move(builder))))); periodic_sync_manager_->HandleLePeriodicAdvertisingSyncEstablished(event_view); sync_handler(); } TEST_F(PeriodicSyncManagerTest, stop_sync_test) { uint16_t sync_handle = 0x12; uint8_t advertiser_sid = 0x02; Loading Loading
system/gd/hci/le_periodic_sync_manager.h +12 −6 Original line number Diff line number Diff line Loading @@ -272,13 +272,19 @@ class PeriodicSyncManager { } auto address_with_type = AddressWithType(event_view.GetAdvertiserAddress(), event_view.GetAdvertiserAddressType()); auto temp_address_type = address_with_type.GetAddressType(); // If the create sync command uses 0x01, Random or Random ID, the result can be 0x01, 0x02, or 0x03, // because a Random Address, if it is an RPA, can be resolved to either Public Identity or Random Identity. if (temp_address_type != AddressType::PUBLIC_DEVICE_ADDRESS) { auto peer_address_type = address_with_type.GetAddressType(); AddressType temp_address_type; switch (peer_address_type) { case AddressType::PUBLIC_DEVICE_ADDRESS: case AddressType::PUBLIC_IDENTITY_ADDRESS: temp_address_type = AddressType::PUBLIC_DEVICE_ADDRESS; break; case AddressType::RANDOM_DEVICE_ADDRESS: case AddressType::RANDOM_IDENTITY_ADDRESS: temp_address_type = AddressType::RANDOM_DEVICE_ADDRESS; break; } auto periodic_sync = GetSyncFromAddressWithTypeAndSid( AddressWithType(event_view.GetAdvertiserAddress(), temp_address_type), event_view.GetAdvertisingSid()); if (periodic_sync == periodic_syncs_.end()) { Loading
system/gd/hci/le_periodic_sync_manager_test.cc +42 −0 Original line number Diff line number Diff line Loading @@ -279,6 +279,48 @@ TEST_F(PeriodicSyncManagerTest, handle_advertising_sync_established_test) { sync_handler(); } TEST_F(PeriodicSyncManagerTest, handle_advertising_sync_established_with_public_identity_address_test) { uint16_t sync_handle = 0x12; uint8_t advertiser_sid = 0x02; // start scan Address address; Address::FromString("00:11:22:33:44:55", address); AddressWithType address_with_type = AddressWithType(address, AddressType::PUBLIC_DEVICE_ADDRESS); PeriodicSyncStates request{ .request_id = 0x01, .advertiser_sid = advertiser_sid, .address_with_type = address_with_type, .sync_handle = sync_handle, .sync_state = PeriodicSyncState::PERIODIC_SYNC_STATE_IDLE, }; test_le_scanning_interface_->SetCommandFuture(); periodic_sync_manager_->StartSync(request, 0x04, 0x0A); auto packet = test_le_scanning_interface_->GetCommand(OpCode::LE_PERIODIC_ADVERTISING_CREATE_SYNC); auto temp_view = LePeriodicAdvertisingCreateSyncView::Create(LeScanningCommandView::Create(packet)); ASSERT_TRUE(temp_view.IsValid()); // Get command status test_le_scanning_interface_->CommandStatusCallback( LePeriodicAdvertisingCreateSyncStatusBuilder::Create(ErrorCode::SUCCESS, 0x00)); EXPECT_CALL(mock_callbacks_, OnPeriodicSyncStarted); // Get LePeriodicAdvertisingSyncEstablished with AddressType::PUBLIC_IDENTITY_ADDRESS auto builder = LePeriodicAdvertisingSyncEstablishedBuilder::Create( ErrorCode::SUCCESS, sync_handle, advertiser_sid, AddressType::PUBLIC_IDENTITY_ADDRESS, address_with_type.GetAddress(), SecondaryPhyType::LE_1M, 0xFF, ClockAccuracy::PPM_250); auto event_view = LePeriodicAdvertisingSyncEstablishedView::Create( LeMetaEventView::Create(EventView::Create(GetPacketView(std::move(builder))))); periodic_sync_manager_->HandleLePeriodicAdvertisingSyncEstablished(event_view); sync_handler(); } TEST_F(PeriodicSyncManagerTest, stop_sync_test) { uint16_t sync_handle = 0x12; uint8_t advertiser_sid = 0x02; Loading