OSDN Git Service

Merge BTM_SecBond and BTM_SecBondByTransport
authorJakub Pawlowski <jpawlowski@google.com>
Tue, 7 Jan 2020 12:47:55 +0000 (13:47 +0100)
committerJakub Pawlowski <jpawlowski@google.com>
Tue, 7 Jan 2020 14:25:40 +0000 (15:25 +0100)
This makes the API surface smaller, and code paths easier to follow.

Bug: 147086339
Change-Id: Ia24771d73792bd352678d41550608f805f27062c

bta/dm/bta_dm_act.cc
bta/dm/bta_dm_api.cc
bta/include/bta_api.h
btif/src/btif_dm.cc
main/shim/btm_api.cc
main/shim/btm_api.h
stack/btm/btm_sec.cc
stack/include/btm_api.h

index 4942eea..f1f062c 100644 (file)
@@ -814,14 +814,10 @@ void bta_dm_remove_all_acl(const tBTA_DM_LINK_TYPE link_type) {
 
 /** Bonds with peer device */
 void bta_dm_bond(const RawAddress& bd_addr, tBTA_TRANSPORT transport) {
-  tBTM_STATUS status;
   tBTA_DM_SEC sec_event;
   char* p_name;
 
-  if (transport == BTA_TRANSPORT_UNKNOWN)
-    status = BTM_SecBond(bd_addr, 0, NULL, 0);
-  else
-    status = BTM_SecBondByTransport(bd_addr, transport, 0, NULL, 0);
+  tBTM_STATUS status = BTM_SecBond(bd_addr, transport, 0, NULL, 0);
 
   if (bta_dm_cb.p_sec_cback && (status != BTM_CMD_STARTED)) {
     memset(&sec_event, 0, sizeof(tBTA_DM_SEC));
index 979d2f6..584fe09 100644 (file)
@@ -210,14 +210,7 @@ void BTA_DmDiscoverUUID(const RawAddress& bd_addr, const Uuid& uuid,
 }
 
 /** This function initiates a bonding procedure with a peer device */
-void BTA_DmBond(const RawAddress& bd_addr) {
-  do_in_main_thread(FROM_HERE,
-                    base::Bind(bta_dm_bond, bd_addr, BTA_TRANSPORT_UNKNOWN));
-}
-
-/** This function initiates a bonding procedure with a peer device */
-void BTA_DmBondByTransport(const RawAddress& bd_addr,
-                           tBTA_TRANSPORT transport) {
+void BTA_DmBond(const RawAddress& bd_addr, tBTA_TRANSPORT transport) {
   do_in_main_thread(FROM_HERE, base::Bind(bta_dm_bond, bd_addr, transport));
 }
 
index 02ca28e..9c2343d 100644 (file)
@@ -1188,20 +1188,6 @@ tBTA_STATUS BTA_DmGetCachedRemoteName(const RawAddress& remote_device,
  * Function         BTA_DmBond
  *
  * Description      This function initiates a bonding procedure with a peer
- *                  device.  The bonding procedure enables authentication
- *                  and optionally encryption on the Bluetooth link.
- *
- *
- * Returns          void
- *
- ******************************************************************************/
-extern void BTA_DmBond(const RawAddress& bd_addr);
-
-/*******************************************************************************
- *
- * Function         BTA_DmBondByTransport
- *
- * Description      This function initiates a bonding procedure with a peer
  *                  device by designated transport.  The bonding procedure
  *                  enables authentication and optionally encryption on the
  *                  Bluetooth link.
@@ -1210,8 +1196,7 @@ extern void BTA_DmBond(const RawAddress& bd_addr);
  * Returns          void
  *
  ******************************************************************************/
-extern void BTA_DmBondByTransport(const RawAddress& bd_addr,
-                                  tBTA_TRANSPORT transport);
+extern void BTA_DmBond(const RawAddress& bd_addr, tBTA_TRANSPORT transport);
 
 /*******************************************************************************
  *
index 5543988..b915f1f 100644 (file)
@@ -697,7 +697,7 @@ static void btif_dm_cb_create_bond(const RawAddress& bd_addr,
     if (status != BT_STATUS_SUCCESS)
       bond_state_changed(status, bd_addr, BT_BOND_STATE_NONE);
   } else {
-    BTA_DmBondByTransport(bd_addr, transport);
+    BTA_DmBond(bd_addr, transport);
   }
   /*  Track  originator of bond creation  */
   pairing_cb.is_local_initiated = true;
index b1cdd60..bd1003b 100644 (file)
@@ -1061,18 +1061,9 @@ bool bluetooth::shim::BTM_BleLocalPrivacyEnabled(void) {
   return controller_get_interface()->supports_ble_privacy();
 }
 
-tBTM_STATUS bluetooth::shim::BTM_SecBondByTransport(const RawAddress& bd_addr,
-                                                    tBT_TRANSPORT transport,
-                                                    uint8_t pin_len,
-                                                    uint8_t* p_pin,
-                                                    uint32_t trusted_mask[]) {
-  return shim_btm.CreateBond(bd_addr, transport, pin_len, p_pin, trusted_mask);
-}
-
 tBTM_STATUS bluetooth::shim::BTM_SecBond(const RawAddress& bd_addr,
+                                         tBT_TRANSPORT transport,
                                          uint8_t pin_len, uint8_t* p_pin,
                                          uint32_t trusted_mask[]) {
-  tBT_TRANSPORT transport = BT_TRANSPORT_BR_EDR;
-  // TODO: do proper transport guessing
   return shim_btm.CreateBond(bd_addr, transport, pin_len, p_pin, trusted_mask);
 }
index b470ded..e9f41f7 100644 (file)
@@ -1797,23 +1797,6 @@ void BTM_PINCodeReply(const RawAddress& bd_addr, uint8_t res, uint8_t pin_len,
  *
  * Function         BTM_SecBond
  *
- * Description      This function is called to perform bonding with peer device.
- *
- * Parameters:      bd_addr      - Address of the device to bond
- *                  pin_len      - length in bytes of the PIN Code
- *                  p_pin        - pointer to array with the PIN Code
- *                  trusted_mask - bitwise OR of trusted services
- *                                 (array of uint32_t)
- * Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
- *
- ******************************************************************************/
-tBTM_STATUS BTM_SecBond(const RawAddress& bd_addr, uint8_t pin_len,
-                        uint8_t* p_pin, uint32_t trusted_mask[]);
-
-/*******************************************************************************
- *
- * Function         BTM_SecBondByTransport
- *
  * Description      Perform bonding by designated transport
  *
  * Parameters:      bd_addr      - Address of the device to bond
@@ -1827,9 +1810,9 @@ tBTM_STATUS BTM_SecBond(const RawAddress& bd_addr, uint8_t pin_len,
  * Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
  *
  ******************************************************************************/
-tBTM_STATUS BTM_SecBondByTransport(const RawAddress& bd_addr,
-                                   tBT_TRANSPORT transport, uint8_t pin_len,
-                                   uint8_t* p_pin, uint32_t trusted_mask[]);
+tBTM_STATUS BTM_SecBond(const RawAddress& bd_addr, tBT_TRANSPORT transport,
+                        uint8_t pin_len, uint8_t* p_pin,
+                        uint32_t trusted_mask[]);
 
 /*******************************************************************************
  *
@@ -2355,23 +2338,6 @@ tBTM_STATUS BTM_BleGetEnergyInfo(tBTM_BLE_ENERGY_INFO_CBACK* p_ener_cback);
  * Function         BTM_SecBond
  *
  * Description      This function is called to perform bonding with peer device.
- *
- * Parameters:      bd_addr      - Address of the device to bond
- *                  pin_len      - length in bytes of the PIN Code
- *                  p_pin        - pointer to array with the PIN Code
- *                  trusted_mask - bitwise OR of trusted services
- *                                 (array of uint32_t)
- * Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
- *
- ******************************************************************************/
-tBTM_STATUS BTM_SecBond(const RawAddress& bd_addr, uint8_t pin_len,
-                        uint8_t* p_pin, uint32_t trusted_mask[]);
-
-/*******************************************************************************
- *
- * Function         BTM_SecBondByTransport
- *
- * Description      This function is called to perform bonding with peer device.
  *                  If the connection is already up, but not secure, pairing
  *                  is attempted.  If already paired BTM_SUCCESS is returned.
  *
@@ -2384,8 +2350,8 @@ tBTM_STATUS BTM_SecBond(const RawAddress& bd_addr, uint8_t pin_len,
  *
  *  Note: After 2.1 parameters are not used and preserved here not to change API
  ******************************************************************************/
-tBTM_STATUS BTM_SecBondByTransport(const RawAddress& bd_addr,
-                                   tBT_TRANSPORT transport, uint8_t pin_len,
-                                   uint8_t* p_pin, uint32_t trusted_mask[]);
+tBTM_STATUS BTM_SecBond(const RawAddress& bd_addr, tBT_TRANSPORT transport,
+                        uint8_t pin_len, uint8_t* p_pin,
+                        uint32_t trusted_mask[]);
 }  // namespace shim
 }  // namespace bluetooth
index 921d6be..a30d234 100644 (file)
@@ -997,7 +997,7 @@ tBTM_STATUS btm_sec_bond_by_transport(const RawAddress& bd_addr,
 
 /*******************************************************************************
  *
- * Function         BTM_SecBondByTransport
+ * Function         BTM_SecBond
  *
  * Description      This function is called to perform bonding with peer device.
  *                  If the connection is already up, but not secure, pairing
@@ -1012,14 +1012,17 @@ tBTM_STATUS btm_sec_bond_by_transport(const RawAddress& bd_addr,
  *
  *  Note: After 2.1 parameters are not used and preserved here not to change API
  ******************************************************************************/
-tBTM_STATUS BTM_SecBondByTransport(const RawAddress& bd_addr,
-                                   tBT_TRANSPORT transport, uint8_t pin_len,
-                                   uint8_t* p_pin, uint32_t trusted_mask[]) {
+tBTM_STATUS BTM_SecBond(const RawAddress& bd_addr, tBT_TRANSPORT transport,
+                        uint8_t pin_len, uint8_t* p_pin,
+                        uint32_t trusted_mask[]) {
   if (bluetooth::shim::is_gd_shim_enabled()) {
-    return bluetooth::shim::BTM_SecBondByTransport(bd_addr, transport, pin_len,
-                                                   p_pin, trusted_mask);
+    return bluetooth::shim::BTM_SecBond(bd_addr, transport, pin_len, p_pin,
+                                        trusted_mask);
   }
 
+  if (transport == BT_TRANSPORT_INVALID)
+    transport = BTM_UseLeLink(bd_addr) ? BT_TRANSPORT_LE : BT_TRANSPORT_BR_EDR;
+
   tBT_DEVICE_TYPE dev_type;
   tBLE_ADDR_TYPE addr_type;
 
@@ -1036,33 +1039,6 @@ tBTM_STATUS BTM_SecBondByTransport(const RawAddress& bd_addr,
 
 /*******************************************************************************
  *
- * Function         BTM_SecBond
- *
- * Description      This function is called to perform bonding with peer device.
- *                  If the connection is already up, but not secure, pairing
- *                  is attempted.  If already paired BTM_SUCCESS is returned.
- *
- * Parameters:      bd_addr      - Address of the device to bond
- *                  pin_len      - length in bytes of the PIN Code
- *                  p_pin        - pointer to array with the PIN Code
- *                  trusted_mask - bitwise OR of trusted services
- *                                 (array of uint32_t)
- *
- *  Note: After 2.1 parameters are not used and preserved here not to change API
- ******************************************************************************/
-tBTM_STATUS BTM_SecBond(const RawAddress& bd_addr, uint8_t pin_len,
-                        uint8_t* p_pin, uint32_t trusted_mask[]) {
-  if (bluetooth::shim::is_gd_shim_enabled()) {
-    return bluetooth::shim::BTM_SecBond(bd_addr, pin_len, p_pin, trusted_mask);
-  }
-
-  tBT_TRANSPORT transport = BT_TRANSPORT_BR_EDR;
-  if (BTM_UseLeLink(bd_addr)) transport = BT_TRANSPORT_LE;
-  return btm_sec_bond_by_transport(bd_addr, transport, pin_len, p_pin,
-                                   trusted_mask);
-}
-/*******************************************************************************
- *
  * Function         BTM_SecBondCancel
  *
  * Description      This function is called to cancel ongoing bonding process
index 2b5de51..33fed3b 100644 (file)
@@ -1189,23 +1189,6 @@ extern void BTM_PINCodeReply(const RawAddress& bd_addr, uint8_t res,
  *
  * Function         BTM_SecBond
  *
- * Description      This function is called to perform bonding with peer device.
- *
- * Parameters:      bd_addr      - Address of the device to bond
- *                  pin_len      - length in bytes of the PIN Code
- *                  p_pin        - pointer to array with the PIN Code
- *                  trusted_mask - bitwise OR of trusted services
- *                                 (array of uint32_t)
- * Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
- *
- ******************************************************************************/
-extern tBTM_STATUS BTM_SecBond(const RawAddress& bd_addr, uint8_t pin_len,
-                               uint8_t* p_pin, uint32_t trusted_mask[]);
-
-/*******************************************************************************
- *
- * Function         BTM_SecBondByTransport
- *
  * Description      Perform bonding by designated transport
  *
  * Parameters:      bd_addr      - Address of the device to bond
@@ -1219,10 +1202,9 @@ extern tBTM_STATUS BTM_SecBond(const RawAddress& bd_addr, uint8_t pin_len,
  * Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
  *
  ******************************************************************************/
-extern tBTM_STATUS BTM_SecBondByTransport(const RawAddress& bd_addr,
-                                          tBT_TRANSPORT transport,
-                                          uint8_t pin_len, uint8_t* p_pin,
-                                          uint32_t trusted_mask[]);
+extern tBTM_STATUS BTM_SecBond(const RawAddress& bd_addr,
+                               tBT_TRANSPORT transport, uint8_t pin_len,
+                               uint8_t* p_pin, uint32_t trusted_mask[]);
 
 /*******************************************************************************
  *