Loading system/stack/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -1105,6 +1105,7 @@ cc_test { ":TestMockRustFfi", ":TestMockStackArbiter", ":TestMockStackBtm", ":TestMockStackConnMgr", ":TestMockStackSdp", "gatt/gatt_utils.cc", "test/common/mock_eatt.cc", Loading system/stack/connection_manager/connection_manager.cc +1 −1 Original line number Diff line number Diff line Loading @@ -367,7 +367,7 @@ bool background_connect_remove(uint8_t app_id, const RawAddress& address) { } if (is_anyone_connecting(it)) { log::debug("some device is still connecting, app_id={}, address={}", static_cast<int>(app_id), log::debug("some app is still connecting, app_id={}, address={}", static_cast<int>(app_id), address); /* Check which method should be used now.*/ if (!accept_list_enabled) { Loading system/stack/gatt/gatt_api.cc +1 −8 Original line number Diff line number Diff line Loading @@ -1486,14 +1486,7 @@ bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr, tBLE_ADDR_TYPE ad /* Consider to remove gatt_act_connect at all */ ret = gatt_act_connect(p_reg, bd_addr, addr_type, transport, initiating_phys); } else { log::verbose("Connecting without tcb address: {}", bd_addr); if (p_reg->direct_connect_request.count(bd_addr) == 0) { p_reg->direct_connect_request.insert(bd_addr); } else { log::warn("{} already added to gatt_if {} direct conn list", bd_addr, gatt_if); } log::verbose("Connecting without tcb to: {}", bd_addr); ret = connection_manager::direct_connect_add(gatt_if, bd_addr, addr_type); } Loading system/stack/gatt/gatt_int.h +0 −2 Original line number Diff line number Diff line Loading @@ -193,7 +193,6 @@ typedef struct { uint8_t listening{0}; /* if adv for all has been enabled */ bool eatt_support{false}; std::string name; std::set<RawAddress> direct_connect_request; std::map<RawAddress, uint16_t> mtu_prefs; } tGATT_REG; Loading Loading @@ -490,7 +489,6 @@ extern bluetooth::common::TimestampedCircularBuffer<tTCB_STATE_HISTORY> tcb_stat /* from gatt_main.cc */ bool gatt_disconnect(tGATT_TCB* p_tcb); void gatt_cancel_connect(const RawAddress& bd_addr, tBT_TRANSPORT transport); bool gatt_act_connect(tGATT_REG* p_reg, const RawAddress& bd_addr, tBT_TRANSPORT transport, int8_t initiating_phys); bool gatt_act_connect(tGATT_REG* p_reg, const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type, Loading system/stack/gatt/gatt_main.cc +29 −56 Original line number Diff line number Diff line Loading @@ -238,32 +238,6 @@ static bool gatt_connect(const RawAddress& rem_bda, tBLE_ADDR_TYPE addr_type, tG return connection_manager::direct_connect_add(gatt_if, rem_bda, addr_type); } /******************************************************************************* * * Function gatt_cancel_connect * * Description This will remove device from allow list and cancel connection * * Parameter bd_addr: peer device address. * transport: transport * * ******************************************************************************/ void gatt_cancel_connect(const RawAddress& bd_addr, tBT_TRANSPORT transport) { /* This shall be call only when device is not connected */ log::debug("{}, transport {}", bd_addr, transport); if (!connection_manager::direct_connect_remove(CONN_MGR_ID_L2CAP, bd_addr)) { bluetooth::shim::ACL_IgnoreLeConnectionFrom(BTM_Sec_GetAddressWithType(bd_addr)); log::info( "GATT connection manager has no record but removed filter " "acceptlist gatt_if:{} peer:{}", static_cast<uint8_t>(CONN_MGR_ID_L2CAP), bd_addr); } gatt_cleanup_upon_disc(bd_addr, GATT_CONN_TERMINATE_LOCAL_HOST, transport); } /******************************************************************************* * * Function gatt_disconnect Loading @@ -290,29 +264,42 @@ bool gatt_disconnect(tGATT_TCB* p_tcb) { return true; } if (p_tcb->att_lcid == L2CAP_ATT_CID) { if (ch_state == GATT_CH_OPEN) { if (p_tcb->att_lcid != L2CAP_ATT_CID) { if ((ch_state == GATT_CH_OPEN) || (ch_state == GATT_CH_CFG)) { gatt_l2cif_disconnect(p_tcb->att_lcid); } else { log::verbose("gatt_disconnect channel not opened"); } return true; } /* att_lcid == L2CAP_ATT_CID */ if (ch_state != GATT_CH_OPEN) { if (!connection_manager::direct_connect_remove(CONN_MGR_ID_L2CAP, p_tcb->peer_bda)) { bluetooth::shim::ACL_IgnoreLeConnectionFrom(BTM_Sec_GetAddressWithType(p_tcb->peer_bda)); log::info( "GATT connection manager has no record but removed filter " "acceptlist gatt_if:{} peer:{}", static_cast<uint8_t>(CONN_MGR_ID_L2CAP), p_tcb->peer_bda); } gatt_cleanup_upon_disc(p_tcb->peer_bda, GATT_CONN_TERMINATE_LOCAL_HOST, p_tcb->transport); return true; } if (com::android::bluetooth::flags::gatt_disconnect_fix() && p_tcb->eatt) { /* ATT is fixed channel and it is expected to drop ACL. * Make sure all EATT channels are disconnected before doing that. */ EattExtension::GetInstance()->Disconnect(p_tcb->peer_bda); } if (!stack::l2cap::get_interface().L2CA_RemoveFixedChnl(L2CAP_ATT_CID, p_tcb->peer_bda)) { log::warn("Unable to remove L2CAP ATT fixed channel peer:{}", p_tcb->peer_bda); } gatt_set_ch_state(p_tcb, GATT_CH_CLOSING); } else { gatt_cancel_connect(p_tcb->peer_bda, p_tcb->transport); } } else { if ((ch_state == GATT_CH_OPEN) || (ch_state == GATT_CH_CFG)) { gatt_l2cif_disconnect(p_tcb->att_lcid); } else { log::verbose("gatt_disconnect channel not opened"); } } gatt_set_ch_state(p_tcb, GATT_CH_CLOSING); return true; } Loading Loading @@ -1004,13 +991,6 @@ static void gatt_send_conn_cback(tGATT_TCB* p_tcb) { gatt_update_app_use_link_flag(p_reg->gatt_if, p_tcb, true, true); } if (p_reg->direct_connect_request.count(p_tcb->peer_bda) > 0) { gatt_update_app_use_link_flag(p_reg->gatt_if, p_tcb, true, true); log::info("Removing device {} from the direct connect list of gatt_if {}", p_tcb->peer_bda, p_reg->gatt_if); p_reg->direct_connect_request.erase(p_tcb->peer_bda); } if (p_reg->app_cb.p_conn_cb) { conn_id = gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if); (*p_reg->app_cb.p_conn_cb)(p_reg->gatt_if, p_tcb->peer_bda, conn_id, kGattConnected, Loading @@ -1027,13 +1007,6 @@ static void gatt_send_conn_cback(tGATT_TCB* p_tcb) { gatt_update_app_use_link_flag(p_reg->gatt_if, p_tcb, true, true); } if (p_reg->direct_connect_request.count(p_tcb->peer_bda) > 0) { gatt_update_app_use_link_flag(p_reg->gatt_if, p_tcb, true, true); log::info("Removing device {} from the direct connect list of gatt_if {}", p_tcb->peer_bda, p_reg->gatt_if); p_reg->direct_connect_request.erase(p_tcb->peer_bda); } if (p_reg->app_cb.p_conn_cb) { conn_id = gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if); (*p_reg->app_cb.p_conn_cb)(p_reg->gatt_if, p_tcb->peer_bda, conn_id, kGattConnected, Loading Loading
system/stack/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -1105,6 +1105,7 @@ cc_test { ":TestMockRustFfi", ":TestMockStackArbiter", ":TestMockStackBtm", ":TestMockStackConnMgr", ":TestMockStackSdp", "gatt/gatt_utils.cc", "test/common/mock_eatt.cc", Loading
system/stack/connection_manager/connection_manager.cc +1 −1 Original line number Diff line number Diff line Loading @@ -367,7 +367,7 @@ bool background_connect_remove(uint8_t app_id, const RawAddress& address) { } if (is_anyone_connecting(it)) { log::debug("some device is still connecting, app_id={}, address={}", static_cast<int>(app_id), log::debug("some app is still connecting, app_id={}, address={}", static_cast<int>(app_id), address); /* Check which method should be used now.*/ if (!accept_list_enabled) { Loading
system/stack/gatt/gatt_api.cc +1 −8 Original line number Diff line number Diff line Loading @@ -1486,14 +1486,7 @@ bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr, tBLE_ADDR_TYPE ad /* Consider to remove gatt_act_connect at all */ ret = gatt_act_connect(p_reg, bd_addr, addr_type, transport, initiating_phys); } else { log::verbose("Connecting without tcb address: {}", bd_addr); if (p_reg->direct_connect_request.count(bd_addr) == 0) { p_reg->direct_connect_request.insert(bd_addr); } else { log::warn("{} already added to gatt_if {} direct conn list", bd_addr, gatt_if); } log::verbose("Connecting without tcb to: {}", bd_addr); ret = connection_manager::direct_connect_add(gatt_if, bd_addr, addr_type); } Loading
system/stack/gatt/gatt_int.h +0 −2 Original line number Diff line number Diff line Loading @@ -193,7 +193,6 @@ typedef struct { uint8_t listening{0}; /* if adv for all has been enabled */ bool eatt_support{false}; std::string name; std::set<RawAddress> direct_connect_request; std::map<RawAddress, uint16_t> mtu_prefs; } tGATT_REG; Loading Loading @@ -490,7 +489,6 @@ extern bluetooth::common::TimestampedCircularBuffer<tTCB_STATE_HISTORY> tcb_stat /* from gatt_main.cc */ bool gatt_disconnect(tGATT_TCB* p_tcb); void gatt_cancel_connect(const RawAddress& bd_addr, tBT_TRANSPORT transport); bool gatt_act_connect(tGATT_REG* p_reg, const RawAddress& bd_addr, tBT_TRANSPORT transport, int8_t initiating_phys); bool gatt_act_connect(tGATT_REG* p_reg, const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type, Loading
system/stack/gatt/gatt_main.cc +29 −56 Original line number Diff line number Diff line Loading @@ -238,32 +238,6 @@ static bool gatt_connect(const RawAddress& rem_bda, tBLE_ADDR_TYPE addr_type, tG return connection_manager::direct_connect_add(gatt_if, rem_bda, addr_type); } /******************************************************************************* * * Function gatt_cancel_connect * * Description This will remove device from allow list and cancel connection * * Parameter bd_addr: peer device address. * transport: transport * * ******************************************************************************/ void gatt_cancel_connect(const RawAddress& bd_addr, tBT_TRANSPORT transport) { /* This shall be call only when device is not connected */ log::debug("{}, transport {}", bd_addr, transport); if (!connection_manager::direct_connect_remove(CONN_MGR_ID_L2CAP, bd_addr)) { bluetooth::shim::ACL_IgnoreLeConnectionFrom(BTM_Sec_GetAddressWithType(bd_addr)); log::info( "GATT connection manager has no record but removed filter " "acceptlist gatt_if:{} peer:{}", static_cast<uint8_t>(CONN_MGR_ID_L2CAP), bd_addr); } gatt_cleanup_upon_disc(bd_addr, GATT_CONN_TERMINATE_LOCAL_HOST, transport); } /******************************************************************************* * * Function gatt_disconnect Loading @@ -290,29 +264,42 @@ bool gatt_disconnect(tGATT_TCB* p_tcb) { return true; } if (p_tcb->att_lcid == L2CAP_ATT_CID) { if (ch_state == GATT_CH_OPEN) { if (p_tcb->att_lcid != L2CAP_ATT_CID) { if ((ch_state == GATT_CH_OPEN) || (ch_state == GATT_CH_CFG)) { gatt_l2cif_disconnect(p_tcb->att_lcid); } else { log::verbose("gatt_disconnect channel not opened"); } return true; } /* att_lcid == L2CAP_ATT_CID */ if (ch_state != GATT_CH_OPEN) { if (!connection_manager::direct_connect_remove(CONN_MGR_ID_L2CAP, p_tcb->peer_bda)) { bluetooth::shim::ACL_IgnoreLeConnectionFrom(BTM_Sec_GetAddressWithType(p_tcb->peer_bda)); log::info( "GATT connection manager has no record but removed filter " "acceptlist gatt_if:{} peer:{}", static_cast<uint8_t>(CONN_MGR_ID_L2CAP), p_tcb->peer_bda); } gatt_cleanup_upon_disc(p_tcb->peer_bda, GATT_CONN_TERMINATE_LOCAL_HOST, p_tcb->transport); return true; } if (com::android::bluetooth::flags::gatt_disconnect_fix() && p_tcb->eatt) { /* ATT is fixed channel and it is expected to drop ACL. * Make sure all EATT channels are disconnected before doing that. */ EattExtension::GetInstance()->Disconnect(p_tcb->peer_bda); } if (!stack::l2cap::get_interface().L2CA_RemoveFixedChnl(L2CAP_ATT_CID, p_tcb->peer_bda)) { log::warn("Unable to remove L2CAP ATT fixed channel peer:{}", p_tcb->peer_bda); } gatt_set_ch_state(p_tcb, GATT_CH_CLOSING); } else { gatt_cancel_connect(p_tcb->peer_bda, p_tcb->transport); } } else { if ((ch_state == GATT_CH_OPEN) || (ch_state == GATT_CH_CFG)) { gatt_l2cif_disconnect(p_tcb->att_lcid); } else { log::verbose("gatt_disconnect channel not opened"); } } gatt_set_ch_state(p_tcb, GATT_CH_CLOSING); return true; } Loading Loading @@ -1004,13 +991,6 @@ static void gatt_send_conn_cback(tGATT_TCB* p_tcb) { gatt_update_app_use_link_flag(p_reg->gatt_if, p_tcb, true, true); } if (p_reg->direct_connect_request.count(p_tcb->peer_bda) > 0) { gatt_update_app_use_link_flag(p_reg->gatt_if, p_tcb, true, true); log::info("Removing device {} from the direct connect list of gatt_if {}", p_tcb->peer_bda, p_reg->gatt_if); p_reg->direct_connect_request.erase(p_tcb->peer_bda); } if (p_reg->app_cb.p_conn_cb) { conn_id = gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if); (*p_reg->app_cb.p_conn_cb)(p_reg->gatt_if, p_tcb->peer_bda, conn_id, kGattConnected, Loading @@ -1027,13 +1007,6 @@ static void gatt_send_conn_cback(tGATT_TCB* p_tcb) { gatt_update_app_use_link_flag(p_reg->gatt_if, p_tcb, true, true); } if (p_reg->direct_connect_request.count(p_tcb->peer_bda) > 0) { gatt_update_app_use_link_flag(p_reg->gatt_if, p_tcb, true, true); log::info("Removing device {} from the direct connect list of gatt_if {}", p_tcb->peer_bda, p_reg->gatt_if); p_reg->direct_connect_request.erase(p_tcb->peer_bda); } if (p_reg->app_cb.p_conn_cb) { conn_id = gatt_create_conn_id(p_tcb->tcb_idx, p_reg->gatt_if); (*p_reg->app_cb.p_conn_cb)(p_reg->gatt_if, p_tcb->peer_bda, conn_id, kGattConnected, Loading