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

Commit a6a7b8d9 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

Remove l2cap fixed channel socket

The spec says in LE only ATT and SMP use fixed channel, and in classic
only SMP_BR uses fixed channel. Don't expose the socket API to java.

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I05e50e53ef9cc3b283cc6c19f74b05cb20b369ce
parent 353e6857
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -487,22 +487,6 @@ tBTA_JV_STATUS BTA_JvCreateRecordByUser(uint32_t rfcomm_slot_id);
 ******************************************************************************/
tBTA_JV_STATUS BTA_JvDeleteRecord(uint32_t handle);

/*******************************************************************************
 *
 * Function         BTA_JvL2capConnectLE
 *
 * Description      Initiate a connection as an LE L2CAP client to the given BD
 *                  Address.
 *                  When the connection is initiated or failed to initiate,
 *                  tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_CL_INIT_EVT
 *                  When the connection is established or failed,
 *                  tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT
 *
 ******************************************************************************/
void BTA_JvL2capConnectLE(uint16_t remote_chan, const RawAddress& peer_bd_addr,
                          tBTA_JV_L2CAP_CBACK* p_cback,
                          uint32_t l2cap_socket_id);

/*******************************************************************************
 *
 * Function         BTA_JvL2capConnect
+0 −21
Original line number Diff line number Diff line
@@ -209,27 +209,6 @@ tBTA_JV_STATUS BTA_JvDeleteRecord(uint32_t handle) {
  return BTA_JV_SUCCESS;
}

/*******************************************************************************
 *
 * Function         BTA_JvL2capConnectLE
 *
 * Description      Initiate an LE connection as a L2CAP client to the given BD
 *                  Address.
 *                  When the connection is initiated or failed to initiate,
 *                  tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_CL_INIT_EVT
 *                  When the connection is established or failed,
 *                  tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT
 *
 ******************************************************************************/
void BTA_JvL2capConnectLE(uint16_t remote_chan, const RawAddress& peer_bd_addr,
                          tBTA_JV_L2CAP_CBACK* p_cback,
                          uint32_t l2cap_socket_id) {
  VLOG(2) << __func__;
  CHECK(p_cback);
  do_in_main_thread(FROM_HERE, Bind(&bta_jv_l2cap_connect_le, remote_chan,
                                    peer_bd_addr, p_cback, l2cap_socket_id));
}

/*******************************************************************************
 *
 * Function         BTA_JvL2capConnect
+0 −2
Original line number Diff line number Diff line
@@ -9,8 +9,6 @@

#include <hardware/bluetooth.h>

#define L2CAP_MASK_FIXED_CHANNEL 0x10000

bt_status_t btsock_l2cap_init(int handle, uid_set_t* set);
bt_status_t btsock_l2cap_cleanup();
bt_status_t btsock_l2cap_listen(const char* name, int channel, int* sock_fd,
+1 −16
Original line number Diff line number Diff line
@@ -871,20 +871,10 @@ static bt_status_t btsock_l2cap_listen_or_connect(const char* name,
                                                  int channel, int* sock_fd,
                                                  int flags, char listen,
                                                  int app_uid) {
  int fixed_chan = 1;
  bool is_le_coc = false;
  bool is_le_coc = (flags & BTSOCK_FLAG_LE_COC) != 0;

  if (!sock_fd) return BT_STATUS_PARM_INVALID;

  if (channel < 0) {
    // We need to auto assign a PSM
    fixed_chan = 0;
  } else {
    is_le_coc = (flags & BTSOCK_FLAG_LE_COC) != 0;
    fixed_chan = (channel & L2CAP_MASK_FIXED_CHANNEL) != 0;
    channel &= ~L2CAP_MASK_FIXED_CHANNEL;
  }

  if (!is_inited()) return BT_STATUS_NOT_READY;

  // TODO: This is kind of bad to lock here, but it is needed for the current
@@ -895,7 +885,6 @@ static bt_status_t btsock_l2cap_listen_or_connect(const char* name,
    return BT_STATUS_NOMEM;
  }

  sock->fixed_chan = fixed_chan;
  sock->channel = channel;
  sock->app_uid = app_uid;
  sock->is_le_coc = is_le_coc;
@@ -904,9 +893,6 @@ static bt_status_t btsock_l2cap_listen_or_connect(const char* name,
  /* "role" is never initialized in rfcomm code */
  if (listen) {
    btsock_l2cap_server_listen(sock);
  } else {
    if (fixed_chan) {
      BTA_JvL2capConnectLE(channel, sock->addr, btsock_l2cap_cbk, sock->id);
  } else {
      int connection_type =
          sock->is_le_coc ? BTA_JV_CONN_TYPE_L2CAP_LE : BTA_JV_CONN_TYPE_L2CAP;
@@ -924,7 +910,6 @@ static bt_status_t btsock_l2cap_listen_or_connect(const char* name,
          connection_type, sock->security, 0, std::move(ertm_info), channel,
          sock->rx_mtu, std::move(cfg), sock->addr, btsock_l2cap_cbk, sock->id);
  }
  }

  *sock_fd = sock->app_fd;
  /* We pass the FD to JAVA, but since it runs in another process, we need to