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

Commit e8632e36 authored by Jack He's avatar Jack He Committed by Android (Google) Code Review
Browse files

Merge "Store and report the union of SDP and BLE UUIDs." into tm-dev

parents ba00fdc0 f0a68745
Loading
Loading
Loading
Loading
+20 −9
Original line number Diff line number Diff line
@@ -166,6 +166,7 @@ typedef struct {
  uint8_t fail_reason;
  Uuid::UUID128Bit eir_uuids[32];
  uint8_t num_eir_uuids;
  std::set<Uuid::UUID128Bit> uuids;
} btif_dm_pairing_cb_t;

// TODO(jpawlowski): unify ?
@@ -1370,6 +1371,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;

@@ -1391,12 +1393,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.
@@ -1463,15 +1471,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");
@@ -1481,7 +1492,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 =
@@ -1576,7 +1587,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");