OSDN Git Service

L2C_CSM: Send ConfigCfm to user after ConfigInd
authorHansong Zhang <hsz@google.com>
Fri, 25 Sep 2020 20:24:55 +0000 (13:24 -0700)
committerHansong Zhang <hsz@google.com>
Sat, 26 Sep 2020 01:06:40 +0000 (18:06 -0700)
This way, users know that a ConfigCfm event with status OK means channel
is established. No need to further keep track of state.

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I90295349c53d57aa859c5bb65e6f28a299714b3d

stack/l2cap/l2c_csm.cc
stack/l2cap/l2c_int.h

index 5a1b2b3..fd55472 100644 (file)
@@ -766,6 +766,10 @@ static void l2c_csm_config(tL2C_CCB* p_ccb, uint16_t event, void* p_data) {
             p_ccb->local_cid, (p_cfg->flags & L2CAP_CFG_FLAGS_MASK_CONT));
         (*p_ccb->p_rcb->api.pL2CA_ConfigInd_Cb)(p_ccb->local_cid, p_cfg);
         l2c_csm_send_config_rsp_ok(p_ccb);
+        if (p_ccb->config_done & OB_CFG_DONE) {
+          (*p_ccb->p_rcb->api.pL2CA_ConfigCfm_Cb)(
+              p_ccb->local_cid, p_ccb->remote_config_rsp_result);
+        }
       } else if (cfg_result == L2CAP_PEER_CFG_DISCONNECT) {
         /* Disconnect if channels are incompatible */
         L2CAP_TRACE_EVENT("L2CAP - incompatible configurations disconnect");
@@ -832,7 +836,11 @@ static void l2c_csm_config(tL2C_CCB* p_ccb, uint16_t event, void* p_data) {
 
       L2CAP_TRACE_API("L2CAP - Calling Config_Rsp_Cb(), CID: 0x%04x",
                       p_ccb->local_cid);
-      (*p_ccb->p_rcb->api.pL2CA_ConfigCfm_Cb)(p_ccb->local_cid, p_cfg->result);
+      p_ccb->remote_config_rsp_result = p_cfg->result;
+      if (p_ccb->config_done & IB_CFG_DONE) {
+        (*p_ccb->p_rcb->api.pL2CA_ConfigCfm_Cb)(p_ccb->local_cid,
+                                                p_cfg->result);
+      }
       break;
 
     case L2CEVT_L2CAP_CONFIG_RSP_NEG: /* Peer config error rsp */
index adec13d..746b109 100644 (file)
@@ -250,9 +250,9 @@ typedef struct t_l2c_ccb {
 #define IB_CFG_DONE 0x01
 #define OB_CFG_DONE 0x02
 #define RECONFIG_FLAG 0x04 /* True after initial configuration */
-#define CFG_DONE_MASK (IB_CFG_DONE | OB_CFG_DONE)
 
   uint8_t config_done; /* Configuration flag word */
+  uint16_t remote_config_rsp_result; /* The config rsp result from remote */
   uint8_t local_id;    /* Transaction ID for local trans */
   uint8_t remote_id;   /* Transaction ID for local */