Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9285462c authored by Jack He's avatar Jack He Committed by Gerrit Code Review
Browse files

Merge "Store and report the union of SDP and BLE UUIDs."

parents 95cece1d 8859f372
Loading
Loading
Loading
Loading
+20 −9
Original line number Diff line number Diff line
@@ -164,6 +164,7 @@ typedef struct {
  bool is_le_nc; /* LE Numeric comparison */
  btif_dm_ble_cb_t ble;
  uint8_t fail_reason;
  std::set<Uuid::UUID128Bit> uuids;
} btif_dm_pairing_cb_t;

// TODO(jpawlowski): unify ?
@@ -1383,6 +1384,7 @@ static void btif_dm_search_services_evt(tBTA_DM_SEARCH_EVT event,
      bt_property_t prop;
      uint32_t i = 0;
      bt_status_t ret;
      std::vector<uint8_t> property_value;

      RawAddress& bd_addr = p_data->disc_res.bd_addr;

@@ -1404,12 +1406,18 @@ static void btif_dm_search_services_evt(tBTA_DM_SEARCH_EVT event,
      prop.len = 0;
      if ((p_data->disc_res.result == BTA_SUCCESS) &&
          (p_data->disc_res.num_uuids > 0)) {
        prop.val = p_data->disc_res.p_uuid_list;
        prop.len = p_data->disc_res.num_uuids * Uuid::kNumBytes128;
        LOG_INFO("New UUIDs:");
        for (i = 0; i < p_data->disc_res.num_uuids; i++) {
          std::string temp = ((p_data->disc_res.p_uuid_list + i))->ToString();
          LOG_INFO("index:%d uuid:%s", i, temp.c_str());
          auto uuid = p_data->disc_res.p_uuid_list + i;
          LOG_INFO("index:%d uuid:%s", i, uuid->ToString().c_str());
          auto valAsBe = uuid->To128BitBE();
          pairing_cb.uuids.insert(valAsBe);
        }
        for (auto uuid : pairing_cb.uuids) {
          property_value.insert(property_value.end(), uuid.begin(), uuid.end());
        }
        prop.val = (void*)property_value.data();
        prop.len = Uuid::kNumBytes128 * pairing_cb.uuids.size();
      }

      /* onUuidChanged requires getBondedDevices to be populated.
@@ -1470,15 +1478,18 @@ static void btif_dm_search_services_evt(tBTA_DM_SEARCH_EVT event,
      std::vector<uint8_t> property_value;
      int num_uuids = 0;

      LOG_INFO("New BLE UUIDs:");
      for (Uuid uuid : *p_data->disc_ble_res.services) {
        LOG_VERBOSE("service %s", uuid.ToString().c_str());
        LOG_INFO("index:%d uuid:%s", num_uuids, uuid.ToString().c_str());
        if (btif_is_interesting_le_service(uuid)) {
          num_uuids++;
          auto valAsBe = uuid.To128BitBE();
          property_value.insert(property_value.end(), valAsBe.begin(),
                                valAsBe.end());
          pairing_cb.uuids.insert(valAsBe);
        }
      }
      for (auto uuid : pairing_cb.uuids) {
        property_value.insert(property_value.end(), uuid.begin(), uuid.end());
      }

      if (num_uuids == 0) {
        LOG_INFO("No well known BLE services discovered");
@@ -1488,7 +1499,7 @@ static void btif_dm_search_services_evt(tBTA_DM_SEARCH_EVT event,
      RawAddress& bd_addr = p_data->disc_ble_res.bd_addr;
      prop[0].type = BT_PROPERTY_UUIDS;
      prop[0].val = (void*)property_value.data();
      prop[0].len = Uuid::kNumBytes128 * num_uuids;
      prop[0].len = Uuid::kNumBytes128 * pairing_cb.uuids.size();

      /* Also write this to the NVRAM */
      bt_status_t ret =
@@ -1584,7 +1595,7 @@ void BTIF_dm_enable() {
    }
  }
  /* clear control blocks */
  memset(&pairing_cb, 0, sizeof(btif_dm_pairing_cb_t));
  pairing_cb = {};
  pairing_cb.bond_type = tBTM_SEC_DEV_REC::BOND_TYPE_PERSISTENT;
  if (enable_address_consolidate) {
    LOG_INFO("enable address consolidate");