Loading system/btif/include/btif_sock_l2cap.h +1 −0 Original line number Diff line number Diff line Loading @@ -18,5 +18,6 @@ bt_status_t btsock_l2cap_connect(const RawAddress* bd_addr, int channel, int* sock_fd, int flags, int app_uid); void btsock_l2cap_signaled(int fd, int flags, uint32_t user_id); void on_l2cap_psm_assigned(int id, int psm); bt_status_t btsock_l2cap_disconnect(const RawAddress* bd_addr); #endif system/btif/include/btif_sock_rfc.h +1 −0 Original line number Diff line number Diff line Loading @@ -43,5 +43,6 @@ bt_status_t btsock_rfc_connect(const RawAddress* bd_addr, const bluetooth::Uuid* uuid, int channel, int* sock_fd, int flags, int app_uid); void btsock_rfc_signaled(int fd, int flags, uint32_t user_id); bt_status_t btsock_rfc_disconnect(const RawAddress* bd_addr); #endif system/btif/src/btif_sock.cc +21 −4 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ static bt_status_t btsock_control_req(uint8_t dlci, const RawAddress& bd_addr, uint8_t break_signal_seq, bool fc); static void btsock_signaled(int fd, int type, int flags, uint32_t user_id); static bt_status_t btsock_disconnect_all(const RawAddress* bd_addr); static std::atomic_int thread_handle{-1}; static thread_t* thread; Loading @@ -86,10 +87,9 @@ static SockConnectionEvent connection_logger[SOCK_LOGGER_SIZE_MAX]; const btsock_interface_t* btif_sock_get_interface(void) { static btsock_interface_t interface = { sizeof(interface), btsock_listen, /* listen */ btsock_connect, /* connect */ btsock_request_max_tx_data_length, /* request_max_tx_data_length */ btsock_control_req /* send_control_req */ sizeof(interface), btsock_listen, btsock_connect, btsock_request_max_tx_data_length, btsock_control_req, btsock_disconnect_all, }; return &interface; Loading Loading @@ -401,3 +401,20 @@ static void btsock_signaled(int fd, int type, int flags, uint32_t user_id) { break; } } static bt_status_t btsock_disconnect_all(const RawAddress* bd_addr) { CHECK(bd_addr != NULL); bt_status_t rfc_status = btsock_rfc_disconnect(bd_addr); bt_status_t l2cap_status = btsock_l2cap_disconnect(bd_addr); /* SCO is disconnected via btif_hf, so is not handled here. */ LOG_INFO("%s: rfc status: %d, l2cap status: %d", __func__, rfc_status, l2cap_status); /* Return error status, if any. */ if (rfc_status == BT_STATUS_SUCCESS) { return l2cap_status; } return rfc_status; } system/btif/src/btif_sock_l2cap.cc +18 −0 Original line number Diff line number Diff line Loading @@ -952,3 +952,21 @@ void btsock_l2cap_signaled(int fd, int flags, uint32_t user_id) { btsock_l2cap_free_l(sock); } } bt_status_t btsock_l2cap_disconnect(const RawAddress* bd_addr) { if (!bd_addr) return BT_STATUS_PARM_INVALID; if (!is_inited()) return BT_STATUS_NOT_READY; std::unique_lock<std::mutex> lock(state_lock); l2cap_socket* sock = socks; while (sock) { l2cap_socket* next = sock->next; if (sock->addr == *bd_addr) { btsock_l2cap_free_l(sock); } sock = next; } return BT_STATUS_SUCCESS; } system/btif/src/btif_sock_rfc.cc +14 −0 Original line number Diff line number Diff line Loading @@ -977,3 +977,17 @@ int bta_co_rfc_data_outgoing(uint32_t id, uint8_t* buf, uint16_t size) { return true; } bt_status_t btsock_rfc_disconnect(const RawAddress* bd_addr) { CHECK(bd_addr != NULL); if (!is_init_done()) return BT_STATUS_NOT_READY; std::unique_lock<std::recursive_mutex> lock(slot_lock); for (size_t i = 0; i < ARRAY_SIZE(rfc_slots); ++i) { if (rfc_slots[i].id && rfc_slots[i].addr == *bd_addr) { cleanup_rfc_slot(&rfc_slots[i]); } } return BT_STATUS_SUCCESS; } Loading
system/btif/include/btif_sock_l2cap.h +1 −0 Original line number Diff line number Diff line Loading @@ -18,5 +18,6 @@ bt_status_t btsock_l2cap_connect(const RawAddress* bd_addr, int channel, int* sock_fd, int flags, int app_uid); void btsock_l2cap_signaled(int fd, int flags, uint32_t user_id); void on_l2cap_psm_assigned(int id, int psm); bt_status_t btsock_l2cap_disconnect(const RawAddress* bd_addr); #endif
system/btif/include/btif_sock_rfc.h +1 −0 Original line number Diff line number Diff line Loading @@ -43,5 +43,6 @@ bt_status_t btsock_rfc_connect(const RawAddress* bd_addr, const bluetooth::Uuid* uuid, int channel, int* sock_fd, int flags, int app_uid); void btsock_rfc_signaled(int fd, int flags, uint32_t user_id); bt_status_t btsock_rfc_disconnect(const RawAddress* bd_addr); #endif
system/btif/src/btif_sock.cc +21 −4 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ static bt_status_t btsock_control_req(uint8_t dlci, const RawAddress& bd_addr, uint8_t break_signal_seq, bool fc); static void btsock_signaled(int fd, int type, int flags, uint32_t user_id); static bt_status_t btsock_disconnect_all(const RawAddress* bd_addr); static std::atomic_int thread_handle{-1}; static thread_t* thread; Loading @@ -86,10 +87,9 @@ static SockConnectionEvent connection_logger[SOCK_LOGGER_SIZE_MAX]; const btsock_interface_t* btif_sock_get_interface(void) { static btsock_interface_t interface = { sizeof(interface), btsock_listen, /* listen */ btsock_connect, /* connect */ btsock_request_max_tx_data_length, /* request_max_tx_data_length */ btsock_control_req /* send_control_req */ sizeof(interface), btsock_listen, btsock_connect, btsock_request_max_tx_data_length, btsock_control_req, btsock_disconnect_all, }; return &interface; Loading Loading @@ -401,3 +401,20 @@ static void btsock_signaled(int fd, int type, int flags, uint32_t user_id) { break; } } static bt_status_t btsock_disconnect_all(const RawAddress* bd_addr) { CHECK(bd_addr != NULL); bt_status_t rfc_status = btsock_rfc_disconnect(bd_addr); bt_status_t l2cap_status = btsock_l2cap_disconnect(bd_addr); /* SCO is disconnected via btif_hf, so is not handled here. */ LOG_INFO("%s: rfc status: %d, l2cap status: %d", __func__, rfc_status, l2cap_status); /* Return error status, if any. */ if (rfc_status == BT_STATUS_SUCCESS) { return l2cap_status; } return rfc_status; }
system/btif/src/btif_sock_l2cap.cc +18 −0 Original line number Diff line number Diff line Loading @@ -952,3 +952,21 @@ void btsock_l2cap_signaled(int fd, int flags, uint32_t user_id) { btsock_l2cap_free_l(sock); } } bt_status_t btsock_l2cap_disconnect(const RawAddress* bd_addr) { if (!bd_addr) return BT_STATUS_PARM_INVALID; if (!is_inited()) return BT_STATUS_NOT_READY; std::unique_lock<std::mutex> lock(state_lock); l2cap_socket* sock = socks; while (sock) { l2cap_socket* next = sock->next; if (sock->addr == *bd_addr) { btsock_l2cap_free_l(sock); } sock = next; } return BT_STATUS_SUCCESS; }
system/btif/src/btif_sock_rfc.cc +14 −0 Original line number Diff line number Diff line Loading @@ -977,3 +977,17 @@ int bta_co_rfc_data_outgoing(uint32_t id, uint8_t* buf, uint16_t size) { return true; } bt_status_t btsock_rfc_disconnect(const RawAddress* bd_addr) { CHECK(bd_addr != NULL); if (!is_init_done()) return BT_STATUS_NOT_READY; std::unique_lock<std::recursive_mutex> lock(slot_lock); for (size_t i = 0; i < ARRAY_SIZE(rfc_slots); ++i) { if (rfc_slots[i].id && rfc_slots[i].addr == *bd_addr) { cleanup_rfc_slot(&rfc_slots[i]); } } return BT_STATUS_SUCCESS; }