summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Srini S <ssrinivaz@google.com> 2025-03-05 16:52:47 -0800
committer Srini S <ssrinivaz@google.com> 2025-03-07 13:32:50 -0800
commitc129e5665fec6f0b08fa3d6cc2f5d445b165ac80 (patch)
tree58225aff54dc01f970f70f6f8c0ac5bd41866948
parentd5888d471cb39c6aa11dcffab02a726b3e43a706 (diff)
Fix SMP connection status sent from L2CAP when LE ACL is not connected
If L2CAP is already trying to establish the LE ACL and SMP pairing attempt requests for LE connection, SMP layer is immediately informed by L2CAP that it is connected. As a result SMP Pairing request could be sent to L2CAP before the actual connection. In such a case the SMP packet would be dropped by the L2CAP and pairing will eventually timeout even if the LE ACL is successfully established a little later. This can happen if LE L2CAP socket connection is requested before LE pairing. This change sends connected status from L2CAP to SMP layer only when the LE ACL has been established. Test: atest PairingTest Flag: com.android.bluetooth.flags.smp_connection_status_handling_when_no_acl Bug: 401053315 Bug: 401073843 Change-Id: Ief654f8286c039404218a802bfff860090ec87e8
-rw-r--r--system/stack/l2cap/l2c_api.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/system/stack/l2cap/l2c_api.cc b/system/stack/l2cap/l2c_api.cc
index 38b9dd030c..04f32105e5 100644
--- a/system/stack/l2cap/l2c_api.cc
+++ b/system/stack/l2cap/l2c_api.cc
@@ -1211,8 +1211,15 @@ bool L2CA_ConnectFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda) {
// Restore the fixed channel if it was suspended
l2cu_fixed_channel_restore(p_lcb, fixed_cid);
- (*l2cb.fixed_reg[fixed_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedConn_Cb)(
- fixed_cid, p_lcb->remote_bd_addr, true, 0, p_lcb->transport);
+ if (!com::android::bluetooth::flags::smp_connection_status_handling_when_no_acl()) {
+ (*l2cb.fixed_reg[fixed_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedConn_Cb)(
+ fixed_cid, p_lcb->remote_bd_addr, true, 0, p_lcb->transport);
+ return true;
+ }
+ if (p_lcb->link_state == LST_CONNECTED) {
+ (*l2cb.fixed_reg[fixed_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedConn_Cb)(
+ fixed_cid, p_lcb->remote_bd_addr, true, 0, p_lcb->transport);
+ }
return true;
}