* tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT
*
******************************************************************************/
-void BTA_JvL2capConnectLE(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
- const tL2CAP_ERTM_INFO* ertm_info,
- uint16_t remote_chan, uint16_t rx_mtu,
- tL2CAP_CFG_INFO* cfg, const RawAddress& peer_bd_addr,
+void BTA_JvL2capConnectLE(uint16_t remote_chan, const RawAddress& peer_bd_addr,
tBTA_JV_L2CAP_CBACK* p_cback,
uint32_t l2cap_socket_id);
*
******************************************************************************/
void BTA_JvL2capConnect(int conn_type, tBTA_SEC sec_mask, tBTA_JV_ROLE role,
- const tL2CAP_ERTM_INFO* ertm_info, uint16_t remote_psm,
- uint16_t rx_mtu, tL2CAP_CFG_INFO* cfg,
+ std::unique_ptr<tL2CAP_ERTM_INFO> ertm_info,
+ uint16_t remote_psm, uint16_t rx_mtu,
+ std::unique_ptr<tL2CAP_CFG_INFO> cfg,
const RawAddress& peer_bd_addr,
tBTA_JV_L2CAP_CBACK* p_cback, uint32_t l2cap_socket_id);
* tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT
*
******************************************************************************/
-void BTA_JvL2capConnectLE(tBTA_SEC sec_mask, tBTA_JV_ROLE,
- const tL2CAP_ERTM_INFO*, uint16_t remote_chan,
- uint16_t, tL2CAP_CFG_INFO*,
- const RawAddress& peer_bd_addr,
+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__;
*
******************************************************************************/
void BTA_JvL2capConnect(int conn_type, tBTA_SEC sec_mask, tBTA_JV_ROLE role,
- const tL2CAP_ERTM_INFO* ertm_info, uint16_t remote_psm,
- uint16_t rx_mtu, tL2CAP_CFG_INFO* cfg,
+ std::unique_ptr<tL2CAP_ERTM_INFO> ertm_info,
+ uint16_t remote_psm, uint16_t rx_mtu,
+ std::unique_ptr<tL2CAP_CFG_INFO> cfg,
const RawAddress& peer_bd_addr,
tBTA_JV_L2CAP_CBACK* p_cback,
uint32_t l2cap_socket_id) {
VLOG(2) << __func__;
CHECK(p_cback);
- std::unique_ptr<tL2CAP_CFG_INFO> cfg_copy;
- if (cfg) cfg_copy = std::make_unique<tL2CAP_CFG_INFO>(*cfg);
-
- std::unique_ptr<tL2CAP_ERTM_INFO> ertm_info_copy;
- if (ertm_info)
- ertm_info_copy = std::make_unique<tL2CAP_ERTM_INFO>(*ertm_info);
-
- do_in_bta_thread(
- FROM_HERE, Bind(&bta_jv_l2cap_connect, conn_type, sec_mask, role,
- remote_psm, rx_mtu, peer_bd_addr, base::Passed(&cfg_copy),
- base::Passed(&ertm_info_copy), p_cback, l2cap_socket_id));
+ do_in_bta_thread(FROM_HERE,
+ Bind(&bta_jv_l2cap_connect, conn_type, sec_mask, role,
+ remote_psm, rx_mtu, peer_bd_addr, base::Passed(&cfg),
+ base::Passed(&ertm_info), p_cback, l2cap_socket_id));
}
/*******************************************************************************
return;
}
- /* Setup ETM settings: mtu will be set below */
+ /* Setup ETM settings: mtu will be set below */
std::unique_ptr<tL2CAP_CFG_INFO> cfg = std::make_unique<tL2CAP_CFG_INFO>(
tL2CAP_CFG_INFO{.fcr_present = true, .fcr = obex_l2c_fcr_opts_def});
int flags, char listen,
int app_uid) {
int fixed_chan = 1;
- l2cap_socket* sock;
- tL2CAP_CFG_INFO cfg;
bool is_le_coc = false;
if (!sock_fd) return BT_STATUS_PARM_INVALID;
// TODO: This is kind of bad to lock here, but it is needed for the current
// design.
std::unique_lock<std::mutex> lock(state_lock);
- sock = btsock_l2cap_alloc_l(name, addr, listen, flags);
+ l2cap_socket* sock = btsock_l2cap_alloc_l(name, addr, listen, flags);
if (!sock) {
return BT_STATUS_NOMEM;
}
sock->app_uid = app_uid;
sock->is_le_coc = is_le_coc;
- /* Setup ETM settings: mtu will be set below */
- memset(&cfg, 0, sizeof(tL2CAP_CFG_INFO));
-
- cfg.fcr_present = true;
- cfg.fcr = obex_l2c_fcr_opts_def;
-
/* "role" is never initialized in rfcomm code */
if (listen) {
btsock_l2cap_server_listen(sock);
} else {
if (fixed_chan) {
- BTA_JvL2capConnectLE(sock->security, 0, NULL, channel, L2CAP_DEFAULT_MTU,
- NULL, sock->addr, btsock_l2cap_cbk, sock->id);
+ BTA_JvL2capConnectLE(channel, sock->addr, btsock_l2cap_cbk, sock->id);
} else {
- if (sock->is_le_coc) {
- BTA_JvL2capConnect(BTA_JV_CONN_TYPE_L2CAP_LE, sock->security, 0, NULL,
- channel, L2CAP_MAX_SDU_LENGTH, &cfg, sock->addr,
- btsock_l2cap_cbk, sock->id);
- } else {
- BTA_JvL2capConnect(BTA_JV_CONN_TYPE_L2CAP, sock->security, 0,
- &obex_l2c_etm_opt, channel, L2CAP_MAX_SDU_LENGTH,
- &cfg, sock->addr, btsock_l2cap_cbk, sock->id);
+ int connection_type =
+ sock->is_le_coc ? BTA_JV_CONN_TYPE_L2CAP_LE : BTA_JV_CONN_TYPE_L2CAP;
+
+ /* Setup ETM settings: mtu will be set below */
+ std::unique_ptr<tL2CAP_CFG_INFO> cfg = std::make_unique<tL2CAP_CFG_INFO>(
+ tL2CAP_CFG_INFO{.fcr_present = true, .fcr = obex_l2c_fcr_opts_def});
+
+ std::unique_ptr<tL2CAP_ERTM_INFO> ertm_info;
+ if (!sock->is_le_coc) {
+ ertm_info.reset(new tL2CAP_ERTM_INFO(obex_l2c_etm_opt));
}
+
+ BTA_JvL2capConnect(connection_type, sock->security, 0,
+ std::move(ertm_info), channel, L2CAP_MAX_SDU_LENGTH,
+ std::move(cfg), sock->addr, btsock_l2cap_cbk,
+ sock->id);
}
}