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

Commit 455efeec authored by Henri Chataing's avatar Henri Chataing
Browse files

btif_a2dp_source: Call btif_a2dp_source_shutdown_delayed with no scheduling

if already on the same thread. Doing otherwise the caller with block
the main thread waiting on the shutdown completion.

Bug: 374166531
Bug: 384401534
Test: m com.android.btservices
Flag: com.android.bluetooth.flags.a2dp_source_threading_fix
Change-Id: Ib538db147cb800ecb469a7bf104acd3612503e90
parent 0f1bd20e
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -574,8 +574,13 @@ void btif_a2dp_source_shutdown(std::promise<void> shutdown_complete_promise) {
  /* Make sure no channels are restarted while shutting down */
  btif_a2dp_source_cb.SetState(BtifA2dpSource::kStateShuttingDown);

  // TODO(b/374166531) Remove the check for get_main_thread.
  if (local_thread() != get_main_thread()) {
    local_thread()->DoInThread(FROM_HERE, base::BindOnce(&btif_a2dp_source_shutdown_delayed,
                                                         std::move(shutdown_complete_promise)));
  } else {
    btif_a2dp_source_shutdown_delayed(std::move(shutdown_complete_promise));
  }
}

static void btif_a2dp_source_shutdown_delayed(std::promise<void> shutdown_complete_promise) {