Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 31135bb5 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "AVRCP: Reject when CT sends invalid RegisterNotification"

parents f9e306a0 66a01d0d
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -105,6 +105,10 @@ std::vector<uint8_t> register_volume_changed_notification = {
    0x03, 0x48, 0x00, 0x00, 0x19, 0x58, 0x31, 0x00,
    0x03, 0x48, 0x00, 0x00, 0x19, 0x58, 0x31, 0x00,
    0x00, 0x05, 0x0d, 0x00, 0x00, 0x00, 0x00};
    0x00, 0x05, 0x0d, 0x00, 0x00, 0x00, 0x00};


// AVRCP Register Notification without any parameter
std::vector<uint8_t> register_notification_invalid = {
    0x03, 0x48, 0x00, 0x00, 0x19, 0x58, 0x31, 0x00, 0x00, 0x05};

// AVRCP Interim Playback Status Notification
// AVRCP Interim Playback Status Notification
std::vector<uint8_t> interim_play_status_notification = {
std::vector<uint8_t> interim_play_status_notification = {
    0x0f, 0x48, 0x00, 0x00, 0x19, 0x58, 0x31, 0x00, 0x00, 0x02, 0x01, 0x00};
    0x0f, 0x48, 0x00, 0x00, 0x19, 0x58, 0x31, 0x00, 0x00, 0x02, 0x01, 0x00};
+8 −0
Original line number Original line Diff line number Diff line
@@ -189,6 +189,14 @@ void Device::HandleGetCapabilities(


void Device::HandleNotification(
void Device::HandleNotification(
    uint8_t label, const std::shared_ptr<RegisterNotificationRequest>& pkt) {
    uint8_t label, const std::shared_ptr<RegisterNotificationRequest>& pkt) {
  if (!pkt->IsValid()) {
    DEVICE_LOG(ERROR) << __func__ << ": Request packet is not valid";
    auto response = RejectBuilder::MakeBuilder(pkt->GetCommandPdu(),
                                               Status::INVALID_PARAMETER);
    send_message(label, false, std::move(response));
    return;
  }

  DEVICE_VLOG(4) << __func__ << ": event=" << pkt->GetEventRegistered();
  DEVICE_VLOG(4) << __func__ << ": event=" << pkt->GetEventRegistered();


  switch (pkt->GetEventRegistered()) {
  switch (pkt->GetEventRegistered()) {
+16 −0
Original line number Original line Diff line number Diff line
@@ -1048,6 +1048,22 @@ TEST_F(AvrcpDeviceTest, getInvalidItemAttributesTest) {
  SendBrowseMessage(1, request);
  SendBrowseMessage(1, request);
}
}


TEST_F(AvrcpDeviceTest, invalidRegisterNotificationTest) {
  MockMediaInterface interface;
  NiceMock<MockA2dpInterface> a2dp_interface;

  test_device->RegisterInterfaces(&interface, &a2dp_interface, nullptr);

  auto reg_notif_rej_rsp = RejectBuilder::MakeBuilder(
      CommandPdu::REGISTER_NOTIFICATION, Status::INVALID_PARAMETER);
  EXPECT_CALL(response_cb,
              Call(1, false, matchPacket(std::move(reg_notif_rej_rsp))))
      .Times(1);

  auto reg_notif_request = TestAvrcpPacket::Make(register_notification_invalid);
  SendMessage(1, reg_notif_request);
}

}  // namespace avrcp
}  // namespace avrcp
}  // namespace bluetooth
}  // namespace bluetooth