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

Commit 4b261555 authored by Zyan Wu's avatar Zyan Wu Committed by Automerger Merge Worker
Browse files

Fix: add DelayReport feature when enable AV api am: c40871e1

Original change: https://googleplex-android-review.googlesource.com/c/platform/system/bt/+/14831526

Change-Id: I9938d0e7b3b6f4743ec018f6f5ff9f6cfac57a28
parents be4d3bba c40871e1
Loading
Loading
Loading
Loading
+5 −0
Original line number 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_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_);