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

Commit 3b98d24b authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5363709 from ab45924f to pi-qpr3-b-release

Change-Id: I32fa1b41df1140ed6855ce534c40fad06e843eef
parents 143d6133 ab45924f
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -346,9 +346,10 @@ void AvrcpService::SendMediaUpdate(bool track_changed, bool play_state,

  // This function may be called on any thread, we need to make sure that the
  // device update happens on the main thread.
  for (auto device : instance_->connection_handler_->GetListOfDevices()) {
    do_in_bta_thread(FROM_HERE, base::Bind(&Device::SendMediaUpdate,
                                           base::Unretained(device.get()),
  for (const auto& device :
       instance_->connection_handler_->GetListOfDevices()) {
    do_in_bta_thread(FROM_HERE,
                     base::Bind(&Device::SendMediaUpdate, device.get()->Get(),
                                track_changed, play_state, queue));
  }
}
@@ -361,10 +362,10 @@ void AvrcpService::SendFolderUpdate(bool available_players,
            << " uids=" << uids;

  // Ensure that the update is posted to the correct thread
  for (auto device : instance_->connection_handler_->GetListOfDevices()) {
    do_in_bta_thread(
        FROM_HERE,
        base::Bind(&Device::SendFolderUpdate, base::Unretained(device.get()),
  for (const auto& device :
       instance_->connection_handler_->GetListOfDevices()) {
    do_in_bta_thread(FROM_HERE,
                     base::Bind(&Device::SendFolderUpdate, device.get()->Get(),
                                available_players, addressed_players, uids));
  }
}
+2 −0
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ void Device::RegisterInterfaces(MediaInterface* media_interface,
  volume_interface_ = volume_interface;
}

base::WeakPtr<Device> Device::Get() { return weak_ptr_factory_.GetWeakPtr(); }

bool Device::IsActive() const {
  return address_ == a2dp_interface_->active_peer();
}
+6 −0
Original line number Diff line number Diff line
@@ -55,6 +55,12 @@ class Device {
      uint16_t ctrl_mtu, uint16_t browse_mtu);
  virtual ~Device() = default;

  /**
   * Gets a weak pointer to this device that is invalidated when the device is
   * disconnected.
   */
  base::WeakPtr<Device> Get();

  const RawAddress& GetAddress() const { return address_; };

  /**
+13 −17
Original line number Diff line number Diff line
@@ -149,6 +149,12 @@ bool BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class,
  return true;
}

void wipe_secrets_and_remove(tBTM_SEC_DEV_REC* p_dev_rec) {
  memset(p_dev_rec->link_key, 0, LINK_KEY_LEN);
  memset(&p_dev_rec->ble.keys, 0, sizeof(tBTM_SEC_BLE_KEYS));
  list_remove(btm_cb.sec_dev_rec, p_dev_rec);
}

/** Free resources associated with the device associated with |bd_addr| address.
 *
 * *** WARNING ***
@@ -170,7 +176,10 @@ bool BTM_SecDeleteDevice(const RawAddress& bd_addr) {
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr);
  if (p_dev_rec != NULL) {
    RawAddress bda = p_dev_rec->bd_addr;
    btm_sec_free_dev(p_dev_rec);

    /* Clear out any saved BLE keys */
    btm_sec_clear_ble_keys(p_dev_rec);
    wipe_secrets_and_remove(p_dev_rec);
    /* Tell controller to get rid of the link key, if it has one stored */
    BTM_DeleteStoredLinkKey(&bda, NULL);
  }
@@ -255,19 +264,6 @@ tBTM_SEC_DEV_REC* btm_sec_alloc_dev(const RawAddress& bd_addr) {
  return (p_dev_rec);
}

/*******************************************************************************
 *
 * Function         btm_sec_free_dev
 *
 * Description      Mark device record as not used
 *
 ******************************************************************************/
void btm_sec_free_dev(tBTM_SEC_DEV_REC* p_dev_rec) {
  /* Clear out any saved BLE keys */
  btm_sec_clear_ble_keys(p_dev_rec);
  list_remove(btm_cb.sec_dev_rec, p_dev_rec);
}

/*******************************************************************************
 *
 * Function         btm_dev_support_switch
@@ -413,7 +409,7 @@ void btm_consolidate_dev(tBTM_SEC_DEV_REC* p_target_rec) {
      p_target_rec->bond_type = temp_rec.bond_type;

      /* remove the combined record */
      list_remove(btm_cb.sec_dev_rec, p_dev_rec);
      wipe_secrets_and_remove(p_dev_rec);
      // p_dev_rec gets freed in list_remove, we should not  access it further
      continue;
    }
@@ -425,7 +421,7 @@ void btm_consolidate_dev(tBTM_SEC_DEV_REC* p_target_rec) {
        p_target_rec->device_type |= p_dev_rec->device_type;

        /* remove the combined record */
        list_remove(btm_cb.sec_dev_rec, p_dev_rec);
        wipe_secrets_and_remove(p_dev_rec);
      }
    }
  }
@@ -514,7 +510,7 @@ tBTM_SEC_DEV_REC* btm_sec_allocate_dev_rec(void) {

  if (list_length(btm_cb.sec_dev_rec) > BTM_SEC_MAX_DEVICE_RECORDS) {
    p_dev_rec = btm_find_oldest_dev_rec();
    list_remove(btm_cb.sec_dev_rec, p_dev_rec);
    wipe_secrets_and_remove(p_dev_rec);
  }

  p_dev_rec =
+1 −1
Original line number Diff line number Diff line
@@ -208,7 +208,7 @@ extern bool btm_dev_support_switch(const RawAddress& bd_addr);

extern tBTM_SEC_DEV_REC* btm_sec_allocate_dev_rec(void);
extern tBTM_SEC_DEV_REC* btm_sec_alloc_dev(const RawAddress& bd_addr);
extern void btm_sec_free_dev(tBTM_SEC_DEV_REC* p_dev_rec);
extern void wipe_secrets_and_remove(tBTM_SEC_DEV_REC* p_dev_rec);
extern tBTM_SEC_DEV_REC* btm_find_dev(const RawAddress& bd_addr);
extern tBTM_SEC_DEV_REC* btm_find_or_alloc_dev(const RawAddress& bd_addr);
extern tBTM_SEC_DEV_REC* btm_find_dev_by_handle(uint16_t handle);
Loading