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

Commit b6a3b877 authored by Zach Johnson's avatar Zach Johnson Committed by Gerrit Code Review
Browse files

Merge changes I8fc751c7,Id99b76d8,I9c17bdfb,I8ecb755b,Iceebe867, ...

* changes:
  btm_acl_report_role_change does nothing, remove it
  p_switch_role_cb is never set to anything other than null
  callback param to BTM_SwitchRole is always null, remove it
  bta_dm_check_av is only called with 0
  bta_dm_check_av(BTA_DM_API_SEARCH_EVT) will never return true
  Remove BTA_DM_AVOID_A2DP_ROLESWITCH_ON_INQUIRY, it's always true
  Don't set link policy from btm_sec_connected
parents 4f4a081c a56e06ec
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1102,7 +1102,7 @@ bool bta_av_switch_if_needed(tBTA_AV_SCB* p_scb) {
        if (bta_av_cb.features & BTA_AV_FEAT_MASTER)
          BTA_dm_block_role_switch_for(p_scbi->PeerAddress());
        if (BTM_CMD_STARTED !=
            BTM_SwitchRole(p_scbi->PeerAddress(), HCI_ROLE_MASTER, NULL)) {
            BTM_SwitchRole(p_scbi->PeerAddress(), HCI_ROLE_MASTER)) {
          /* can not switch role on SCBI
           * start the timer on SCB - because this function is ONLY called when
           * SCB gets API_OPEN */
@@ -1147,7 +1147,7 @@ bool bta_av_link_role_ok(tBTA_AV_SCB* p_scb, uint8_t bits) {
        BTA_dm_block_role_switch_for(p_scb->PeerAddress());

      tBTM_STATUS status =
          BTM_SwitchRole(p_scb->PeerAddress(), HCI_ROLE_MASTER, NULL);
          BTM_SwitchRole(p_scb->PeerAddress(), HCI_ROLE_MASTER);
      if (status != BTM_CMD_STARTED) {
        /* can not switch role on SCB - start the timer on SCB */
        LOG_ERROR("%s: peer %s BTM_SwitchRole(HCI_ROLE_MASTER) error: %d",
+9 −56
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ static uint8_t bta_dm_authentication_complete_cback(const RawAddress& bd_addr,
                                                    BD_NAME bd_name,
                                                    int result);
static void bta_dm_local_name_cback(void* p_name);
static bool bta_dm_check_av(uint16_t event);
static void bta_dm_check_av();

void BTA_dm_update_policy(tBTA_SYS_CONN_STATUS status, uint8_t id,
                          uint8_t app_id, const RawAddress& peer_addr);
@@ -871,14 +871,6 @@ void bta_dm_search_start(tBTA_DM_MSG* p_data) {
  APPL_TRACE_DEBUG("%s avoid_scatter=%d", __func__,
                   p_bta_dm_cfg->avoid_scatter);

  if (p_bta_dm_cfg->avoid_scatter &&
      (p_data->search.rs_res == BTA_DM_RS_NONE) &&
      bta_dm_check_av(BTA_DM_API_SEARCH_EVT)) {
    LOG(INFO) << __func__ << ": delay search to avoid scatter";
    memcpy(&bta_dm_cb.search_msg, &p_data->search, sizeof(tBTA_DM_API_SEARCH));
    return;
  }

  BTM_ClearInqDb(nullptr);
  /* save search params */
  bta_dm_search_cb.p_search_cback = p_data->search.p_cback;
@@ -2524,7 +2516,7 @@ static void handle_role_change(const RawAddress& bd_addr, uint8_t new_role,
      /* more than one connections and the AV connection is role switched
       * to slave
       * switch it back to master and remove the switch policy */
      BTM_SwitchRole(bd_addr, HCI_ROLE_MASTER, NULL);
      BTM_SwitchRole(bd_addr, HCI_ROLE_MASTER);
      need_policy_change = true;
    } else if (p_bta_dm_cfg->avoid_scatter && (new_role == HCI_ROLE_MASTER)) {
      /* if the link updated to be master include AV activities, remove
@@ -2539,7 +2531,7 @@ static void handle_role_change(const RawAddress& bd_addr, uint8_t new_role,
    /* there's AV no activity on this link and role switch happened
     * check if AV is active
     * if so, make sure the AV link is master */
    bta_dm_check_av(0);
    bta_dm_check_av();
  }
  bta_sys_notify_role_chg(bd_addr, new_role, hci_status);
}
@@ -2701,25 +2693,6 @@ void BTA_dm_acl_down(const RawAddress bd_addr, tBT_TRANSPORT transport) {
  do_in_main_thread(FROM_HERE, base::Bind(bta_dm_acl_down, bd_addr, transport));
}

/*******************************************************************************
 *
 * Function         bta_dm_rs_cback
 *
 * Description      Receives the role switch complete event
 *
 * Returns
 *
 ******************************************************************************/
static void bta_dm_rs_cback(UNUSED_ATTR void* p1) {
  APPL_TRACE_WARNING("bta_dm_rs_cback:%d", bta_dm_cb.rs_event);
  if (bta_dm_cb.rs_event == BTA_DM_API_SEARCH_EVT) {
    bta_dm_cb.search_msg.rs_res =
        BTA_DM_RS_OK; /* do not care about the result for now */
    bta_dm_cb.rs_event = 0;
    bta_dm_search_start((tBTA_DM_MSG*)&bta_dm_cb.search_msg);
  }
}

/*******************************************************************************
 *
 * Function         bta_dm_check_av
@@ -2727,47 +2700,27 @@ static void bta_dm_rs_cback(UNUSED_ATTR void* p1) {
 * Description      This function checks if AV is active
 *                  if yes, make sure the AV link is master
 *
 * Returns          bool - true, if switch is in progress
 *
 ******************************************************************************/
static bool bta_dm_check_av(uint16_t event) {
  bool avoid_roleswitch = false;
  bool switching = false;
static void bta_dm_check_av() {
  uint8_t i;
  tBTA_DM_PEER_DEVICE* p_dev;

#if (BTA_DM_AVOID_A2DP_ROLESWITCH_ON_INQUIRY == TRUE)

  /* avoid role switch upon inquiry if a2dp is actively streaming as it
     introduces an audioglitch due to FW scheduling delays (unavoidable) */
  if (event == BTA_DM_API_SEARCH_EVT) {
    avoid_roleswitch = true;
  }
#endif

  APPL_TRACE_WARNING("bta_dm_check_av:%d", bta_dm_cb.cur_av_count);
  if (bta_dm_cb.cur_av_count) {
    for (i = 0; i < bta_dm_cb.device_list.count; i++) {
      p_dev = &bta_dm_cb.device_list.peer_device[i];
      APPL_TRACE_WARNING("[%d]: state:%d, info:x%x, avoid_rs %d", i,
                         p_dev->conn_state, p_dev->info, avoid_roleswitch);
      APPL_TRACE_WARNING("[%d]: state:%d, info:x%x", i, p_dev->conn_state,
                         p_dev->info);
      if ((p_dev->conn_state == BTA_DM_CONNECTED) &&
          (p_dev->info & BTA_DM_DI_AV_ACTIVE) && (!avoid_roleswitch)) {
          (p_dev->info & BTA_DM_DI_AV_ACTIVE)) {
        /* make master and take away the role switch policy */
        if (BTM_CMD_STARTED == BTM_SwitchRole(p_dev->peer_bdaddr,
                                              HCI_ROLE_MASTER,
                                              bta_dm_rs_cback)) {
          /* the role switch command is actually sent */
          bta_dm_cb.rs_event = event;
          switching = true;
        }
        BTM_SwitchRole(p_dev->peer_bdaddr, HCI_ROLE_MASTER);
        /* else either already master or can not switch for some reasons */
        BTA_dm_block_role_switch_for(p_dev->peer_bdaddr);
        break;
      }
    }
  }
  return switching;
}

/*******************************************************************************
@@ -2972,7 +2925,7 @@ static void bta_dm_adjust_roles(bool delay_role_switch) {
                  BTA_SLAVE_ROLE_ONLY &&
              !delay_role_switch) {
            BTM_SwitchRole(bta_dm_cb.device_list.peer_device[i].peer_bdaddr,
                           HCI_ROLE_MASTER, NULL);
                           HCI_ROLE_MASTER);
          } else {
            alarm_set_on_mloop(bta_dm_cb.switch_delay_timer,
                               BTA_DM_SWITCH_DELAY_TIMER_MS,
+0 −1
Original line number Diff line number Diff line
@@ -296,7 +296,6 @@ typedef struct {
  uint8_t num_master_only;
  uint8_t pm_id;
  tBTA_PM_TIMER pm_timer[BTA_DM_NUM_PM_TIMER];
  uint16_t rs_event;      /* the event waiting for role switch */
  uint8_t cur_av_count;   /* current AV connecions */
  bool disable_pair_mode; /* disable pair mode or not */
  bool conn_paired_only;  /* allow connectable to paired device only or not */
+0 −4
Original line number Diff line number Diff line
@@ -1230,10 +1230,6 @@
  "5)),(\"roam\",(0,1)),(\"battchg\",(0-5)),(\"callheld\",(0-2))"
#endif

#ifndef BTA_DM_AVOID_A2DP_ROLESWITCH_ON_INQUIRY
#define BTA_DM_AVOID_A2DP_ROLESWITCH_ON_INQUIRY TRUE
#endif

/******************************************************************************
 *
 * Tracing:  Include trace header file here.
+2 −5
Original line number Diff line number Diff line
@@ -1209,9 +1209,7 @@ tBTM_STATUS BTM_GetRole(const RawAddress& remote_bd_addr, uint8_t* p_role);
 * Function         BTM_SwitchRole
 *
 * Description      This function is called to switch role between master and
 *                  slave.  If role is already set it will do nothing.  If the
 *                  command was initiated, the callback function is called upon
 *                  completion.
 *                  slave.  If role is already set it will do nothing.
 *
 * Returns          BTM_SUCCESS if already in specified role.
 *                  BTM_CMD_STARTED if command issued to controller.
@@ -1222,8 +1220,7 @@ tBTM_STATUS BTM_GetRole(const RawAddress& remote_bd_addr, uint8_t* p_role);
 *                                       role switching
 *
 ******************************************************************************/
tBTM_STATUS BTM_SwitchRole(const RawAddress& remote_bd_addr, uint8_t new_role,
                           tBTM_CMPL_CB* p_cb);
tBTM_STATUS BTM_SwitchRole(const RawAddress& remote_bd_addr, uint8_t new_role);

/*******************************************************************************
 *
Loading