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

Commit 4bd43a7b authored by Cheney Ni's avatar Cheney Ni
Browse files

AVDTP: Reject the start request while SCO is up

Some Bluetooth headsets can't handle AVDTP media and SCO at the same
time, and we have checked the call state to prevent such case. However,
if there was a voice recognition running over the Bluetooth SCO, it was
call idle. Now we listen to the SCO status, so AVDTP media won't be
started at the same time.

Bug: 139520575
Test: manually
Change-Id: I70377cf531bf6c4b56dc51a84d2c8ead6a7fdc39
parent cc8823ce
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -243,9 +243,7 @@ static void bta_av_api_enable(tBTA_AV_DATA* p_data) {
  enable.features = bta_av_cb.features;

  /* Register for SCO change event */
  if (!(bta_av_cb.features & BTA_AV_FEAT_NO_SCO_SSPD)) {
  bta_sys_sco_register(bta_av_sco_chg_cback);
  }

  /* call callback with enable event */
  tBTA_AV bta_av_data;
@@ -986,16 +984,20 @@ static void bta_av_sco_chg_cback(tBTA_SYS_CONN_STATUS status, uint8_t id,
  int i;
  tBTA_AV_API_STOP stop;

  APPL_TRACE_DEBUG("%s: id:%d status:%d", __func__, id, status);
  LOG(INFO) << __func__ << ": status=" << +status << ", num_links=" << +id;
  if (id) {
    bta_av_cb.sco_occupied = true;

    if (bta_av_cb.features & BTA_AV_FEAT_NO_SCO_SSPD) {
      return;
    }

    /* either BTA_SYS_SCO_OPEN or BTA_SYS_SCO_CLOSE with remaining active SCO */
    for (i = 0; i < BTA_AV_NUM_STRS; i++) {
      p_scb = bta_av_cb.p_scb[i];

      if (p_scb && p_scb->co_started && (!p_scb->sco_suspend)) {
        APPL_TRACE_DEBUG("%s: suspending scb:%d", __func__, i);
        VLOG(1) << __func__ << ": suspending scb:" << i;
        /* scb is used and started, not suspended automatically */
        p_scb->sco_suspend = true;
        stop.flush = false;
@@ -1007,12 +1009,16 @@ static void bta_av_sco_chg_cback(tBTA_SYS_CONN_STATUS status, uint8_t id,
  } else {
    bta_av_cb.sco_occupied = false;

    if (bta_av_cb.features & BTA_AV_FEAT_NO_SCO_SSPD) {
      return;
    }

    for (i = 0; i < BTA_AV_NUM_STRS; i++) {
      p_scb = bta_av_cb.p_scb[i];

      if (p_scb && p_scb->sco_suspend) /* scb is used and suspended for SCO */
      {
        APPL_TRACE_DEBUG("%s: starting scb:%d", __func__, i);
        VLOG(1) << __func__ << ": starting scb:" << i;
        bta_av_ssm_execute(p_scb, BTA_AV_AP_START_EVT, NULL);
      }
    }