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

Commit 986fb371 authored by Amitesh Chandra's avatar Amitesh Chandra Committed by Jakub Pawlowski
Browse files

Allow Sniff for HID when (e)SCO active

Currently stack disables sniff for HID link when eSCO is active.
This was needed only for legacy controllers. The current
controllers do not require this change and this change
has an adverse impact on the coex conditions (WLAN+HID+eSCO)

Bug: 188481980
Test: Link policy tests for HID and eSCO
Change-Id: I63c7a3adb5c32087b34f253a503076f83249f3b7
parent fa27e39d
Loading
Loading
Loading
Loading
+0 −50
Original line number Diff line number Diff line
@@ -51,7 +51,6 @@ static bool bta_dm_pm_park(const RawAddress& peer_addr);
void bta_dm_pm_sniff(tBTA_DM_PEER_DEVICE* p_peer_dev, uint8_t index);
static bool bta_dm_pm_is_sco_active();
static int bta_dm_get_sco_index();
static void bta_dm_pm_hid_check(bool bScoActive);
static void bta_dm_pm_stop_timer_by_index(tBTA_PM_TIMER* p_timer,
                                          uint8_t timer_idx);

@@ -470,24 +469,6 @@ static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, uint8_t id,
  }

  bta_dm_pm_set_mode(peer_addr, BTA_DM_PM_NO_ACTION, pm_req);

  /* perform the HID link workaround if needed
  ** 1. If SCO up/down event is received OR
  ** 2. If HID connection open is received and SCO is already active.
  **     This will handle the case where HID connects when SCO already active
  */
  if (BTM_IsDeviceUp() &&
      (((status == BTA_SYS_SCO_OPEN) || (status == BTA_SYS_SCO_CLOSE)) ||
       ((status == BTA_SYS_CONN_OPEN) && (id == BTA_ID_HH) &&
        bta_dm_pm_is_sco_active()))) {
    bool bScoActive;
    if (status == BTA_SYS_CONN_OPEN)
      bScoActive = true;
    else
      bScoActive = (status == BTA_SYS_SCO_OPEN);

    bta_dm_pm_hid_check(bScoActive);
  }
}

/*******************************************************************************
@@ -1108,37 +1089,6 @@ static int bta_dm_get_sco_index() {
  return -1;
}

/*******************************************************************************
 *
 * Function         bta_dm_pm_hid_check
 *
 * Description      Disables/Enables sniff in link policy based on SCO Up/Down
 *
 * Returns          None
 *
 ******************************************************************************/
static void bta_dm_pm_hid_check(bool bScoActive) {
  int j;

  /* if HID is active, disable the link policy */
  for (j = 0; j < bta_dm_conn_srvcs.count; j++) {
    /* check if an entry already present */
    if (bta_dm_conn_srvcs.conn_srvc[j].id == BTA_ID_HH) {
      APPL_TRACE_DEBUG(
          "SCO status change(Active: %d), modify HID link policy. state: %d",
          bScoActive, bta_dm_conn_srvcs.conn_srvc[j].state);
      auto peer_addr = bta_dm_conn_srvcs.conn_srvc[j].peer_bdaddr;
      if (bScoActive) {
        BTM_block_sniff_mode_for(peer_addr);
        bta_dm_pm_active(peer_addr);
      } else {
        BTM_unblock_sniff_mode_for(peer_addr);
        bta_dm_pm_set_mode(peer_addr, BTA_DM_PM_NO_ACTION, BTA_DM_PM_RESTART);
      }
    }
  }
}

/*******************************************************************************
 *
 * Function         bta_dm_pm_obtain_controller_state