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

Commit 31b55918 authored by Hansong Zhang's avatar Hansong Zhang Committed by android-build-merger
Browse files

Merge changes I1abcf94d,I720b8a16 am: 05897671 am: 1ef7a1c3

am: 6ff3e8f8

Change-Id: If15a31804a1d9a94e562c5c1c277a40f92fa5de2
parents eb0b7e90 6ff3e8f8
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -773,11 +773,6 @@
#define SDP_SERVICE_NAME "Service Discovery"
#endif

/* The security level for BTM. */
#ifndef SDP_SECURITY_LEVEL
#define SDP_SECURITY_LEVEL BTM_SEC_NONE
#endif

/******************************************************************************
 *
 * RFCOMM
+0 −17
Original line number Diff line number Diff line
@@ -239,23 +239,6 @@ uint8_t bluetooth::shim::L2CA_SetDesireRole(uint8_t new_role) {
  return 0;
}

/**
 * Ping APIs
 */
bool bluetooth::shim::L2CA_Ping(const RawAddress& p_bd_addr,
                                tL2CA_ECHO_RSP_CB* p_callback) {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s addr:%s p_callback:%p", __func__,
           p_bd_addr.ToString().c_str(), p_callback);
  return false;
}

bool bluetooth::shim::L2CA_Echo(const RawAddress& p_bd_addr, BT_HDR* p_data,
                                tL2CA_ECHO_DATA_CB* p_callback) {
  LOG_INFO(LOG_TAG, "UNIMPLEMENTED %s addr:%s p_callback:%p", __func__,
           p_bd_addr.ToString().c_str(), p_callback);
  return false;
}

/**
 * Link APIs
 */
+0 −24
Original line number Diff line number Diff line
@@ -287,30 +287,6 @@ bool L2CA_DisconnectRsp(uint16_t cid);
 ******************************************************************************/
uint8_t L2CA_DataWrite(uint16_t cid, BT_HDR* p_data);

/*******************************************************************************
 *
 * Function         L2CA_Ping
 *
 * Description      Higher layers call this function to send an echo request.
 *
 * Returns          true if echo request sent, else false.
 *
 ******************************************************************************/
bool L2CA_Ping(const RawAddress& p_bd_addr, tL2CA_ECHO_RSP_CB* p_cb);

/*******************************************************************************
 *
 * Function         L2CA_Echo
 *
 * Description      Higher layers call this function to send an echo request
 *                  with application-specific data.
 *
 * Returns          true if echo request sent, else false.
 *
 ******************************************************************************/
bool L2CA_Echo(const RawAddress& p_bd_addr, BT_HDR* p_data,
               tL2CA_ECHO_DATA_CB* p_callback);

// Given a local channel identifier, |lcid|, this function returns the bound
// remote channel identifier, |rcid|, and the ACL link handle, |handle|. If
// |lcid| is not known or is invalid, this function returns false and does not
+0 −24
Original line number Diff line number Diff line
@@ -611,30 +611,6 @@ extern bool L2CA_DisconnectRsp(uint16_t cid);
 ******************************************************************************/
extern uint8_t L2CA_DataWrite(uint16_t cid, BT_HDR* p_data);

/*******************************************************************************
 *
 * Function         L2CA_Ping
 *
 * Description      Higher layers call this function to send an echo request.
 *
 * Returns          true if echo request sent, else false.
 *
 ******************************************************************************/
extern bool L2CA_Ping(const RawAddress& p_bd_addr, tL2CA_ECHO_RSP_CB* p_cb);

/*******************************************************************************
 *
 * Function         L2CA_Echo
 *
 * Description      Higher layers call this function to send an echo request
 *                  with application-specific data.
 *
 * Returns          true if echo request sent, else false.
 *
 ******************************************************************************/
extern bool L2CA_Echo(const RawAddress& p_bd_addr, BT_HDR* p_data,
                      tL2CA_ECHO_DATA_CB* p_callback);

// Given a local channel identifier, |lcid|, this function returns the bound
// remote channel identifier, |rcid|, and the ACL link handle, |handle|. If
// |lcid| is not known or is invalid, this function returns false and does not
+0 −120
Original line number Diff line number Diff line
@@ -1033,126 +1033,6 @@ bool L2CA_DisconnectRsp(uint16_t cid) {
  return (true);
}

/*******************************************************************************
 *
 * Function         L2CA_Ping
 *
 * Description      Higher layers call this function to send an echo request.
 *
 * Returns          true if echo request sent, else false.
 *
 ******************************************************************************/
bool L2CA_Ping(const RawAddress& p_bd_addr, tL2CA_ECHO_RSP_CB* p_callback) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::L2CA_Ping(p_bd_addr, p_callback);
  }

  tL2C_LCB* p_lcb;

  VLOG(1) << __func__ << " BDA: " << p_bd_addr;

  /* Fail if we have not established communications with the controller */
  if (!BTM_IsDeviceUp()) return (false);

  /* First, see if we already have a link to the remote */
  p_lcb = l2cu_find_lcb_by_bd_addr(p_bd_addr, BT_TRANSPORT_BR_EDR);
  if (p_lcb == NULL) {
    /* No link. Get an LCB and start link establishment */
    p_lcb = l2cu_allocate_lcb(p_bd_addr, false, BT_TRANSPORT_BR_EDR);
    if (p_lcb == NULL) {
      L2CAP_TRACE_WARNING("L2CAP - no LCB for L2CA_ping");
      return (false);
    }
    if (!l2cu_create_conn_br_edr(p_lcb)) {
      return (false);
    }

    p_lcb->p_echo_rsp_cb = p_callback;

    return (true);
  }

  /* We only allow 1 ping outstanding at a time */
  if (p_lcb->p_echo_rsp_cb != NULL) {
    L2CAP_TRACE_WARNING("L2CAP - rejected second L2CA_ping");
    return (false);
  }

  /* Have a link control block. If link is disconnecting, tell user to retry
   * later */
  if (p_lcb->link_state == LST_DISCONNECTING) {
    L2CAP_TRACE_WARNING("L2CAP - L2CA_ping rejected - link disconnecting");
    return (false);
  }

  /* Save address of callback */
  p_lcb->p_echo_rsp_cb = p_callback;

  if (p_lcb->link_state == LST_CONNECTED) {
    l2cu_adj_id(p_lcb, L2CAP_ADJ_BRCM_ID); /* Make sure not using Broadcom ID */
    l2cu_send_peer_echo_req(p_lcb, NULL, 0);
    alarm_set_on_mloop(p_lcb->l2c_lcb_timer, L2CAP_ECHO_RSP_TIMEOUT_MS,
                       l2c_lcb_timer_timeout, p_lcb);
  }

  return (true);
}

/*******************************************************************************
 *
 * Function         L2CA_Echo
 *
 * Description      Higher layers call this function to send an echo request
 *                  with application-specific data.
 *
 * Returns          true if echo request sent, else false.
 *
 ******************************************************************************/
bool L2CA_Echo(const RawAddress& p_bd_addr, BT_HDR* p_data,
               tL2CA_ECHO_DATA_CB* p_callback) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::L2CA_Echo(p_bd_addr, p_data, p_callback);
  }

  tL2C_LCB* p_lcb;
  uint8_t* pp;

  VLOG(1) << __func__ << " BDA: " << p_bd_addr;
  ;

  /* Fail if we have not established communications with the controller */
  if (!BTM_IsDeviceUp()) return (false);

  if (RawAddress::kAny == p_bd_addr && (p_data == NULL)) {
    /* Only register callback without sending message. */
    l2cb.p_echo_data_cb = p_callback;
    return true;
  }

  /* We assume the upper layer will call this function only when the link is
   * established. */
  p_lcb = l2cu_find_lcb_by_bd_addr(p_bd_addr, BT_TRANSPORT_BR_EDR);
  if (p_lcb == NULL) {
    L2CAP_TRACE_ERROR("L2CA_Echo ERROR : link not established");
    return false;
  }

  if (p_lcb->link_state != LST_CONNECTED) {
    L2CAP_TRACE_ERROR("L2CA_Echo ERROR : link is not connected");
    return false;
  }

  /* Save address of callback */
  l2cb.p_echo_data_cb = p_callback;

  /* Set the pointer to the beginning of the data */
  pp = (uint8_t*)(p_data + 1) + p_data->offset;
  l2cu_adj_id(p_lcb, L2CAP_ADJ_BRCM_ID); /* Make sure not using Broadcom ID */
  l2cu_send_peer_echo_req(p_lcb, pp, p_data->len);

  return (true);
}

bool L2CA_GetIdentifiers(uint16_t lcid, uint16_t* rcid, uint16_t* handle) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::L2CA_GetIdentifiers(lcid, rcid, handle);
Loading