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

Commit 81c7d1d8 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of [19454630, 19416683, 17530926, 19500904, 19588293,...

Merge cherrypicks of [19454630, 19416683, 17530926, 19500904, 19588293, 19600909, 19563375, 19609315] into tm-release.

Change-Id: I69bef6d8643598d6d90b28a5f797f50084b1fc2d
parents c633b3bc 6e2717b7
Loading
Loading
Loading
Loading
+17 −12
Original line number Diff line number Diff line
@@ -652,13 +652,6 @@ void bta_dm_remove_device(const RawAddress& bd_addr) {
  if (!other_address_connected && !other_address.IsEmpty()) {
    bta_dm_process_remove_device(other_address);
  }

  /* Check the length of the paired devices, and if 0 then reset IRK */
  auto paired_devices = btif_config_get_paired_devices();
  if (paired_devices.empty()) {
    LOG_INFO("Last paired device removed, resetting IRK");
    btm_ble_reset_id();
  }
}

/*******************************************************************************
@@ -873,11 +866,9 @@ void bta_dm_search_start(tBTA_DM_MSG* p_data) {
 ******************************************************************************/
void bta_dm_search_cancel() {
  if (BTM_IsInquiryActive()) {
    LOG_DEBUG("Cancelling search with inquiry active");
    BTM_CancelInquiryNotifyWhenComplete([]() {
    BTM_CancelInquiry();
    bta_dm_search_cancel_notify();
    bta_dm_search_cmpl();
    });
  }
  /* If no Service Search going on then issue cancel remote name in case it is
     active */
@@ -4023,6 +4014,20 @@ void bta_dm_clear_event_filter(void) {
  bluetooth::shim::BTM_ClearEventFilter();
}

/*******************************************************************************
 *
 * Function         bta_dm_ble_reset_id
 *
 * Description      Reset the local adapter BLE keys.
 *
 * Parameters:
 *
 ******************************************************************************/
void bta_dm_ble_reset_id(void) {
  VLOG(1) << "bta_dm_ble_reset_id in bta_dm_act";
  bluetooth::shim::BTM_BleResetId();
}

/*******************************************************************************
 *
 * Function         bta_dm_gattc_callback
+14 −0
Original line number Diff line number Diff line
@@ -675,3 +675,17 @@ void BTA_DmClearEventFilter(void) {
  APPL_TRACE_API("BTA_DmClearEventFilter");
  do_in_main_thread(FROM_HERE, base::Bind(bta_dm_clear_event_filter));
}

/*******************************************************************************
 *
 * Function         BTA_DmBleResetId
 *
 * Description      This function resets the ble keys such as IRK
 *
 * Returns          void
 *
 ******************************************************************************/
void BTA_DmBleResetId(void) {
  APPL_TRACE_API("BTA_DmBleResetId");
  do_in_main_thread(FROM_HERE, base::Bind(bta_dm_ble_reset_id));
}
+2 −0
Original line number Diff line number Diff line
@@ -543,6 +543,8 @@ extern tBTA_DM_PEER_DEVICE* bta_dm_find_peer_device(

extern void bta_dm_clear_event_filter(void);

extern void bta_dm_ble_reset_id(void);

uint8_t bta_dm_search_get_state();
void bta_dm_search_set_state(uint8_t state);

+11 −0
Original line number Diff line number Diff line
@@ -1203,4 +1203,15 @@ extern void BTA_VendorInit(void);
 ******************************************************************************/
extern void BTA_DmClearEventFilter(void);

/*******************************************************************************
 *
 * Function         BTA_DmBleResetId
 *
 * Description      This function resets the ble keys such as IRK
 *
 * Returns          void
 *
 ******************************************************************************/
extern void BTA_DmBleResetId(void);

#endif /* BTA_API_H */
+61 −18
Original line number Diff line number Diff line
@@ -1355,6 +1355,14 @@ static bool btif_is_interesting_le_service(bluetooth::Uuid uuid) {
          uuid == UUID_BATTERY);
}

static void btif_get_existing_uuids(RawAddress* bd_addr, Uuid* existing_uuids) {
  bt_property_t tmp_prop;
  BTIF_STORAGE_FILL_PROPERTY(&tmp_prop, BT_PROPERTY_UUIDS,
                             sizeof(existing_uuids), existing_uuids);

  btif_storage_get_remote_device_property(bd_addr, &tmp_prop);
}

/*******************************************************************************
 *
 * Function         btif_dm_search_services_evt
@@ -1372,6 +1380,7 @@ static void btif_dm_search_services_evt(tBTA_DM_SEARCH_EVT event,
      uint32_t i = 0;
      bt_status_t ret;
      std::vector<uint8_t> property_value;
      std::set<Uuid> uuids;

      RawAddress& bd_addr = p_data->disc_res.bd_addr;

@@ -1393,18 +1402,37 @@ 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)) {
        LOG_INFO("New UUIDs:");
        LOG_INFO("New UUIDs for %s:", bd_addr.ToString().c_str());
        for (i = 0; i < p_data->disc_res.num_uuids; i++) {
          auto uuid = p_data->disc_res.p_uuid_list + i;
          if (uuid->IsEmpty()) {
            continue;
          }
          LOG_INFO("index:%d uuid:%s", i, uuid->ToString().c_str());
          auto valAsBe = uuid->To128BitBE();
          pairing_cb.uuids.insert(valAsBe);
          uuids.insert(*uuid);
        }

        Uuid existing_uuids[BT_MAX_NUM_UUIDS] = {};
        btif_get_existing_uuids(&bd_addr, existing_uuids);

        for (int i = 0; i < BT_MAX_NUM_UUIDS; i++) {
          Uuid uuid = existing_uuids[i];
          if (uuid.IsEmpty()) {
            continue;
          }
          if (btif_is_interesting_le_service(uuid)) {
            LOG_INFO("interesting le service %s insert",
                     uuid.ToString().c_str());
            uuids.insert(uuid);
          }
        for (auto uuid : pairing_cb.uuids) {
          property_value.insert(property_value.end(), uuid.begin(), uuid.end());
        }
        for (auto& uuid : uuids) {
          auto uuid_128bit = uuid.To128BitBE();
          property_value.insert(property_value.end(), uuid_128bit.begin(),
                                uuid_128bit.end());
        }
        prop.val = (void*)property_value.data();
        prop.len = Uuid::kNumBytes128 * pairing_cb.uuids.size();
        prop.len = Uuid::kNumBytes128 * uuids.size();
      }

      /* onUuidChanged requires getBondedDevices to be populated.
@@ -1469,30 +1497,45 @@ static void btif_dm_search_services_evt(tBTA_DM_SEARCH_EVT event,
      int num_properties = 0;
      bt_property_t prop[2];
      std::vector<uint8_t> property_value;
      int num_uuids = 0;
      std::set<Uuid> uuids;
      RawAddress& bd_addr = p_data->disc_ble_res.bd_addr;

      LOG_INFO("New BLE UUIDs:");
      LOG_INFO("New BLE UUIDs for %s:", bd_addr.ToString().c_str());
      for (Uuid uuid : *p_data->disc_ble_res.services) {
        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();
          pairing_cb.uuids.insert(valAsBe);
          if (uuid.IsEmpty()) {
            continue;
          }
          LOG_INFO("index:%d uuid:%s", static_cast<int>(uuids.size()),
                   uuid.ToString().c_str());
          uuids.insert(uuid);
        }
      for (auto uuid : pairing_cb.uuids) {
        property_value.insert(property_value.end(), uuid.begin(), uuid.end());
      }

      if (num_uuids == 0) {
      if (uuids.empty()) {
        LOG_INFO("No well known BLE services discovered");
        return;
      }

      RawAddress& bd_addr = p_data->disc_ble_res.bd_addr;
      Uuid existing_uuids[BT_MAX_NUM_UUIDS] = {};
      btif_get_existing_uuids(&bd_addr, existing_uuids);
      for (int i = 0; i < BT_MAX_NUM_UUIDS; i++) {
        Uuid uuid = existing_uuids[i];
        if (uuid.IsEmpty()) {
          continue;
        }
        uuids.insert(uuid);
      }

      for (auto& uuid : uuids) {
        auto uuid_128bit = uuid.To128BitBE();
        property_value.insert(property_value.end(), uuid_128bit.begin(),
                              uuid_128bit.end());
      }

      prop[0].type = BT_PROPERTY_UUIDS;
      prop[0].val = (void*)property_value.data();
      prop[0].len = Uuid::kNumBytes128 * pairing_cb.uuids.size();
      prop[0].len = Uuid::kNumBytes128 * uuids.size();

      /* Also write this to the NVRAM */
      bt_status_t ret =
Loading