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

Commit ea71d39f authored by Chris Manton's avatar Chris Manton Committed by Automerger Merge Worker
Browse files

Merge changes If5f6b231,I8c5eb4bb,I01aa1955 am: b81bf9d9

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

Change-Id: Iba49f3d4d1fa8afa9efb14987d629c16ba3b4fa4
parents 97cf0a34 b81bf9d9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1015,7 +1015,7 @@ static uint8_t convert_api_sndcmd_param(const tBTA_HH_CMD_DATA& api_sndcmd) {
void bta_hh_write_dev_act(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) {
  tBTA_HH_CBDATA cbdata = {BTA_HH_OK, 0};
  uint16_t event = (p_data->api_sndcmd.t_type - BTA_HH_FST_BTE_TRANS_EVT) +
                   BTA_HH_FST_TRANS_CB_EVT;
                   BTA_HH_GET_RPT_EVT;

  if (p_cb->is_le_device)
    bta_hh_le_write_dev_act(p_cb, p_data);
+0 −1
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@ typedef uint16_t tBTA_HH_INT_EVT; /* HID host internal events */
#define BTA_HH_INVALID_EVT (BTA_HH_DISC_CMPL_EVT + 1)

/* event used to map between BTE event and BTA event */
#define BTA_HH_FST_TRANS_CB_EVT BTA_HH_GET_RPT_EVT
#define BTA_HH_FST_BTE_TRANS_EVT HID_TRANS_GET_REPORT

/* sub event code used for device maintainence API call */
+1 −1
Original line number Diff line number Diff line
@@ -222,7 +222,7 @@ void bta_hh_sm_execute(tBTA_HH_DEV_CB* p_cb, uint16_t event,
          break;
        case BTA_HH_API_WRITE_DEV_EVT:
          cback_event = (p_data->api_sndcmd.t_type - BTA_HH_FST_BTE_TRANS_EVT) +
                        BTA_HH_FST_TRANS_CB_EVT;
                        BTA_HH_GET_RPT_EVT;
          osi_free_and_reset((void**)&p_data->api_sndcmd.p_data);
          if (p_data->api_sndcmd.t_type == HID_TRANS_SET_PROTOCOL ||
              p_data->api_sndcmd.t_type == HID_TRANS_SET_REPORT ||
+49 −42
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include "device/include/interop.h"
#include "osi/include/osi.h"
#include "stack/include/acl_api.h"
#include "stack/include/btm_client_interface.h"
#include "types/raw_address.h"

/* if SSR max latency is not defined by remote device, set the default value
@@ -37,6 +38,12 @@
 *  Constants
 ****************************************************************************/

namespace {

constexpr uint16_t kSsrMaxLatency = 18; /* slots * 0.625ms */

}  // namespace

/*******************************************************************************
 *
 * Function         bta_hh_find_cb
@@ -232,18 +239,24 @@ bool bta_hh_tod_spt(tBTA_HH_DEV_CB* p_cb, uint8_t sub_class) {
tBTA_HH_STATUS bta_hh_read_ssr_param(const RawAddress& bd_addr,
                                     uint16_t* p_max_ssr_lat,
                                     uint16_t* p_min_ssr_tout) {
  tBTA_HH_STATUS status = BTA_HH_ERR;
  tBTA_HH_CB* p_cb = &bta_hh_cb;
  uint8_t i;
  uint16_t ssr_max_latency;
  for (i = 0; i < BTA_HH_MAX_KNOWN; i++) {
    if (p_cb->kdev[i].addr == bd_addr) {
  tBTA_HH_DEV_CB* p_cb = bta_hh_get_cb(bd_addr);
  if (p_cb == nullptr) {
    LOG_WARN("Unable to find device:%s", PRIVATE_ADDRESS(bd_addr));
    return BTA_HH_ERR;
  }

  /* if remote device does not have HIDSSRHostMaxLatency attribute in SDP,
     set SSR max latency default value here.  */
      if (p_cb->kdev[i].dscp_info.ssr_max_latency == HID_SSR_PARAM_INVALID) {
  if (p_cb->dscp_info.ssr_max_latency == HID_SSR_PARAM_INVALID) {
    /* The default is calculated as half of link supervision timeout.*/

        BTM_GetLinkSuperTout(p_cb->kdev[i].addr, &ssr_max_latency);
    uint16_t ssr_max_latency;
    if (get_btm_client_interface().link_controller.BTM_GetLinkSuperTout(
            p_cb->addr, &ssr_max_latency) != BTM_SUCCESS) {
      LOG_WARN("Unable to get supervision timeout for peer:%s",
               PRIVATE_ADDRESS(p_cb->addr));
      return BTA_HH_ERR;
    }
    ssr_max_latency = BTA_HH_GET_DEF_SSR_MAX_LAT(ssr_max_latency);

    /* per 1.1 spec, if the newly calculated max latency is greater than
@@ -256,28 +269,22 @@ tBTA_HH_STATUS bta_hh_read_ssr_param(const RawAddress& bd_addr,
    if (btif_storage_get_stored_remote_name(bd_addr, remote_name)) {
      if (interop_match_name(INTEROP_HID_HOST_LIMIT_SNIFF_INTERVAL,
                             remote_name)) {
            if (ssr_max_latency > 18 /* slots * 0.625ms */) {
              ssr_max_latency = 18;
        if (ssr_max_latency > kSsrMaxLatency /* slots * 0.625ms */) {
          ssr_max_latency = kSsrMaxLatency;
        }
      }
    }

    *p_max_ssr_lat = ssr_max_latency;
  } else
        *p_max_ssr_lat = p_cb->kdev[i].dscp_info.ssr_max_latency;
    *p_max_ssr_lat = p_cb->dscp_info.ssr_max_latency;

      if (p_cb->kdev[i].dscp_info.ssr_min_tout == HID_SSR_PARAM_INVALID)
  if (p_cb->dscp_info.ssr_min_tout == HID_SSR_PARAM_INVALID)
    *p_min_ssr_tout = BTA_HH_SSR_MIN_TOUT_DEF;
  else
        *p_min_ssr_tout = p_cb->kdev[i].dscp_info.ssr_min_tout;

      status = BTA_HH_OK;

      break;
    }
  }
    *p_min_ssr_tout = p_cb->dscp_info.ssr_min_tout;

  return status;
  return BTA_HH_OK;
}

/*******************************************************************************
+8 −7
Original line number Diff line number Diff line
@@ -1117,14 +1117,15 @@ void btm_establish_continue_from_address(const RawAddress& bda,
 ******************************************************************************/
tBTM_STATUS BTM_GetLinkSuperTout(const RawAddress& remote_bda,
                                 uint16_t* p_timeout) {
  tACL_CONN* p = internal_.btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
  if (p != (tACL_CONN*)NULL) {
    *p_timeout = p->link_super_tout;
    return (BTM_SUCCESS);
  }
  CHECK(p_timeout != nullptr);
  const tACL_CONN* p_acl =
      internal_.btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
  if (p_acl == nullptr) {
    LOG_WARN("Unable to find active acl");
  /* If here, no BD Addr found */
  return (BTM_UNKNOWN_ADDR);
    return BTM_UNKNOWN_ADDR;
  }
  *p_timeout = p_acl->link_super_tout;
  return BTM_SUCCESS;
}

/*******************************************************************************