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

Commit 71de37e4 authored by Chris Manton's avatar Chris Manton
Browse files

Add stack/btm/btm_sco::btm_sco_on_disconnected

Bug: 177382279
Tag: #refactor
Test: gd/cert/run

Change-Id: I29b4a60bbab47a3415c96df7adea3a175bc19848
parent 0e3f9467
Loading
Loading
Loading
Loading
+29 −0
Original line number Original line Diff line number Diff line
@@ -852,6 +852,35 @@ bool btm_sco_removed(uint16_t hci_handle, tHCI_REASON reason) {
  return false;
  return false;
}
}


void btm_sco_on_disconnected(uint16_t hci_handle, tHCI_REASON reason) {
  tSCO_CONN* p_sco = btm_cb.sco_cb.get_sco_connection_from_handle(hci_handle);
  if (p_sco == nullptr) {
    LOG_ERROR("Unable to find sco connection");
    return;
  }

  if (!p_sco->is_active()) {
    LOG_ERROR("Connection is not active handle:0x%04x reason:%s", hci_handle,
              hci_reason_code_text(reason).c_str());
    return;
  }

  if (p_sco->state == SCO_ST_LISTENING) {
    LOG_ERROR("Connection is in listening state handle:0x%04x reason:%s",
              hci_handle, hci_reason_code_text(reason).c_str());
    return;
  }

  p_sco->state = SCO_ST_UNUSED;
  p_sco->hci_handle = HCI_INVALID_HANDLE;
  p_sco->rem_bd_known = false;
  p_sco->esco.p_esco_cback = NULL; /* Deregister eSCO callback */
  btm_cb.sco_cb.sco_disc_reason = reason;
  (*p_sco->p_disc_cb)(btm_cb.sco_cb.get_index(p_sco));
  LOG_DEBUG("Disconnected SCO link handle:%hu reason:%s", hci_handle,
            hci_reason_code_text(reason).c_str());
}

/*******************************************************************************
/*******************************************************************************
 *
 *
 * Function         btm_sco_acl_removed
 * Function         btm_sco_acl_removed