Loading system/gd/hci/hci_layer.cc +3 −3 Original line number Diff line number Diff line Loading @@ -364,9 +364,9 @@ struct HciLayer::impl { auto view = VendorSpecificEventView::Create(event); ASSERT(view.IsValid()); if (view.GetSubeventCode() == VseSubeventCode::BQR_EVENT) { auto bqr_quality_view = BqrLinkQualityEventView::Create(BqrEventView::Create(view)); auto inflammation = BqrRootInflammationEventView::Create(bqr_quality_view); if (bqr_quality_view.IsValid() && inflammation.IsValid()) { auto bqr_event = BqrEventView::Create(view); auto inflammation = BqrRootInflammationEventView::Create(bqr_event); if (bqr_event.IsValid() && inflammation.IsValid()) { handle_root_inflammation(inflammation.GetVendorSpecificErrorCode()); return; } Loading system/gd/hci/hci_layer_unittest.cc +35 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,20 @@ using packet::PacketView; using packet::RawBuilder; using testing::LogCapture; std::vector<uint8_t> GetPacketBytes(std::unique_ptr<packet::BasePacketBuilder> packet) { std::vector<uint8_t> bytes; BitInserter i(bytes); bytes.reserve(packet->size()); packet->Serialize(i); return bytes; } std::unique_ptr<packet::BasePacketBuilder> CreatePayload(std::vector<uint8_t> payload) { auto raw_builder = std::make_unique<packet::RawBuilder>(); raw_builder->AddOctets(payload); return raw_builder; } class TestHciHal : public hal::HciHal { public: TestHciHal() : hal::HciHal() {} Loading Loading @@ -97,6 +111,10 @@ class TestHciHal : public hal::HciHal { return outgoing_commands_.size(); } void InjectEvent(std::unique_ptr<packet::BasePacketBuilder> packet) { callbacks->hciEventReceived(GetPacketBytes(std::move(packet))); } std::string ToString() const override { return std::string("TestHciHal"); } Loading Loading @@ -184,5 +202,22 @@ TEST_F(HciLayerTest, abort_after_hci_restart_timeout) { ""); } TEST_F(HciLayerTest, abort_on_root_inflammation_event) { FailIfResetNotSent(); auto payload = CreatePayload({'0'}); auto root_inflammation_event = BqrRootInflammationEventBuilder::Create(0x01, 0x01, std::move(payload)); hal_->InjectEvent(std::move(root_inflammation_event)); std::promise<void> promise; log_capture_->WaitUntilLogContains(&promise, "Received a Root Inflammation Event"); ASSERT_DEATH( { FakeTimerAdvance(HciLayer::kHciTimeoutRestartMs.count()); std::promise<void> promise; log_capture_->WaitUntilLogContains(&promise, "Root inflammation with reason"); }, ""); } } // namespace hci } // namespace bluetooth Loading
system/gd/hci/hci_layer.cc +3 −3 Original line number Diff line number Diff line Loading @@ -364,9 +364,9 @@ struct HciLayer::impl { auto view = VendorSpecificEventView::Create(event); ASSERT(view.IsValid()); if (view.GetSubeventCode() == VseSubeventCode::BQR_EVENT) { auto bqr_quality_view = BqrLinkQualityEventView::Create(BqrEventView::Create(view)); auto inflammation = BqrRootInflammationEventView::Create(bqr_quality_view); if (bqr_quality_view.IsValid() && inflammation.IsValid()) { auto bqr_event = BqrEventView::Create(view); auto inflammation = BqrRootInflammationEventView::Create(bqr_event); if (bqr_event.IsValid() && inflammation.IsValid()) { handle_root_inflammation(inflammation.GetVendorSpecificErrorCode()); return; } Loading
system/gd/hci/hci_layer_unittest.cc +35 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,20 @@ using packet::PacketView; using packet::RawBuilder; using testing::LogCapture; std::vector<uint8_t> GetPacketBytes(std::unique_ptr<packet::BasePacketBuilder> packet) { std::vector<uint8_t> bytes; BitInserter i(bytes); bytes.reserve(packet->size()); packet->Serialize(i); return bytes; } std::unique_ptr<packet::BasePacketBuilder> CreatePayload(std::vector<uint8_t> payload) { auto raw_builder = std::make_unique<packet::RawBuilder>(); raw_builder->AddOctets(payload); return raw_builder; } class TestHciHal : public hal::HciHal { public: TestHciHal() : hal::HciHal() {} Loading Loading @@ -97,6 +111,10 @@ class TestHciHal : public hal::HciHal { return outgoing_commands_.size(); } void InjectEvent(std::unique_ptr<packet::BasePacketBuilder> packet) { callbacks->hciEventReceived(GetPacketBytes(std::move(packet))); } std::string ToString() const override { return std::string("TestHciHal"); } Loading Loading @@ -184,5 +202,22 @@ TEST_F(HciLayerTest, abort_after_hci_restart_timeout) { ""); } TEST_F(HciLayerTest, abort_on_root_inflammation_event) { FailIfResetNotSent(); auto payload = CreatePayload({'0'}); auto root_inflammation_event = BqrRootInflammationEventBuilder::Create(0x01, 0x01, std::move(payload)); hal_->InjectEvent(std::move(root_inflammation_event)); std::promise<void> promise; log_capture_->WaitUntilLogContains(&promise, "Received a Root Inflammation Event"); ASSERT_DEATH( { FakeTimerAdvance(HciLayer::kHciTimeoutRestartMs.count()); std::promise<void> promise; log_capture_->WaitUntilLogContains(&promise, "Root inflammation with reason"); }, ""); } } // namespace hci } // namespace bluetooth