OSDN Git Service

Bluetooth: GAP: Serialize the commands during Pairing process
authorSrinu Jella <sjella@codeaurora.org>
Wed, 18 Dec 2013 06:27:33 +0000 (11:57 +0530)
committerLinux Build Service Account <lnxbuild@localhost>
Wed, 24 Aug 2016 14:09:54 +0000 (08:09 -0600)
Serialize the Remote version, Remote features, Authentication
requested commands.

This will make sure the above commands doesn't go simultaneously
to the remote device which can't handle the multiple comands
at a time.

Change-Id: I4448c291a60ee637dc5927806547e67f26571d86
CRs-Fixed: 896888

stack/btm/btm_acl.c
stack/btm/btm_int.h
stack/btm/btm_sec.c

index d04b75a..6049a38 100644 (file)
@@ -337,7 +337,6 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn,
             /* if BR/EDR do something more */
             if (transport == BT_TRANSPORT_BR_EDR)
             {
-                btsnd_hcic_read_rmt_clk_offset (p->hci_handle);
                 btsnd_hcic_rmt_ver_req (p->hci_handle);
             }
             p_dev_rec = btm_find_dev_by_handle (hci_handle);
@@ -394,11 +393,7 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn,
                     btm_establish_continue(p);
                 }
             }
-            else
 #endif
-            {
-                btm_read_remote_features (p->hci_handle);
-            }
 
             /* read page 1 - on rmt feature event for buffer reasons */
             return;
@@ -1034,6 +1029,11 @@ void btm_read_remote_version_complete (UINT8 *p)
                 STREAM_TO_UINT8  (p_acl_cb->lmp_version, p);
                 STREAM_TO_UINT16 (p_acl_cb->manufacturer, p);
                 STREAM_TO_UINT16 (p_acl_cb->lmp_subversion, p);
+                if (p_acl_cb->transport == BT_TRANSPORT_BR_EDR)
+                {
+                    BTM_TRACE_DEBUG("Calling btm_read_remote_features");
+                    btm_read_remote_features (p_acl_cb->hci_handle);
+                }
             }
 
 #if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
@@ -1051,7 +1051,6 @@ void btm_read_remote_version_complete (UINT8 *p)
     }
 }
 
-
 /*******************************************************************************
 **
 ** Function         btm_process_remote_ext_features
@@ -1067,6 +1066,7 @@ void btm_process_remote_ext_features (tACL_CONN *p_acl_cb, UINT8 num_read_pages)
     UINT16              handle = p_acl_cb->hci_handle;
     tBTM_SEC_DEV_REC    *p_dev_rec = btm_find_dev_by_handle (handle);
     UINT8               page_idx;
+    UINT8             status;
 
     BTM_TRACE_DEBUG ("btm_process_remote_ext_features");
 
@@ -1092,6 +1092,12 @@ void btm_process_remote_ext_features (tACL_CONN *p_acl_cb, UINT8 num_read_pages)
                 HCI_FEATURE_BYTES_PER_PAGE);
     }
 
+    if (!(p_dev_rec->sec_flags & BTM_SEC_NAME_KNOWN) || p_dev_rec->is_originator)
+    {
+        BTM_TRACE_DEBUG ("Calling Next Security Procedure");
+        if ((status = btm_sec_execute_procedure (p_dev_rec)) != BTM_CMD_STARTED)
+            btm_sec_dev_rec_cback_event (p_dev_rec, status , FALSE);
+    }
     const UINT8 req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND);
 
     /* Store the Peer Security Capabilites (in SM4 and rmt_sec_caps) */
@@ -1338,24 +1344,28 @@ void btm_establish_continue (tACL_CONN *p_acl_cb)
                 BTM_SetLinkPolicy (p_acl_cb->remote_addr, &btm_cb.btm_def_link_policy);
         }
 #endif
-        p_acl_cb->link_up_issued = TRUE;
-
-        /* If anyone cares, tell him database changed */
-        if (btm_cb.p_bl_changed_cb)
+        if(p_acl_cb->link_up_issued == FALSE)
         {
-            evt_data.event = BTM_BL_CONN_EVT;
-            evt_data.conn.p_bda = p_acl_cb->remote_addr;
-            evt_data.conn.p_bdn = p_acl_cb->remote_name;
-            evt_data.conn.p_dc  = p_acl_cb->remote_dc;
-            evt_data.conn.p_features = p_acl_cb->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0];
+
+            p_acl_cb->link_up_issued = TRUE;
+
+            /* If anyone cares, tell him database changed */
+            if (btm_cb.p_bl_changed_cb)
+            {
+                evt_data.event = BTM_BL_CONN_EVT;
+                evt_data.conn.p_bda = p_acl_cb->remote_addr;
+                evt_data.conn.p_bdn = p_acl_cb->remote_name;
+                evt_data.conn.p_dc  = p_acl_cb->remote_dc;
+                evt_data.conn.p_features = p_acl_cb->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0];
 #if BLE_INCLUDED == TRUE
-            evt_data.conn.handle = p_acl_cb->hci_handle;
-            evt_data.conn.transport = p_acl_cb->transport;
+                evt_data.conn.handle = p_acl_cb->hci_handle;
+                evt_data.conn.transport = p_acl_cb->transport;
 #endif
 
-            (*btm_cb.p_bl_changed_cb)(&evt_data);
-        }
-        btm_acl_update_busy_level (BTM_BLI_ACL_UP_EVT);
+                (*btm_cb.p_bl_changed_cb)(&evt_data);
+            }
+            btm_acl_update_busy_level (BTM_BLI_ACL_UP_EVT);
+       }
 }
 
 
index b02d51b..cfcc30a 100644 (file)
@@ -1093,6 +1093,8 @@ extern tBTM_STATUS  btm_sec_l2cap_access_req (BD_ADDR bd_addr, UINT16 psm,
 extern tBTM_STATUS  btm_sec_mx_access_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_originator,
                                         UINT32 mx_proto_id, UINT32 mx_chan_id,
                                         tBTM_SEC_CALLBACK *p_callback, void *p_ref_data);
+
+extern  tBTM_STATUS btm_sec_execute_procedure (tBTM_SEC_DEV_REC *p_dev_rec);
 extern void  btm_sec_conn_req (UINT8 *bda, UINT8 *dc);
 extern void btm_create_conn_cancel_complete (UINT8 *p);
 
index ec7de9e..aa5dbe5 100644 (file)
@@ -64,7 +64,7 @@ static tBTM_SEC_SERV_REC *btm_sec_find_mx_serv (UINT8 is_originator, UINT16 psm,
                                                 UINT32 mx_proto_id,
                                                 UINT32 mx_chan_id);
 
-static tBTM_STATUS btm_sec_execute_procedure (tBTM_SEC_DEV_REC *p_dev_rec);
+
 static BOOLEAN  btm_sec_start_get_name (tBTM_SEC_DEV_REC *p_dev_rec);
 static BOOLEAN  btm_sec_start_authentication (tBTM_SEC_DEV_REC *p_dev_rec);
 static BOOLEAN  btm_sec_start_encryption (tBTM_SEC_DEV_REC *p_dev_rec);
@@ -4704,11 +4704,6 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode)
     /* the name, or if we are originator because some procedure can have */
     /* been scheduled while connection was down */
     BTM_TRACE_DEBUG ("is_originator:%d ", p_dev_rec->is_originator);
-    if (!(p_dev_rec->sec_flags & BTM_SEC_NAME_KNOWN) || p_dev_rec->is_originator)
-    {
-        if ((res = btm_sec_execute_procedure (p_dev_rec)) != BTM_CMD_STARTED)
-            btm_sec_dev_rec_cback_event (p_dev_rec, res, FALSE);
-    }
     return;
 }
 
@@ -5366,7 +5361,7 @@ void btm_sec_update_clock_offset (UINT16 handle, UINT16 clock_offset)
 **                  BTM_NO_RESOURCES  - permission declined
 **
 *******************************************************************************/
-static tBTM_STATUS btm_sec_execute_procedure (tBTM_SEC_DEV_REC *p_dev_rec)
+extern tBTM_STATUS btm_sec_execute_procedure (tBTM_SEC_DEV_REC *p_dev_rec)
 {
     BTM_TRACE_EVENT ("btm_sec_execute_procedure: Required:0x%x Flags:0x%x State:%d",
                       p_dev_rec->security_required, p_dev_rec->sec_flags, p_dev_rec->sec_state);