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

Commit 7fe6e532 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 7360053 from d468f80c to sc-release

Change-Id: Icc8f8e65e42acb13373d7b1f199fc27cc84ce4bd
parents a904775f d468f80c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1014,8 +1014,8 @@ 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;
  uint16_t event =
      (p_data->api_sndcmd.t_type - HID_TRANS_GET_REPORT) + BTA_HH_GET_RPT_EVT;

  if (p_cb->is_le_device)
    bta_hh_le_write_dev_act(p_cb, p_data);
+2 −30
Original line number Diff line number Diff line
@@ -33,11 +33,8 @@
#include "bta/sys/bta_sys.h"
#include "stack/include/bt_types.h"

/* can be moved to bta_api.h */
#define BTA_HH_MAX_RPT_CHARS 8

/* state machine events, these events are handled by the state machine */
enum {
enum tBTA_HH_INT_EVT : uint16_t {
  BTA_HH_API_OPEN_EVT = BTA_SYS_EVT_START(BTA_ID_HH),
  BTA_HH_API_CLOSE_EVT,
  BTA_HH_INT_OPEN_EVT,
@@ -60,19 +57,10 @@ enum {
  BTA_HH_API_ENABLE_EVT,
  BTA_HH_API_DISABLE_EVT,
  BTA_HH_DISC_CMPL_EVT
};
typedef uint16_t tBTA_HH_INT_EVT; /* HID host internal events */
}; /* 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 */
#define BTA_HH_ADD_DEV 0
#define BTA_HH_REMOVE_DEV 1

/* state machine states */
enum {
  BTA_HH_NULL_ST,
@@ -213,7 +201,6 @@ typedef struct {
  bool in_use;                 /* control block currently in use */
  bool incoming_conn;          /* is incoming connection? */
  uint8_t incoming_hid_handle; /* temporary handle for incoming connection? */
  bool opened; /* true if device successfully opened HID connection */
  tBTA_HH_PROTO_MODE mode; /* protocol mode */
  tBTA_HH_STATE state;     /* CB state */

@@ -230,33 +217,19 @@ typedef struct {
  uint16_t conn_id;
  bool in_bg_conn;
  uint8_t clt_cfg_idx;
  uint16_t scan_refresh_char_handle;
  bool scps_supported;

#define BTA_HH_LE_SCPS_NOTIFY_NONE 0
#define BTA_HH_LE_SCPS_NOTIFY_SPT 0x01
#define BTA_HH_LE_SCPS_NOTIFY_ENB 0x02
  uint8_t scps_notify; /* scan refresh supported/notification enabled */

  bool security_pending;
} tBTA_HH_DEV_CB;

/* key board parsing control block */
typedef struct {
  bool mod_key[4]; /* ctrl, shift(upper), Alt, GUI */
  bool num_lock;
  bool caps_lock;
  uint8_t last_report[BTA_HH_MAX_RPT_CHARS];
} tBTA_HH_KB_CB;

/******************************************************************************
 * Main Control Block
 ******************************************************************************/
typedef struct {
  tBTA_HH_KB_CB kb_cb;                    /* key board control block,
                                             suppose BTA will connect
                                             to only one keyboard at
                                              the same time */
  tBTA_HH_DEV_CB kdev[BTA_HH_MAX_DEVICE]; /* device control block */
  tBTA_HH_DEV_CB* p_cur;                  /* current device control
                                                 block idx, used in sdp */
@@ -267,7 +240,6 @@ typedef struct {
  tGATT_IF gatt_if;
  tBTA_HH_CBACK* p_cback; /* Application callbacks */
  tSDP_DISCOVERY_DB* p_disc_db;
  uint8_t trace_level; /* tracing level */
  uint8_t cnt_num;     /* connected device number */
  bool w4_disable;     /* w4 disable flag */
} tBTA_HH_CB;
+0 −2
Original line number Diff line number Diff line
@@ -1469,11 +1469,9 @@ static void bta_hh_le_srvc_search_cmpl(tBTA_GATTC_SEARCH_CMPL* p_data) {
      APPL_TRACE_DEBUG("%s: have HID service inst_id= %d", __func__,
                       p_dev_cb->hid_srvc.srvc_inst_id);
    } else if (service.uuid == Uuid::From16Bit(UUID_SERVCLASS_SCAN_PARAM)) {
      p_dev_cb->scan_refresh_char_handle = 0;

      for (const gatt::Characteristic& charac : service.characteristics) {
        if (charac.uuid == Uuid::From16Bit(GATT_UUID_SCAN_REFRESH)) {
          p_dev_cb->scan_refresh_char_handle = charac.value_handle;

          if (charac.properties & GATT_CHAR_PROP_BIT_NOTIFY)
            p_dev_cb->scps_notify |= BTA_HH_LE_SCPS_NOTIFY_SPT;
+3 −3
Original line number Diff line number Diff line
@@ -189,7 +189,7 @@ void bta_hh_sm_execute(tBTA_HH_DEV_CB* p_cb, uint16_t event,
  tBTA_HH cback_data;
  tBTA_HH_EVT cback_event = 0;
  tBTA_HH_STATE in_state;
  uint16_t debug_event = event;
  tBTA_HH_INT_EVT debug_event = static_cast<tBTA_HH_INT_EVT>(event);

  memset(&cback_data, 0, sizeof(tBTA_HH));

@@ -221,8 +221,8 @@ 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;
          cback_event = (p_data->api_sndcmd.t_type - HID_TRANS_GET_REPORT) +
                        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;
}

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