OSDN Git Service

[automerger] Revert "DO NOT MERGE Separate SDP procedure from bonding state (1/2...
authorAndroid Build Merger (Role) <noreply-android-build-merger@google.com>
Wed, 1 May 2019 18:28:20 +0000 (18:28 +0000)
committerAndroid Build Merger (Role) <noreply-android-build-merger@google.com>
Wed, 1 May 2019 18:28:20 +0000 (18:28 +0000)
Change-Id: If67e79b47e46c5808dff364e9a51da247e2c82f3

1  2 
btif/src/btif_dm.c

diff --combined btif/src/btif_dm.c
@@@ -191,7 -191,6 +191,6 @@@ typedef struc
  #define BTA_SERVICE_ID_TO_SERVICE_MASK(id)       (1 << (id))
  
  #define UUID_HUMAN_INTERFACE_DEVICE "00001124-0000-1000-8000-00805f9b34fb"
- #define UUID_EMPTY "00000000-0000-0000-0000-000000000000"
  
  #define MAX_BTIF_BOND_EVENT_ENTRIES 15
  
@@@ -270,11 -269,6 +269,6 @@@ static bool is_empty_128bit(uint8_t *da
      return !memcmp(zero, data, sizeof(zero));
  }
  
- static bool is_bonding_or_sdp() {
-     return pairing_cb.state == BT_BOND_STATE_BONDING ||
-             (pairing_cb.state == BT_BOND_STATE_BONDED && pairing_cb.sdp_attempts);
- }
  static void btif_dm_data_copy(uint16_t event, char *dst, char *src)
  {
      tBTA_DM_SEC *dst_dm_sec = (tBTA_DM_SEC*)dst;
@@@ -556,19 -550,15 +550,15 @@@ static void bond_state_changed(bt_statu
  
      HAL_CBACK(bt_hal_cbacks, bond_state_changed_cb, status, bd_addr, state);
  
-     int dev_type;
-     if (!btif_get_device_type(bd_addr->address, &dev_type))
+     if (state == BT_BOND_STATE_BONDING)
      {
-         dev_type = BT_DEVICE_TYPE_BREDR;
-     }
-     if (state == BT_BOND_STATE_BONDING ||
-         (state == BT_BOND_STATE_BONDED && pairing_cb.sdp_attempts > 0))
-     {
-         // Save state for the device is bonding or SDP.
          pairing_cb.state = state;
          bdcpy(pairing_cb.bd_addr, bd_addr->address);
      } else {
-         memset(&pairing_cb, 0, sizeof(pairing_cb));
+         if (!pairing_cb.sdp_attempts)
+             memset(&pairing_cb, 0, sizeof(pairing_cb));
+         else
+             BTIF_TRACE_DEBUG("%s: BR-EDR service discovery active", __func__);
      }
  }
  
@@@ -1213,8 -1203,6 +1203,6 @@@ static void btif_dm_auth_cmpl_evt (tBTA
  
                  // Ensure inquiry is stopped before attempting service discovery
                  btif_dm_cancel_discovery();
-                 // Report bonded to Java before start SDP
-                 bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDED);
  
                  /* Trigger SDP on the device */
                  pairing_cb.sdp_attempts = 1;
@@@ -1508,7 -1496,7 +1496,7 @@@ static void btif_dm_search_services_evt
              BTIF_TRACE_DEBUG("%s:(result=0x%x, services 0x%x)", __FUNCTION__,
                      p_data->disc_res.result, p_data->disc_res.services);
              if  ((p_data->disc_res.result != BTA_SUCCESS) &&
-                  (pairing_cb.state == BT_BOND_STATE_BONDED) &&
+                  (pairing_cb.state == BT_BOND_STATE_BONDING ) &&
                   (pairing_cb.sdp_attempts < BTIF_DM_MAX_SDP_ATTEMPTS_AFTER_PAIRING))
              {
                  BTIF_TRACE_WARNING("%s:SDP failed after bonding re-attempting", __FUNCTION__);
              /* onUuidChanged requires getBondedDevices to be populated.
              ** bond_state_changed needs to be sent prior to remote_device_property
              */
-             if ((pairing_cb.state == BT_BOND_STATE_BONDED && pairing_cb.sdp_attempts) &&
+             if ((pairing_cb.state == BT_BOND_STATE_BONDING) &&
                  ((bdcmp(p_data->disc_res.bd_addr, pairing_cb.bd_addr) == 0) ||
-                  (bdcmp(p_data->disc_res.bd_addr, pairing_cb.static_bdaddr.address) == 0)))
+                  (bdcmp(p_data->disc_res.bd_addr, pairing_cb.static_bdaddr.address) == 0)) &&
+                   pairing_cb.sdp_attempts > 0)
              {
-                  LOG_INFO(LOG_TAG, "%s Remote Service SDP done.", __FUNCTION__);
+                  BTIF_TRACE_DEBUG("%s Remote Service SDP done. Call bond_state_changed_cb BONDED",
+                                    __FUNCTION__);
                   pairing_cb.sdp_attempts  = 0;
  
-                  // If bond occured due to cross-key pairing, send bond state callback
+                  // If bonding occured due to cross-key pairing, send bonding callback
                   // for static address now
                   if (bdcmp(p_data->disc_res.bd_addr, pairing_cb.static_bdaddr.address) == 0)
-                  {
-                       bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDING);
-                       bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDED);
-                  }
-                  if (pairing_cb.state == BT_BOND_STATE_BONDED) {
-                       if (p_data->disc_res.result == BTA_SUCCESS) {
-                           // Device is bonded and SDP completed. Clear the pairing control
-                           // block.
-                           memset(&pairing_cb, 0, sizeof(pairing_cb));
-                       } else {
-                           // Report empty UUID to Java if SDP report negative result while
-                           // pairing.
-                           bt_property_t prop;
-                           bt_uuid_t uuid;
-                           char uuid_str[128] = UUID_EMPTY;
-                           string_to_uuid(uuid_str, &uuid);
-                           prop.type = BT_PROPERTY_UUIDS;
-                           prop.val = uuid.uu;
-                           prop.len = MAX_UUID_SIZE;
-                           /* Send the event to the BTIF */
-                           HAL_CBACK(bt_hal_cbacks, remote_device_properties_cb,
-                                   BT_STATUS_SUCCESS, &bd_addr, 1, &prop);
-                           break;
-                       }
-                  }
+                     bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDING);
+                  bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDED);
              }
  
              if (p_data->disc_res.num_uuids != 0)
@@@ -1794,7 -1759,7 +1759,7 @@@ static void btif_dm_upstreams_evt(UINT1
              break;
  
          case BTA_DM_BOND_CANCEL_CMPL_EVT:
-             if (is_bonding_or_sdp())
+             if (pairing_cb.state == BT_BOND_STATE_BONDING)
              {
                  bdcpy(bd_addr.address, pairing_cb.bd_addr);
                  btm_set_bond_type_dev(pairing_cb.bd_addr, BOND_TYPE_UNKNOWN);
@@@ -2444,7 -2409,7 +2409,7 @@@ bt_status_t btif_dm_cancel_bond(const b
      **  1. Restore scan modes
      **  2. special handling for HID devices
      */
-     if (is_bonding_or_sdp())
+     if (pairing_cb.state == BT_BOND_STATE_BONDING)
      {
  
  #if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
  
  void btif_dm_hh_open_failed(bt_bdaddr_t *bdaddr)
  {
-     if (is_bonding_or_sdp() &&
+     if (pairing_cb.state == BT_BOND_STATE_BONDING &&
              bdcmp(bdaddr->address, pairing_cb.bd_addr) == 0)
      {
          bond_state_changed(BT_STATUS_FAIL, bdaddr, BT_BOND_STATE_NONE);
@@@ -3113,18 -3078,6 +3078,18 @@@ static void btif_dm_ble_auth_cmpl_evt (
              btif_storage_remove_bonded_device(&bdaddr);
              state = BT_BOND_STATE_NONE;
          } else {
 +            /*
 +             * Note: This is a Wear-specific feature for iOS pairing.
 +             * Store the address of the first bonded device that is also of type LE to
 +             * enable auto connection parameter update.
 +             */
 +#if (defined(WEAR_AUTO_CONN_PARAM_UPDATE) && (WEAR_AUTO_CONN_PARAM_UPDATE == TRUE))
 +            if (btif_storage_get_num_bonded_devices() == 0) {
 +                bdstr_t bdstr;
 +                bdaddr_to_string(&bdaddr, bdstr, sizeof(bdstr));
 +                btif_config_set_str("Adapter", "AutoConnParamUpdateAddr", bdstr);
 +            }
 +#endif
              btif_dm_save_ble_bonding_keys();
              BTA_GATTC_Refresh(bd_addr.address);
              btif_dm_get_remote_services_by_transport(&bd_addr, BTA_GATT_TRANSPORT_LE);
@@@ -3464,7 -3417,7 +3429,7 @@@ bt_status_t btif_le_test_mode(uint16_t 
  void btif_dm_on_disable()
  {
      /* cancel any pending pairing requests */
-     if (is_bonding_or_sdp())
+     if (pairing_cb.state == BT_BOND_STATE_BONDING)
      {
          bt_bdaddr_t bd_addr;