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

Commit fc94ed50 authored by Zyan Wu's avatar Zyan Wu
Browse files

Fix: add DelayReport feature when enable AV api

We shall enable AV api with feature of DelayReport when the device
enables delay reporting in its properties.

We shall only send delay report when that feature is enabled for
AVDT

Bug: 189404280
Tag: #compatibility
Test: atest --host bluetooth_test_gd
Change-Id: I3b2a8dec4bb845e222e2efc239b1654da78f49cf
parent e95577f9
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -3239,6 +3239,11 @@ bt_status_t btif_av_sink_execute_service(bool enable) {
                            BTA_AV_FEAT_METADATA | BTA_AV_FEAT_VENDOR |
                            BTA_AV_FEAT_ADV_CTRL | BTA_AV_FEAT_RCTG |
                            BTA_AV_FEAT_BROWSE | BTA_AV_FEAT_COVER_ARTWORK;

    if (delay_reporting_enabled()) {
      features |= BTA_AV_FEAT_DELAY_RPT;
    }

    BTA_AvEnable(features, bta_av_sink_callback);
    btif_av_sink.RegisterAllBtaHandles();
    return BT_STATUS_SUCCESS;
+4 −2
Original line number Diff line number Diff line
@@ -840,9 +840,11 @@ void avdt_scb_hdl_tc_close(AvdtpScb* p_scb, tAVDT_SCB_EVT* p_data) {
 *
 ******************************************************************************/
void avdt_scb_snd_delay_rpt_req(AvdtpScb* p_scb, tAVDT_SCB_EVT* p_data) {
  if (p_scb->stream_config.cfg.psc_mask & AVDT_PSC_DELAY_RPT) {
    avdt_msg_send_cmd(p_scb->p_ccb, p_scb, AVDT_SIG_DELAY_RPT,
                      (tAVDT_MSG*)&p_data->apidelay);
  }
}

/*******************************************************************************
 *
+22 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ class StackAvdtpTest : public ::testing::Test {
   uint8_t event, tAVDT_CTRL* p_data, uint8_t scb_index) {
    mock_function_count_map[__func__]++;
  }

  static void _streamcallback(uint8_t handle, const RawAddress& bd_addr,
   uint8_t event, tAVDT_CTRL* p_data,
   uint8_t scb_index) {
@@ -130,6 +131,8 @@ TEST_F(StackAvdtpTest, test_no_delay_report_if_not_sink) {
  // Get SCB ready to send response
  auto pscb = avdt_scb_by_hdl(scb_handle_);
  pscb->in_use = true;

  // Change the scb to SRC
  pscb->stream_config.tsep = AVDT_TSEP_SRC;

  // Send SetConfig response
@@ -143,6 +146,25 @@ TEST_F(StackAvdtpTest, test_no_delay_report_if_not_sink) {
  ASSERT_EQ(mock_function_count_map["avdt_msg_send_cmd"], 0); // Delay report command not sent
}

TEST_F(StackAvdtpTest, test_no_delay_report_if_not_enabled) {
  // Get SCB ready to send response
  auto pscb = avdt_scb_by_hdl(scb_handle_);
  pscb->in_use = true;

  // Disable the scb's delay report mask
  pscb->stream_config.cfg.psc_mask &= ~AVDT_PSC_DELAY_RPT;

  // Send SetConfig response
  uint8_t label = 0;
  uint8_t err_code = 0;
  uint8_t category = 0;
  mock_function_count_map["avdt_msg_send_rsp"] = 0;
  mock_function_count_map["avdt_msg_send_cmd"] = 0;
  ASSERT_EQ(AVDT_ConfigRsp(scb_handle_, label, err_code, category), AVDT_SUCCESS);
  ASSERT_EQ(mock_function_count_map["avdt_msg_send_rsp"], 1); // Config response sent
  ASSERT_EQ(mock_function_count_map["avdt_msg_send_cmd"], 0); // Delay report command not sent
}

TEST_F(StackAvdtpTest, test_delay_report_as_init) {
  auto pscb = avdt_scb_by_hdl(scb_handle_);