Loading system/bta/jv/bta_jv_api.cc +29 −27 Original line number Diff line number Diff line Loading @@ -63,13 +63,12 @@ bool bta_jv_enabled = false; * ******************************************************************************/ tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK* p_cback) { LOG_VERBOSE(""); if (!p_cback || bta_jv_enabled) { LOG(ERROR) << __func__ << ": failure"; return BTA_JV_FAILURE; } VLOG(2) << __func__; memset(&bta_jv_cb, 0, sizeof(tBTA_JV_CB)); /* set handle to invalid value by default */ for (int i = 0; i < BTA_JV_PM_MAX_NUM; i++) { Loading Loading @@ -116,7 +115,7 @@ void BTA_JvDisable(void) { * ******************************************************************************/ void BTA_JvGetChannelId(int conn_type, uint32_t id, int32_t channel) { VLOG(2) << __func__ << ": conn_type=" << conn_type; LOG_VERBOSE("conn_type:%d, id:%u, channel:%u", conn_type, id, channel); if (conn_type != BTA_JV_CONN_TYPE_RFCOMM && conn_type != BTA_JV_CONN_TYPE_L2CAP && Loading @@ -143,7 +142,7 @@ void BTA_JvGetChannelId(int conn_type, uint32_t id, int32_t channel) { * ******************************************************************************/ tBTA_JV_STATUS BTA_JvFreeChannel(uint16_t channel, int conn_type) { VLOG(2) << __func__; LOG_VERBOSE("channel:%u, conn_type:%d", channel, conn_type); do_in_main_thread(FROM_HERE, Bind(&bta_jv_free_scn, conn_type, channel)); return BTA_JV_SUCCESS; Loading @@ -165,7 +164,8 @@ tBTA_JV_STATUS BTA_JvFreeChannel(uint16_t channel, int conn_type) { tBTA_JV_STATUS BTA_JvStartDiscovery(const RawAddress& bd_addr, uint16_t num_uuid, const Uuid* p_uuid_list, uint32_t rfcomm_slot_id) { VLOG(2) << __func__; LOG_VERBOSE("bd_addr:%s, rfcomm_slot_id:%u, num_uuid:%u", ADDRESS_TO_LOGGABLE_CSTR(bd_addr), rfcomm_slot_id, num_uuid); Uuid* uuid_list_copy = new Uuid[num_uuid]; memcpy(uuid_list_copy, p_uuid_list, num_uuid * sizeof(Uuid)); Loading @@ -189,7 +189,7 @@ tBTA_JV_STATUS BTA_JvStartDiscovery(const RawAddress& bd_addr, * ******************************************************************************/ tBTA_JV_STATUS BTA_JvCreateRecordByUser(uint32_t rfcomm_slot_id) { VLOG(2) << __func__; LOG_VERBOSE("rfcomm_slot_id: %u", rfcomm_slot_id); do_in_main_thread(FROM_HERE, Bind(&bta_jv_create_record, rfcomm_slot_id)); return BTA_JV_SUCCESS; Loading @@ -206,7 +206,7 @@ tBTA_JV_STATUS BTA_JvCreateRecordByUser(uint32_t rfcomm_slot_id) { * ******************************************************************************/ tBTA_JV_STATUS BTA_JvDeleteRecord(uint32_t handle) { VLOG(2) << __func__; LOG_VERBOSE("handle:%u", handle); do_in_main_thread(FROM_HERE, Bind(&bta_jv_delete_record, handle)); return BTA_JV_SUCCESS; Loading @@ -231,7 +231,11 @@ void BTA_JvL2capConnect(int conn_type, tBTA_SEC sec_mask, tBTA_JV_ROLE role, const RawAddress& peer_bd_addr, tBTA_JV_L2CAP_CBACK* p_cback, uint32_t l2cap_socket_id) { VLOG(2) << __func__; LOG_VERBOSE( "conn_type:%d, role:%u, remote_psm:%u, peer_bd_addr:%s, " "l2cap_socket_id:%u", conn_type, role, remote_psm, ADDRESS_TO_LOGGABLE_CSTR(peer_bd_addr), l2cap_socket_id); CHECK(p_cback); do_in_main_thread(FROM_HERE, Loading @@ -251,7 +255,7 @@ void BTA_JvL2capConnect(int conn_type, tBTA_SEC sec_mask, tBTA_JV_ROLE role, * ******************************************************************************/ tBTA_JV_STATUS BTA_JvL2capClose(uint32_t handle) { VLOG(2) << __func__; LOG_VERBOSE("handle:%u", handle); if (handle >= BTA_JV_MAX_L2C_CONN || !bta_jv_cb.l2c_cb[handle].p_cback) return BTA_JV_FAILURE; Loading Loading @@ -281,7 +285,8 @@ void BTA_JvL2capStartServer(int conn_type, tBTA_SEC sec_mask, tBTA_JV_ROLE role, std::unique_ptr<tL2CAP_CFG_INFO> cfg, tBTA_JV_L2CAP_CBACK* p_cback, uint32_t l2cap_socket_id) { VLOG(2) << __func__; LOG_VERBOSE("conn_type:%d, role:%u, local_psm:%u, l2cap_socket_id:%u", conn_type, role, local_psm, l2cap_socket_id); CHECK(p_cback); do_in_main_thread(FROM_HERE, Loading @@ -303,7 +308,7 @@ void BTA_JvL2capStartServer(int conn_type, tBTA_SEC sec_mask, tBTA_JV_ROLE role, ******************************************************************************/ tBTA_JV_STATUS BTA_JvL2capStopServer(uint16_t local_psm, uint32_t l2cap_socket_id) { VLOG(2) << __func__; LOG_VERBOSE("local_psm:%u, l2cap_socket_id:%u", local_psm, l2cap_socket_id); do_in_main_thread( FROM_HERE, Bind(&bta_jv_l2cap_stop_server, local_psm, l2cap_socket_id)); Loading @@ -324,7 +329,7 @@ tBTA_JV_STATUS BTA_JvL2capStopServer(uint16_t local_psm, ******************************************************************************/ tBTA_JV_STATUS BTA_JvL2capRead(uint32_t handle, uint32_t req_id, uint8_t* p_data, uint16_t len) { VLOG(2) << __func__; LOG_VERBOSE("handle:%u, req_id:%u, len:%u", handle, req_id, len); if (handle >= BTA_JV_MAX_L2C_CONN || !bta_jv_cb.l2c_cb[handle].p_cback) return BTA_JV_FAILURE; Loading Loading @@ -359,7 +364,7 @@ tBTA_JV_STATUS BTA_JvL2capRead(uint32_t handle, uint32_t req_id, tBTA_JV_STATUS BTA_JvL2capReady(uint32_t handle, uint32_t* p_data_size) { tBTA_JV_STATUS status = BTA_JV_FAILURE; VLOG(2) << __func__ << ": handle=" << handle; LOG_VERBOSE("handle:%u", handle); if (p_data_size && handle < BTA_JV_MAX_L2C_CONN && bta_jv_cb.l2c_cb[handle].p_cback) { *p_data_size = 0; Loading Loading @@ -388,7 +393,7 @@ tBTA_JV_STATUS BTA_JvL2capReady(uint32_t handle, uint32_t* p_data_size) { ******************************************************************************/ tBTA_JV_STATUS BTA_JvL2capWrite(uint32_t handle, uint32_t req_id, BT_HDR* msg, uint32_t user_id) { VLOG(2) << __func__; LOG_VERBOSE("handle:%u, user_id:%u", handle, user_id); if (handle >= BTA_JV_MAX_L2C_CONN || !bta_jv_cb.l2c_cb[handle].p_cback) { osi_free(msg); Loading Loading @@ -421,7 +426,8 @@ tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask, tBTA_JV_ROLE role, const RawAddress& peer_bd_addr, tBTA_JV_RFCOMM_CBACK* p_cback, uint32_t rfcomm_slot_id) { VLOG(2) << __func__; LOG_VERBOSE("remote_scn:%u, peer_bd_addr:%s, rfcomm_slot_id:%u", remote_scn, ADDRESS_TO_LOGGABLE_CSTR(peer_bd_addr), rfcomm_slot_id); if (!p_cback) return BTA_JV_FAILURE; /* Nothing to do */ Loading @@ -445,7 +451,7 @@ tBTA_JV_STATUS BTA_JvRfcommClose(uint32_t handle, uint32_t rfcomm_slot_id) { uint32_t hi = ((handle & BTA_JV_RFC_HDL_MASK) & ~BTA_JV_RFCOMM_MASK) - 1; uint32_t si = BTA_JV_RFC_HDL_TO_SIDX(handle); VLOG(2) << __func__; LOG_VERBOSE("handle:%u, rfcomm_slot_id:%u", handle, rfcomm_slot_id); if (hi >= BTA_JV_MAX_RFC_CONN || !bta_jv_cb.rfc_cb[hi].p_cback || si >= BTA_JV_MAX_RFC_SR_SESSION || !bta_jv_cb.rfc_cb[hi].rfc_hdl[si]) Loading Loading @@ -475,7 +481,7 @@ tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask, tBTA_JV_ROLE role, uint8_t local_scn, uint8_t max_session, tBTA_JV_RFCOMM_CBACK* p_cback, uint32_t rfcomm_slot_id) { VLOG(2) << __func__; LOG_VERBOSE("local_scn:%u, rfcomm_slot_id:%u", local_scn, rfcomm_slot_id); if (p_cback == NULL) return BTA_JV_FAILURE; /* Nothing to do */ Loading Loading @@ -505,7 +511,7 @@ tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask, tBTA_JV_ROLE role, ******************************************************************************/ tBTA_JV_STATUS BTA_JvRfcommStopServer(uint32_t handle, uint32_t rfcomm_slot_id) { VLOG(2) << __func__; LOG_VERBOSE("handle:%u, rfcomm_slot_id:%u", handle, rfcomm_slot_id); do_in_main_thread(FROM_HERE, Bind(&bta_jv_rfcomm_stop_server, handle, rfcomm_slot_id)); Loading @@ -518,8 +524,7 @@ tBTA_JV_STATUS BTA_JvRfcommStopServer(uint32_t handle, * * Description This function fetches the rfcomm port handle * * Returns BTA_JV_SUCCESS, if the request is being processed. * BTA_JV_FAILURE, otherwise. * Returns * ******************************************************************************/ uint16_t BTA_JvRfcommGetPortHdl(uint32_t handle) { Loading Loading @@ -547,16 +552,13 @@ tBTA_JV_STATUS BTA_JvRfcommWrite(uint32_t handle, uint32_t req_id) { uint32_t hi = ((handle & BTA_JV_RFC_HDL_MASK) & ~BTA_JV_RFCOMM_MASK) - 1; uint32_t si = BTA_JV_RFC_HDL_TO_SIDX(handle); VLOG(2) << __func__; VLOG(2) << __func__ << "handle=" << loghex(handle) << ", hi=" << hi << ", si=" << si; LOG_VERBOSE("handle:%u, req_id:%u, hi:%u, si:%u", handle, req_id, hi, si); if (hi >= BTA_JV_MAX_RFC_CONN || !bta_jv_cb.rfc_cb[hi].p_cback || si >= BTA_JV_MAX_RFC_SR_SESSION || !bta_jv_cb.rfc_cb[hi].rfc_hdl[si]) { return BTA_JV_FAILURE; } VLOG(2) << "write ok"; LOG_VERBOSE("write ok"); tBTA_JV_RFC_CB* p_cb = &bta_jv_cb.rfc_cb[hi]; do_in_main_thread(FROM_HERE, Bind(&bta_jv_rfcomm_write, handle, req_id, p_cb, Loading Loading @@ -589,7 +591,7 @@ tBTA_JV_STATUS BTA_JvRfcommWrite(uint32_t handle, uint32_t req_id) { ******************************************************************************/ tBTA_JV_STATUS BTA_JvSetPmProfile(uint32_t handle, tBTA_JV_PM_ID app_id, tBTA_JV_CONN_STATE init_st) { VLOG(2) << __func__ << " handle=" << loghex(handle) << ", app_id:" << app_id; LOG_VERBOSE("handle:%u, app_id:%u, init_st:%u", handle, app_id, handle); do_in_main_thread(FROM_HERE, Bind(&bta_jv_set_pm_profile, handle, app_id, init_st)); Loading system/btif/src/btif_sock_rfc.cc +19 −5 Original line number Diff line number Diff line Loading @@ -364,7 +364,8 @@ bt_status_t btsock_rfc_connect(const RawAddress* bd_addr, rfc_slot_t* slot = alloc_rfc_slot(bd_addr, NULL, *service_uuid, channel, flags, false); if (!slot) { LOG_ERROR("%s unable to allocate RFCOMM slot.", __func__); LOG_ERROR("unable to allocate RFCOMM slot. bd_addr:%s", ADDRESS_TO_LOGGABLE_CSTR(*bd_addr)); return BT_STATUS_FAIL; } Loading @@ -373,17 +374,22 @@ bt_status_t btsock_rfc_connect(const RawAddress* bd_addr, BTA_JvRfcommConnect(slot->security, slot->role, slot->scn, slot->addr, rfcomm_cback, slot->id); if (ret != BTA_JV_SUCCESS) { LOG_ERROR("%s unable to initiate RFCOMM connection: %d", __func__, ret); LOG_ERROR( "unable to initiate RFCOMM connection. status:%d, scn:%d, bd_addr:%s", ret, slot->scn, ADDRESS_TO_LOGGABLE_CSTR(slot->addr)); cleanup_rfc_slot(slot); return BT_STATUS_FAIL; } if (!send_app_scn(slot)) { LOG_ERROR("%s unable to send channel number.", __func__); LOG_ERROR("send_app_scn() failed, closing slot->id:%u", slot->id); cleanup_rfc_slot(slot); return BT_STATUS_FAIL; } } else { LOG_INFO("service_uuid:%s, bd_addr:%s, slot_id:%u", service_uuid->ToString().c_str(), ADDRESS_TO_LOGGABLE_CSTR(*bd_addr), slot->id); if (!is_requesting_sdp()) { BTA_JvStartDiscovery(*bd_addr, 1, service_uuid, slot->id); slot->f.pending_sdp_request = false; Loading Loading @@ -471,9 +477,11 @@ static void cleanup_rfc_slot(rfc_slot_t* slot) { static bool send_app_scn(rfc_slot_t* slot) { if (slot->scn_notified) { // already send, just return success. // already sent, just return success. return true; } LOG_DEBUG("Sending scn for slot %u. bd_addr:%s", slot->id, ADDRESS_TO_LOGGABLE_CSTR(slot->addr)); slot->scn_notified = true; return sock_send_all(slot->fd, (const uint8_t*)&slot->scn, sizeof(slot->scn)) == sizeof(slot->scn); Loading Loading @@ -540,6 +548,7 @@ static void on_srv_rfc_listen_started(tBTA_JV_RFCOMM_START* p_start, static uint32_t on_srv_rfc_connect(tBTA_JV_RFCOMM_SRV_OPEN* p_open, uint32_t id) { LOG_VERBOSE("id:%u", id); std::unique_lock<std::recursive_mutex> lock(slot_lock); rfc_slot_t* accept_rs; rfc_slot_t* srv_rs = find_rfc_slot_by_id(id); Loading Loading @@ -576,6 +585,7 @@ static uint32_t on_srv_rfc_connect(tBTA_JV_RFCOMM_SRV_OPEN* p_open, } static void on_cli_rfc_connect(tBTA_JV_RFCOMM_OPEN* p_open, uint32_t id) { LOG_VERBOSE("id:%u", id); std::unique_lock<std::recursive_mutex> lock(slot_lock); rfc_slot_t* slot = find_rfc_slot_by_id(id); if (!slot) { Loading Loading @@ -614,6 +624,7 @@ static void on_cli_rfc_connect(tBTA_JV_RFCOMM_OPEN* p_open, uint32_t id) { static void on_rfc_close(UNUSED_ATTR tBTA_JV_RFCOMM_CLOSE* p_close, uint32_t id) { LOG_VERBOSE("id:%u", id); std::unique_lock<std::recursive_mutex> lock(slot_lock); // rfc_handle already closed when receiving rfcomm close event from stack. Loading Loading @@ -672,6 +683,7 @@ static void on_rfc_outgoing_congest(tBTA_JV_RFCOMM_CONG* p, uint32_t id) { static uint32_t rfcomm_cback(tBTA_JV_EVT event, tBTA_JV* p_data, uint32_t rfcomm_slot_id) { uint32_t id = 0; LOG_INFO("handling event:%d id:%u", event, rfcomm_slot_id); switch (event) { case BTA_JV_RFCOMM_START_EVT: Loading Loading @@ -720,6 +732,7 @@ static uint32_t rfcomm_cback(tBTA_JV_EVT event, tBTA_JV* p_data, } static void jv_dm_cback(tBTA_JV_EVT event, tBTA_JV* p_data, uint32_t id) { LOG_INFO("handling event:%d, id:%u", event, id); switch (event) { case BTA_JV_GET_SCN_EVT: { std::unique_lock<std::recursive_mutex> lock(slot_lock); Loading @@ -739,7 +752,7 @@ static void jv_dm_cback(tBTA_JV_EVT event, tBTA_JV* p_data, uint32_t id) { rs->scn = p_data->scn; // Send channel ID to java layer if (!send_app_scn(rs)) { LOG_DEBUG("send_app_scn() failed, closing rs->id:%d", rs->id); LOG_WARN("send_app_scn() failed, closing rs->id:%d", rs->id); cleanup_rfc_slot(rs); break; } Loading Loading @@ -849,6 +862,7 @@ static void handle_discovery_comp(tBTA_JV_STATUS status, int scn, uint32_t id) { slot->f.doing_sdp_request = false; if (!send_app_scn(slot)) { LOG_WARN("send_app_scn() failed, closing slot->id %u", slot->id); cleanup_rfc_slot(slot); return; } Loading system/stack/rfcomm/port_api.cc +1 −1 Original line number Diff line number Diff line Loading @@ -330,7 +330,7 @@ int RFCOMM_RemoveServer(uint16_t handle) { p_port->p_mgmt_callback = nullptr; if (!p_port->in_use || (p_port->state == PORT_CONNECTION_STATE_CLOSED)) { VLOG(1) << __func__ << ": handle " << handle << " not opened"; LOG_DEBUG("handle %u not opened", handle); return (PORT_SUCCESS); } LOG(INFO) << __func__ << ": handle=" << handle; Loading system/stack/rfcomm/port_rfc.cc +4 −6 Original line number Diff line number Diff line Loading @@ -427,10 +427,8 @@ void PORT_ParNegCnf(tRFC_MCB* p_mcb, uint8_t dlci, uint16_t mtu, uint8_t cl, void PORT_DlcEstablishInd(tRFC_MCB* p_mcb, uint8_t dlci, uint16_t mtu) { tPORT* p_port = port_find_mcb_dlci_port(p_mcb, dlci); LOG_VERBOSE("PORT_DlcEstablishInd p_mcb:%p, dlci:%d mtu:%di, p_port:%p", p_mcb, dlci, mtu, p_port); VLOG(1) << __func__ << " p_mcb addr:" << ADDRESS_TO_LOGGABLE_STR(p_mcb->bd_addr); LOG_VERBOSE("p_mcb:%p, dlci:%d mtu:%di, p_port:%p, bd_addr:%s", p_mcb, dlci, mtu, p_port, ADDRESS_TO_LOGGABLE_CSTR(p_mcb->bd_addr)); if (!p_port) { /* This can be a first request for this port */ Loading Loading @@ -710,8 +708,8 @@ void PORT_LineStatusInd(tRFC_MCB* p_mcb, uint8_t dlci, uint8_t line_status) { * ******************************************************************************/ void PORT_DlcReleaseInd(tRFC_MCB* p_mcb, uint8_t dlci) { VLOG(1) << __func__ << ": dlci=" << std::to_string(dlci) << ", bd_addr=" << p_mcb->bd_addr; LOG_VERBOSE("dlci:%u, bd_addr:%s", dlci, ADDRESS_TO_LOGGABLE_CSTR(p_mcb->bd_addr)); tPORT* p_port = port_find_mcb_dlci_port(p_mcb, dlci); if (!p_port) return; port_rfc_closed(p_port, PORT_CLOSED); Loading system/stack/rfcomm/port_utils.cc +4 −5 Original line number Diff line number Diff line Loading @@ -287,14 +287,13 @@ tRFC_MCB* port_find_mcb(const RawAddress& bd_addr) { for (tRFC_MCB& mcb : rfc_cb.port.rfc_mcb) { if ((mcb.state != RFC_MX_STATE_IDLE) && (mcb.bd_addr == bd_addr)) { /* Multiplexer channel found do not change anything */ VLOG(1) << __func__ << ": found bd_addr=" << ADDRESS_TO_LOGGABLE_STR(bd_addr) << ", rfc_mcb=" << &mcb << ", lcid=" << loghex(mcb.lcid); LOG_VERBOSE("found, bd_addr:%s, rfc_mcb:%p, lcid:%s", ADDRESS_TO_LOGGABLE_CSTR(bd_addr), &mcb, loghex(mcb.lcid).c_str()); return &mcb; } } VLOG(1) << __func__ << ": not found, bd_addr:" << ADDRESS_TO_LOGGABLE_STR(bd_addr); LOG_WARN("not found, bd_addr:%s", ADDRESS_TO_LOGGABLE_CSTR(bd_addr)); return nullptr; } Loading Loading
system/bta/jv/bta_jv_api.cc +29 −27 Original line number Diff line number Diff line Loading @@ -63,13 +63,12 @@ bool bta_jv_enabled = false; * ******************************************************************************/ tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK* p_cback) { LOG_VERBOSE(""); if (!p_cback || bta_jv_enabled) { LOG(ERROR) << __func__ << ": failure"; return BTA_JV_FAILURE; } VLOG(2) << __func__; memset(&bta_jv_cb, 0, sizeof(tBTA_JV_CB)); /* set handle to invalid value by default */ for (int i = 0; i < BTA_JV_PM_MAX_NUM; i++) { Loading Loading @@ -116,7 +115,7 @@ void BTA_JvDisable(void) { * ******************************************************************************/ void BTA_JvGetChannelId(int conn_type, uint32_t id, int32_t channel) { VLOG(2) << __func__ << ": conn_type=" << conn_type; LOG_VERBOSE("conn_type:%d, id:%u, channel:%u", conn_type, id, channel); if (conn_type != BTA_JV_CONN_TYPE_RFCOMM && conn_type != BTA_JV_CONN_TYPE_L2CAP && Loading @@ -143,7 +142,7 @@ void BTA_JvGetChannelId(int conn_type, uint32_t id, int32_t channel) { * ******************************************************************************/ tBTA_JV_STATUS BTA_JvFreeChannel(uint16_t channel, int conn_type) { VLOG(2) << __func__; LOG_VERBOSE("channel:%u, conn_type:%d", channel, conn_type); do_in_main_thread(FROM_HERE, Bind(&bta_jv_free_scn, conn_type, channel)); return BTA_JV_SUCCESS; Loading @@ -165,7 +164,8 @@ tBTA_JV_STATUS BTA_JvFreeChannel(uint16_t channel, int conn_type) { tBTA_JV_STATUS BTA_JvStartDiscovery(const RawAddress& bd_addr, uint16_t num_uuid, const Uuid* p_uuid_list, uint32_t rfcomm_slot_id) { VLOG(2) << __func__; LOG_VERBOSE("bd_addr:%s, rfcomm_slot_id:%u, num_uuid:%u", ADDRESS_TO_LOGGABLE_CSTR(bd_addr), rfcomm_slot_id, num_uuid); Uuid* uuid_list_copy = new Uuid[num_uuid]; memcpy(uuid_list_copy, p_uuid_list, num_uuid * sizeof(Uuid)); Loading @@ -189,7 +189,7 @@ tBTA_JV_STATUS BTA_JvStartDiscovery(const RawAddress& bd_addr, * ******************************************************************************/ tBTA_JV_STATUS BTA_JvCreateRecordByUser(uint32_t rfcomm_slot_id) { VLOG(2) << __func__; LOG_VERBOSE("rfcomm_slot_id: %u", rfcomm_slot_id); do_in_main_thread(FROM_HERE, Bind(&bta_jv_create_record, rfcomm_slot_id)); return BTA_JV_SUCCESS; Loading @@ -206,7 +206,7 @@ tBTA_JV_STATUS BTA_JvCreateRecordByUser(uint32_t rfcomm_slot_id) { * ******************************************************************************/ tBTA_JV_STATUS BTA_JvDeleteRecord(uint32_t handle) { VLOG(2) << __func__; LOG_VERBOSE("handle:%u", handle); do_in_main_thread(FROM_HERE, Bind(&bta_jv_delete_record, handle)); return BTA_JV_SUCCESS; Loading @@ -231,7 +231,11 @@ void BTA_JvL2capConnect(int conn_type, tBTA_SEC sec_mask, tBTA_JV_ROLE role, const RawAddress& peer_bd_addr, tBTA_JV_L2CAP_CBACK* p_cback, uint32_t l2cap_socket_id) { VLOG(2) << __func__; LOG_VERBOSE( "conn_type:%d, role:%u, remote_psm:%u, peer_bd_addr:%s, " "l2cap_socket_id:%u", conn_type, role, remote_psm, ADDRESS_TO_LOGGABLE_CSTR(peer_bd_addr), l2cap_socket_id); CHECK(p_cback); do_in_main_thread(FROM_HERE, Loading @@ -251,7 +255,7 @@ void BTA_JvL2capConnect(int conn_type, tBTA_SEC sec_mask, tBTA_JV_ROLE role, * ******************************************************************************/ tBTA_JV_STATUS BTA_JvL2capClose(uint32_t handle) { VLOG(2) << __func__; LOG_VERBOSE("handle:%u", handle); if (handle >= BTA_JV_MAX_L2C_CONN || !bta_jv_cb.l2c_cb[handle].p_cback) return BTA_JV_FAILURE; Loading Loading @@ -281,7 +285,8 @@ void BTA_JvL2capStartServer(int conn_type, tBTA_SEC sec_mask, tBTA_JV_ROLE role, std::unique_ptr<tL2CAP_CFG_INFO> cfg, tBTA_JV_L2CAP_CBACK* p_cback, uint32_t l2cap_socket_id) { VLOG(2) << __func__; LOG_VERBOSE("conn_type:%d, role:%u, local_psm:%u, l2cap_socket_id:%u", conn_type, role, local_psm, l2cap_socket_id); CHECK(p_cback); do_in_main_thread(FROM_HERE, Loading @@ -303,7 +308,7 @@ void BTA_JvL2capStartServer(int conn_type, tBTA_SEC sec_mask, tBTA_JV_ROLE role, ******************************************************************************/ tBTA_JV_STATUS BTA_JvL2capStopServer(uint16_t local_psm, uint32_t l2cap_socket_id) { VLOG(2) << __func__; LOG_VERBOSE("local_psm:%u, l2cap_socket_id:%u", local_psm, l2cap_socket_id); do_in_main_thread( FROM_HERE, Bind(&bta_jv_l2cap_stop_server, local_psm, l2cap_socket_id)); Loading @@ -324,7 +329,7 @@ tBTA_JV_STATUS BTA_JvL2capStopServer(uint16_t local_psm, ******************************************************************************/ tBTA_JV_STATUS BTA_JvL2capRead(uint32_t handle, uint32_t req_id, uint8_t* p_data, uint16_t len) { VLOG(2) << __func__; LOG_VERBOSE("handle:%u, req_id:%u, len:%u", handle, req_id, len); if (handle >= BTA_JV_MAX_L2C_CONN || !bta_jv_cb.l2c_cb[handle].p_cback) return BTA_JV_FAILURE; Loading Loading @@ -359,7 +364,7 @@ tBTA_JV_STATUS BTA_JvL2capRead(uint32_t handle, uint32_t req_id, tBTA_JV_STATUS BTA_JvL2capReady(uint32_t handle, uint32_t* p_data_size) { tBTA_JV_STATUS status = BTA_JV_FAILURE; VLOG(2) << __func__ << ": handle=" << handle; LOG_VERBOSE("handle:%u", handle); if (p_data_size && handle < BTA_JV_MAX_L2C_CONN && bta_jv_cb.l2c_cb[handle].p_cback) { *p_data_size = 0; Loading Loading @@ -388,7 +393,7 @@ tBTA_JV_STATUS BTA_JvL2capReady(uint32_t handle, uint32_t* p_data_size) { ******************************************************************************/ tBTA_JV_STATUS BTA_JvL2capWrite(uint32_t handle, uint32_t req_id, BT_HDR* msg, uint32_t user_id) { VLOG(2) << __func__; LOG_VERBOSE("handle:%u, user_id:%u", handle, user_id); if (handle >= BTA_JV_MAX_L2C_CONN || !bta_jv_cb.l2c_cb[handle].p_cback) { osi_free(msg); Loading Loading @@ -421,7 +426,8 @@ tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask, tBTA_JV_ROLE role, const RawAddress& peer_bd_addr, tBTA_JV_RFCOMM_CBACK* p_cback, uint32_t rfcomm_slot_id) { VLOG(2) << __func__; LOG_VERBOSE("remote_scn:%u, peer_bd_addr:%s, rfcomm_slot_id:%u", remote_scn, ADDRESS_TO_LOGGABLE_CSTR(peer_bd_addr), rfcomm_slot_id); if (!p_cback) return BTA_JV_FAILURE; /* Nothing to do */ Loading @@ -445,7 +451,7 @@ tBTA_JV_STATUS BTA_JvRfcommClose(uint32_t handle, uint32_t rfcomm_slot_id) { uint32_t hi = ((handle & BTA_JV_RFC_HDL_MASK) & ~BTA_JV_RFCOMM_MASK) - 1; uint32_t si = BTA_JV_RFC_HDL_TO_SIDX(handle); VLOG(2) << __func__; LOG_VERBOSE("handle:%u, rfcomm_slot_id:%u", handle, rfcomm_slot_id); if (hi >= BTA_JV_MAX_RFC_CONN || !bta_jv_cb.rfc_cb[hi].p_cback || si >= BTA_JV_MAX_RFC_SR_SESSION || !bta_jv_cb.rfc_cb[hi].rfc_hdl[si]) Loading Loading @@ -475,7 +481,7 @@ tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask, tBTA_JV_ROLE role, uint8_t local_scn, uint8_t max_session, tBTA_JV_RFCOMM_CBACK* p_cback, uint32_t rfcomm_slot_id) { VLOG(2) << __func__; LOG_VERBOSE("local_scn:%u, rfcomm_slot_id:%u", local_scn, rfcomm_slot_id); if (p_cback == NULL) return BTA_JV_FAILURE; /* Nothing to do */ Loading Loading @@ -505,7 +511,7 @@ tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask, tBTA_JV_ROLE role, ******************************************************************************/ tBTA_JV_STATUS BTA_JvRfcommStopServer(uint32_t handle, uint32_t rfcomm_slot_id) { VLOG(2) << __func__; LOG_VERBOSE("handle:%u, rfcomm_slot_id:%u", handle, rfcomm_slot_id); do_in_main_thread(FROM_HERE, Bind(&bta_jv_rfcomm_stop_server, handle, rfcomm_slot_id)); Loading @@ -518,8 +524,7 @@ tBTA_JV_STATUS BTA_JvRfcommStopServer(uint32_t handle, * * Description This function fetches the rfcomm port handle * * Returns BTA_JV_SUCCESS, if the request is being processed. * BTA_JV_FAILURE, otherwise. * Returns * ******************************************************************************/ uint16_t BTA_JvRfcommGetPortHdl(uint32_t handle) { Loading Loading @@ -547,16 +552,13 @@ tBTA_JV_STATUS BTA_JvRfcommWrite(uint32_t handle, uint32_t req_id) { uint32_t hi = ((handle & BTA_JV_RFC_HDL_MASK) & ~BTA_JV_RFCOMM_MASK) - 1; uint32_t si = BTA_JV_RFC_HDL_TO_SIDX(handle); VLOG(2) << __func__; VLOG(2) << __func__ << "handle=" << loghex(handle) << ", hi=" << hi << ", si=" << si; LOG_VERBOSE("handle:%u, req_id:%u, hi:%u, si:%u", handle, req_id, hi, si); if (hi >= BTA_JV_MAX_RFC_CONN || !bta_jv_cb.rfc_cb[hi].p_cback || si >= BTA_JV_MAX_RFC_SR_SESSION || !bta_jv_cb.rfc_cb[hi].rfc_hdl[si]) { return BTA_JV_FAILURE; } VLOG(2) << "write ok"; LOG_VERBOSE("write ok"); tBTA_JV_RFC_CB* p_cb = &bta_jv_cb.rfc_cb[hi]; do_in_main_thread(FROM_HERE, Bind(&bta_jv_rfcomm_write, handle, req_id, p_cb, Loading Loading @@ -589,7 +591,7 @@ tBTA_JV_STATUS BTA_JvRfcommWrite(uint32_t handle, uint32_t req_id) { ******************************************************************************/ tBTA_JV_STATUS BTA_JvSetPmProfile(uint32_t handle, tBTA_JV_PM_ID app_id, tBTA_JV_CONN_STATE init_st) { VLOG(2) << __func__ << " handle=" << loghex(handle) << ", app_id:" << app_id; LOG_VERBOSE("handle:%u, app_id:%u, init_st:%u", handle, app_id, handle); do_in_main_thread(FROM_HERE, Bind(&bta_jv_set_pm_profile, handle, app_id, init_st)); Loading
system/btif/src/btif_sock_rfc.cc +19 −5 Original line number Diff line number Diff line Loading @@ -364,7 +364,8 @@ bt_status_t btsock_rfc_connect(const RawAddress* bd_addr, rfc_slot_t* slot = alloc_rfc_slot(bd_addr, NULL, *service_uuid, channel, flags, false); if (!slot) { LOG_ERROR("%s unable to allocate RFCOMM slot.", __func__); LOG_ERROR("unable to allocate RFCOMM slot. bd_addr:%s", ADDRESS_TO_LOGGABLE_CSTR(*bd_addr)); return BT_STATUS_FAIL; } Loading @@ -373,17 +374,22 @@ bt_status_t btsock_rfc_connect(const RawAddress* bd_addr, BTA_JvRfcommConnect(slot->security, slot->role, slot->scn, slot->addr, rfcomm_cback, slot->id); if (ret != BTA_JV_SUCCESS) { LOG_ERROR("%s unable to initiate RFCOMM connection: %d", __func__, ret); LOG_ERROR( "unable to initiate RFCOMM connection. status:%d, scn:%d, bd_addr:%s", ret, slot->scn, ADDRESS_TO_LOGGABLE_CSTR(slot->addr)); cleanup_rfc_slot(slot); return BT_STATUS_FAIL; } if (!send_app_scn(slot)) { LOG_ERROR("%s unable to send channel number.", __func__); LOG_ERROR("send_app_scn() failed, closing slot->id:%u", slot->id); cleanup_rfc_slot(slot); return BT_STATUS_FAIL; } } else { LOG_INFO("service_uuid:%s, bd_addr:%s, slot_id:%u", service_uuid->ToString().c_str(), ADDRESS_TO_LOGGABLE_CSTR(*bd_addr), slot->id); if (!is_requesting_sdp()) { BTA_JvStartDiscovery(*bd_addr, 1, service_uuid, slot->id); slot->f.pending_sdp_request = false; Loading Loading @@ -471,9 +477,11 @@ static void cleanup_rfc_slot(rfc_slot_t* slot) { static bool send_app_scn(rfc_slot_t* slot) { if (slot->scn_notified) { // already send, just return success. // already sent, just return success. return true; } LOG_DEBUG("Sending scn for slot %u. bd_addr:%s", slot->id, ADDRESS_TO_LOGGABLE_CSTR(slot->addr)); slot->scn_notified = true; return sock_send_all(slot->fd, (const uint8_t*)&slot->scn, sizeof(slot->scn)) == sizeof(slot->scn); Loading Loading @@ -540,6 +548,7 @@ static void on_srv_rfc_listen_started(tBTA_JV_RFCOMM_START* p_start, static uint32_t on_srv_rfc_connect(tBTA_JV_RFCOMM_SRV_OPEN* p_open, uint32_t id) { LOG_VERBOSE("id:%u", id); std::unique_lock<std::recursive_mutex> lock(slot_lock); rfc_slot_t* accept_rs; rfc_slot_t* srv_rs = find_rfc_slot_by_id(id); Loading Loading @@ -576,6 +585,7 @@ static uint32_t on_srv_rfc_connect(tBTA_JV_RFCOMM_SRV_OPEN* p_open, } static void on_cli_rfc_connect(tBTA_JV_RFCOMM_OPEN* p_open, uint32_t id) { LOG_VERBOSE("id:%u", id); std::unique_lock<std::recursive_mutex> lock(slot_lock); rfc_slot_t* slot = find_rfc_slot_by_id(id); if (!slot) { Loading Loading @@ -614,6 +624,7 @@ static void on_cli_rfc_connect(tBTA_JV_RFCOMM_OPEN* p_open, uint32_t id) { static void on_rfc_close(UNUSED_ATTR tBTA_JV_RFCOMM_CLOSE* p_close, uint32_t id) { LOG_VERBOSE("id:%u", id); std::unique_lock<std::recursive_mutex> lock(slot_lock); // rfc_handle already closed when receiving rfcomm close event from stack. Loading Loading @@ -672,6 +683,7 @@ static void on_rfc_outgoing_congest(tBTA_JV_RFCOMM_CONG* p, uint32_t id) { static uint32_t rfcomm_cback(tBTA_JV_EVT event, tBTA_JV* p_data, uint32_t rfcomm_slot_id) { uint32_t id = 0; LOG_INFO("handling event:%d id:%u", event, rfcomm_slot_id); switch (event) { case BTA_JV_RFCOMM_START_EVT: Loading Loading @@ -720,6 +732,7 @@ static uint32_t rfcomm_cback(tBTA_JV_EVT event, tBTA_JV* p_data, } static void jv_dm_cback(tBTA_JV_EVT event, tBTA_JV* p_data, uint32_t id) { LOG_INFO("handling event:%d, id:%u", event, id); switch (event) { case BTA_JV_GET_SCN_EVT: { std::unique_lock<std::recursive_mutex> lock(slot_lock); Loading @@ -739,7 +752,7 @@ static void jv_dm_cback(tBTA_JV_EVT event, tBTA_JV* p_data, uint32_t id) { rs->scn = p_data->scn; // Send channel ID to java layer if (!send_app_scn(rs)) { LOG_DEBUG("send_app_scn() failed, closing rs->id:%d", rs->id); LOG_WARN("send_app_scn() failed, closing rs->id:%d", rs->id); cleanup_rfc_slot(rs); break; } Loading Loading @@ -849,6 +862,7 @@ static void handle_discovery_comp(tBTA_JV_STATUS status, int scn, uint32_t id) { slot->f.doing_sdp_request = false; if (!send_app_scn(slot)) { LOG_WARN("send_app_scn() failed, closing slot->id %u", slot->id); cleanup_rfc_slot(slot); return; } Loading
system/stack/rfcomm/port_api.cc +1 −1 Original line number Diff line number Diff line Loading @@ -330,7 +330,7 @@ int RFCOMM_RemoveServer(uint16_t handle) { p_port->p_mgmt_callback = nullptr; if (!p_port->in_use || (p_port->state == PORT_CONNECTION_STATE_CLOSED)) { VLOG(1) << __func__ << ": handle " << handle << " not opened"; LOG_DEBUG("handle %u not opened", handle); return (PORT_SUCCESS); } LOG(INFO) << __func__ << ": handle=" << handle; Loading
system/stack/rfcomm/port_rfc.cc +4 −6 Original line number Diff line number Diff line Loading @@ -427,10 +427,8 @@ void PORT_ParNegCnf(tRFC_MCB* p_mcb, uint8_t dlci, uint16_t mtu, uint8_t cl, void PORT_DlcEstablishInd(tRFC_MCB* p_mcb, uint8_t dlci, uint16_t mtu) { tPORT* p_port = port_find_mcb_dlci_port(p_mcb, dlci); LOG_VERBOSE("PORT_DlcEstablishInd p_mcb:%p, dlci:%d mtu:%di, p_port:%p", p_mcb, dlci, mtu, p_port); VLOG(1) << __func__ << " p_mcb addr:" << ADDRESS_TO_LOGGABLE_STR(p_mcb->bd_addr); LOG_VERBOSE("p_mcb:%p, dlci:%d mtu:%di, p_port:%p, bd_addr:%s", p_mcb, dlci, mtu, p_port, ADDRESS_TO_LOGGABLE_CSTR(p_mcb->bd_addr)); if (!p_port) { /* This can be a first request for this port */ Loading Loading @@ -710,8 +708,8 @@ void PORT_LineStatusInd(tRFC_MCB* p_mcb, uint8_t dlci, uint8_t line_status) { * ******************************************************************************/ void PORT_DlcReleaseInd(tRFC_MCB* p_mcb, uint8_t dlci) { VLOG(1) << __func__ << ": dlci=" << std::to_string(dlci) << ", bd_addr=" << p_mcb->bd_addr; LOG_VERBOSE("dlci:%u, bd_addr:%s", dlci, ADDRESS_TO_LOGGABLE_CSTR(p_mcb->bd_addr)); tPORT* p_port = port_find_mcb_dlci_port(p_mcb, dlci); if (!p_port) return; port_rfc_closed(p_port, PORT_CLOSED); Loading
system/stack/rfcomm/port_utils.cc +4 −5 Original line number Diff line number Diff line Loading @@ -287,14 +287,13 @@ tRFC_MCB* port_find_mcb(const RawAddress& bd_addr) { for (tRFC_MCB& mcb : rfc_cb.port.rfc_mcb) { if ((mcb.state != RFC_MX_STATE_IDLE) && (mcb.bd_addr == bd_addr)) { /* Multiplexer channel found do not change anything */ VLOG(1) << __func__ << ": found bd_addr=" << ADDRESS_TO_LOGGABLE_STR(bd_addr) << ", rfc_mcb=" << &mcb << ", lcid=" << loghex(mcb.lcid); LOG_VERBOSE("found, bd_addr:%s, rfc_mcb:%p, lcid:%s", ADDRESS_TO_LOGGABLE_CSTR(bd_addr), &mcb, loghex(mcb.lcid).c_str()); return &mcb; } } VLOG(1) << __func__ << ": not found, bd_addr:" << ADDRESS_TO_LOGGABLE_STR(bd_addr); LOG_WARN("not found, bd_addr:%s", ADDRESS_TO_LOGGABLE_CSTR(bd_addr)); return nullptr; } Loading