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

Commit c40871e1 authored by Zyan Wu's avatar Zyan Wu Committed by Cheney Ni
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: I685eb2386514c98c2f27a8107cb01f5e2b178daf
Merged-In: I3b2a8dec4bb845e222e2efc239b1654da78f49cf
(cherry picked from commit 75f3ee8c35212225186c4dea05278e70492329d9)
parent 17bcf30b
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -3231,6 +3231,11 @@ bt_status_t btif_av_sink_execute_service(bool enable) {
                            BTA_AV_FEAT_METADATA | BTA_AV_FEAT_VENDOR |
                            BTA_AV_FEAT_METADATA | BTA_AV_FEAT_VENDOR |
                            BTA_AV_FEAT_ADV_CTRL | BTA_AV_FEAT_RCTG |
                            BTA_AV_FEAT_ADV_CTRL | BTA_AV_FEAT_RCTG |
                            BTA_AV_FEAT_BROWSE | BTA_AV_FEAT_COVER_ARTWORK;
                            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);
    BTA_AvEnable(features, bta_av_sink_callback);
    btif_av_sink.RegisterAllBtaHandles();
    btif_av_sink.RegisterAllBtaHandles();
    return BT_STATUS_SUCCESS;
    return BT_STATUS_SUCCESS;
+4 −2
Original line number Original line 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) {
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,
    avdt_msg_send_cmd(p_scb->p_ccb, p_scb, AVDT_SIG_DELAY_RPT,
                      (tAVDT_MSG*)&p_data->apidelay);
                      (tAVDT_MSG*)&p_data->apidelay);
  }
  }
}


/*******************************************************************************
/*******************************************************************************
 *
 *
+22 −0
Original line number Original line 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) {
   uint8_t event, tAVDT_CTRL* p_data, uint8_t scb_index) {
    mock_function_count_map[__func__]++;
    mock_function_count_map[__func__]++;
  }
  }

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

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


  // Send SetConfig response
  // 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
  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) {
TEST_F(StackAvdtpTest, test_delay_report_as_init) {
  auto pscb = avdt_scb_by_hdl(scb_handle_);
  auto pscb = avdt_scb_by_hdl(scb_handle_);