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

Commit 9592229d authored by William Escande's avatar William Escande
Browse files

Avrcp: Fix NullException

Timing issue can cause AVRCP NE.
When Bluetooth turn off, a2dp call avrcp disconnect.

Bug: 328841933
Fix: 328841933
Test: None
Flag: Exempt trivial nullpointer check
Change-Id: I3decc84aa0975bb8f565176c4c0d9f4db5486c91
parent 3c2df109
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -460,23 +460,34 @@ ServiceInterface* AvrcpService::GetServiceInterface() {

void AvrcpService::ConnectDevice(const RawAddress& bdaddr) {
  log::info("address={}", bdaddr);

  if (connection_handler_ == nullptr) {
    return;
  }
  connection_handler_->ConnectDevice(bdaddr);
}

void AvrcpService::DisconnectDevice(const RawAddress& bdaddr) {
  log::info("address={}", bdaddr);
  if (connection_handler_ == nullptr) {
    return;
  }
  connection_handler_->DisconnectDevice(bdaddr);
}

void AvrcpService::SetBipClientStatus(const RawAddress& bdaddr, bool connected) {
  log::info("address={}, connected={}", bdaddr, connected);
  if (connection_handler_ == nullptr) {
    return;
  }
  connection_handler_->SetBipClientStatus(bdaddr, connected);
}

void AvrcpService::SendMediaUpdate(bool track_changed, bool play_state, bool queue) {
  log::info("track_changed={} :  play_state={} :  queue={}", track_changed, play_state, queue);

  if (instance_ == nullptr || instance_->connection_handler_ == nullptr) {
    return;
  }
  // This function may be called on any thread, we need to make sure that the
  // device update happens on the main thread.
  for (const auto& device : instance_->connection_handler_->GetListOfDevices()) {
@@ -489,6 +500,9 @@ void AvrcpService::SendFolderUpdate(bool available_players, bool addressed_playe
  log::info("available_players={} :  addressed_players={} :  uids={}", available_players,
            addressed_players, uids);

  if (instance_ == nullptr || instance_->connection_handler_ == nullptr) {
    return;
  }
  // Ensure that the update is posted to the correct thread
  for (const auto& device : instance_->connection_handler_->GetListOfDevices()) {
    do_in_main_thread(FROM_HERE, base::BindOnce(&Device::SendFolderUpdate, device.get()->Get(),