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

Commit 240c9d4b authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes I43b8a393,I576be190,Iedc4254e,I0420630f,Ic6aa1f96, ... am:...

Merge changes I43b8a393,I576be190,Iedc4254e,I0420630f,Ic6aa1f96, ... am: cd755eeb am: c30a9397 am: 9c9f5e61

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I8337b47ecb4477b9eab81cca4d6fc6f9c60bb1db
parents ed449587 9c9f5e61
Loading
Loading
Loading
Loading
+19 −13
Original line number Diff line number Diff line
@@ -1114,10 +1114,11 @@ bt_status_t HeadsetInterface::PhoneStateChange(
    const char* number, bthf_call_addrtype_t type, const char* name,
    RawAddress* bd_addr) {
  CHECK_BTHF_INIT();
  if (!bd_addr) {
  if (bd_addr == nullptr) {
    LOG_WARN("bd_addr is null");
    return BT_STATUS_FAIL;
  }

  const RawAddress raw_address(*bd_addr);
  int idx = btif_hf_idx_by_bdaddr(bd_addr);
  if (idx < 0 || idx > BTA_AG_MAX_NUM_CLIENTS) {
@@ -1138,14 +1139,13 @@ bt_status_t HeadsetInterface::PhoneStateChange(
              << ", num_held=" << num_held;
    return BT_STATUS_SUCCESS;
  }
  LOG(INFO) << __func__ << ": idx=" << idx << ", addr=" << *bd_addr
            << ", active_bda=" << active_bda << ", num_active=" << num_active
            << ", prev_num_active" << control_block.num_active
            << ", num_held=" << num_held
            << ", prev_num_held=" << control_block.num_held
            << ", call_state=" << dump_hf_call_state(call_setup_state)
            << ", prev_call_state="
            << dump_hf_call_state(control_block.call_setup_state);
  LOG_DEBUG(
      "bd_addr:%s active_bda:%s num_active:%u prev_num_active:%u num_held:%u "
      "prev_num_held:%u call_state:%s prev_call_state:%s",
      PRIVATE_ADDRESS((*bd_addr)), PRIVATE_ADDRESS(active_bda), num_active,
      control_block.num_active, num_held, control_block.num_held,
      dump_hf_call_state(call_setup_state),
      dump_hf_call_state(control_block.call_setup_state));
  tBTA_AG_RES res = BTA_AG_UNKNOWN;
  bt_status_t status = BT_STATUS_SUCCESS;
  bool active_call_updated = false;
@@ -1153,7 +1153,9 @@ bt_status_t HeadsetInterface::PhoneStateChange(
  /* if all indicators are 0, send end call and return */
  if (num_active == 0 && num_held == 0 &&
      call_setup_state == BTHF_CALL_STATE_IDLE) {
    if (control_block.num_active > 0) {
      BTM_LogHistory(kBtmLogTag, raw_address, "Call Ended");
    }
    BTA_AgResult(control_block.handle, BTA_AG_END_CALL_RES,
                 tBTA_AG_RES_DATA::kEmpty);
    /* if held call was present, reset that as well */
@@ -1291,10 +1293,14 @@ bt_status_t HeadsetInterface::PhoneStateChange(
          }
          snprintf(ag_res.str, sizeof(ag_res.str), "%s",
                   call_number_stream.str().c_str());
          std::string number(call_number_stream.str());
          BTM_LogHistory(kBtmLogTag, raw_address, "Call Incoming",
                         base::StringPrintf("number:%s", PRIVATE_CELL(number)));
        }
        {
          std::string cell_number(number);
          BTM_LogHistory(
              kBtmLogTag, raw_address, "Call Incoming",
              base::StringPrintf("number:%s", PRIVATE_CELL(cell_number)));
        }
        // base::StringPrintf("number:%s", PRIVATE_CELL(number)));
        break;
      case BTHF_CALL_STATE_DIALING:
        if (!(num_active + num_held) && is_active_device(*bd_addr)) {
+11 −0
Original line number Diff line number Diff line
@@ -128,6 +128,17 @@ inline uint8_t ToLegacyRole(hci::Role role) {
  return static_cast<uint8_t>(role);
}

inline hci::Role ToHciRole(hci_role_t role) {
  switch (role) {
    case HCI_ROLE_CENTRAL:
      return hci::Role::CENTRAL;
    case HCI_ROLE_PERIPHERAL:
      return hci::Role::PERIPHERAL;
    default:
      ASSERT_LOG(false, "Unable to determine legacy role:%u", role);
  }
}

inline tHCI_STATUS ToLegacyHciErrorCode(hci::ErrorCode reason) {
  switch (reason) {
    case hci::ErrorCode::SUCCESS:
+20 −0
Original line number Diff line number Diff line
@@ -251,7 +251,27 @@ struct sACL_CONN {
#define BTM_SEC_RS_NOT_PENDING 0 /* Role Switch not in progress */
#define BTM_SEC_RS_PENDING 1     /* Role Switch in progress */
#define BTM_SEC_DISC_PENDING 2   /* Disconnect is pending */
 private:
  uint8_t rs_disc_pending = BTM_SEC_RS_NOT_PENDING;
  friend struct StackAclBtmAcl;
  friend tBTM_STATUS btm_remove_acl(const RawAddress& bd_addr,
                                    tBT_TRANSPORT transport);
  friend void acl_disconnect_after_role_switch(uint16_t conn_handle,
                                               tHCI_STATUS reason);
  friend void bluetooth::shim::btm_pm_on_mode_change(tHCI_STATUS status,
                                                     uint16_t handle,
                                                     tHCI_MODE hci_mode,
                                                     uint16_t interval);
  friend void btm_acl_encrypt_change(uint16_t handle, uint8_t status,
                                     uint8_t encr_enable);

 public:
  bool is_disconnect_pending() const {
    return rs_disc_pending == BTM_SEC_DISC_PENDING;
  }
  bool is_role_switch_pending() const {
    return rs_disc_pending == BTM_SEC_RS_PENDING;
  }

 private:
  uint8_t switch_role_state_;
+0 −4
Original line number Diff line number Diff line
@@ -2834,10 +2834,6 @@ void acl_disconnect_after_role_switch(uint16_t conn_handle,
  if (p_acl == nullptr) {
    LOG_ERROR("Sending disconnect for unknown acl:%hu PLEASE FIX", conn_handle);
    GetLegacyHciInterface().Disconnect(conn_handle, reason);
    if (bluetooth::shim::is_gd_acl_enabled() &&
        btm_sco_removed(conn_handle, HCI_ERR_CONN_CAUSE_LOCAL_HOST))
      LOG_ERROR(
          "Assuming this was a SCO connection and short circuiting disconnect");
    return;
  }

+23 −7
Original line number Diff line number Diff line
@@ -23,7 +23,9 @@
 *
 ******************************************************************************/

#include <base/strings/stringprintf.h>
#include <cstdint>
#include <string>

#include "device/include/controller.h"
#include "device/include/esco_parameters.h"
@@ -34,11 +36,18 @@
#include "stack/include/acl_api.h"
#include "stack/include/btm_api.h"
#include "stack/include/btm_api_types.h"
#include "stack/include/hci_error_code.h"
#include "stack/include/hcimsgs.h"

extern tBTM_CB btm_cb;

namespace {
constexpr char kBtmLogTag[] = "SCO";

const bluetooth::legacy::hci::Interface& GetLegacyHciInterface() {
  return bluetooth::legacy::hci::GetInterface();
}

};  // namespace

/******************************************************************************/
@@ -333,7 +342,7 @@ tBTM_STATUS BTM_CreateSco(const RawAddress* remote_bda, bool is_orig,
  enh_esco_params_t* p_setup;
  tSCO_CONN* p = &btm_cb.sco_cb.sco_db[0];
  uint16_t xx;
  uint16_t acl_handle = 0;
  uint16_t acl_handle = HCI_INVALID_HANDLE;
  *p_sco_inx = BTM_INVALID_SCO_INDEX;

  if (BTM_MAX_SCO_LINKS == 0) {
@@ -461,7 +470,11 @@ tBTM_STATUS BTM_CreateSco(const RawAddress* remote_bda, bool is_orig,

      *p_sco_inx = xx;
      LOG_DEBUG("SCO connection successfully requested");
      BTM_LogHistory(kBtmLogTag, *remote_bda, "Connecting", "local initiated");
      if (p->state == SCO_ST_CONNECTING) {
        BTM_LogHistory(
            kBtmLogTag, *remote_bda, "Connecting",
            base::StringPrintf("local initiated acl:0x%04x", acl_handle));
      }
      return BTM_CMD_STARTED;
    }
  }
@@ -768,7 +781,6 @@ void btm_sco_connected(uint8_t hci_status, const RawAddress* bda,
 ******************************************************************************/
tBTM_STATUS BTM_RemoveSco(uint16_t sco_inx) {
  tSCO_CONN* p = &btm_cb.sco_cb.sco_db[sco_inx];
  uint16_t tempstate;
  tBTM_PM_STATE state = BTM_PM_ST_INVALID;

  BTM_TRACE_DEBUG("%s", __func__);
@@ -797,13 +809,17 @@ tBTM_STATUS BTM_RemoveSco(uint16_t sco_inx) {
    return (BTM_CMD_STARTED);
  }

  tempstate = p->state;
  tSCO_STATE old_state = p->state;
  p->state = SCO_ST_DISCONNECTING;

  acl_disconnect_from_handle(p->hci_handle, HCI_ERR_PEER_USER);
  BTM_LogHistory(kBtmLogTag, p->esco.data.bd_addr, "Disconnecting",
                 "local initiated");
  GetLegacyHciInterface().Disconnect(p->Handle(), HCI_ERR_PEER_USER);

  LOG_DEBUG("Disconnecting link sco_handle:0x%04x peer:%s", p->Handle(),
            PRIVATE_ADDRESS(p->esco.data.bd_addr));
  BTM_LogHistory(
      kBtmLogTag, p->esco.data.bd_addr, "Disconnecting",
      base::StringPrintf("local initiated handle:0x%04x previous_state:%s",
                         p->Handle(), sco_state_text(old_state).c_str()));
  return (BTM_CMD_STARTED);
}

Loading