OSDN Git Service

Simplify sdp_on_l2cap_error
authorHansong Zhang <hsz@google.com>
Fri, 25 Sep 2020 23:29:29 +0000 (16:29 -0700)
committerHansong Zhang <hsz@google.com>
Sat, 26 Sep 2020 01:06:40 +0000 (18:06 -0700)
Both cases are doing the same thing (send disconnect request is no-op if
channel is not open, and then free the control block).

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

stack/sdp/sdp_main.cc

index a8da759..0a38f33 100644 (file)
@@ -129,24 +129,7 @@ static void sdp_connect_ind(const RawAddress& bd_addr, uint16_t l2cap_cid,
 
 static void sdp_on_l2cap_error(uint16_t l2cap_cid, uint16_t result) {
   tCONN_CB* p_ccb = sdpu_find_ccb_by_cid(l2cap_cid);
-  if (p_ccb->con_state == SDP_STATE_CONN_SETUP) {
-    // If we see an error while waiting for connection response
-    SDP_TRACE_WARNING("SDP - Rcvd conn cnf with error: 0x%x  CID 0x%x", result,
-                      p_ccb->connection_id);
-
-    /* Tell the user if there is a callback */
-    if (p_ccb->p_cb || p_ccb->p_cb2) {
-      uint16_t err = SDP_CONN_FAILED;
-      if (p_ccb->p_cb)
-        (*p_ccb->p_cb)(err);
-      else if (p_ccb->p_cb2)
-        (*p_ccb->p_cb2)(err, p_ccb->user_data);
-    }
-    sdpu_release_ccb(p_ccb);
-  } else if (p_ccb->con_state == SDP_STATE_CFG_SETUP) {
-    // If we see an error while waiting for configure response
-    sdp_disconnect(p_ccb, SDP_CFG_FAILED);
-  }
+  sdp_disconnect(p_ccb, SDP_CFG_FAILED);
 }
 
 /*******************************************************************************