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

Commit 27fff601 authored by Zach Johnson's avatar Zach Johnson
Browse files

btu_task_start_up -> main_thread_start_up

pull contents out that are not about starting
the main thread

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: Ia2ec9be82e20559327a331cbf35b979013645fde
parent 5bb7de67
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -37,8 +37,10 @@

// Temp includes
#include "bt_utils.h"
#include "bta/sys/bta_sys.h"
#include "btif_config.h"
#include "btif_profile_queue.h"
#include "internal_include/bte.h"

using bluetooth::common::MessageLoopThread;

@@ -58,7 +60,7 @@ static void event_clean_up_stack(void* context);
static void event_signal_stack_up(void* context);
static void event_signal_stack_down(void* context);

void btu_task_start_up();
void main_thread_start_up();

// Unvetted includes/imports, etc which should be removed or vetted in the
// future
@@ -166,7 +168,18 @@ static void event_start_up_stack(UNUSED_ATTR void* context) {
  }

  BTU_StartUp();
  btu_task_start_up();

  btu_init_core();
  BTE_InitStack();
  bta_sys_init();
  module_init(get_module(BTE_LOGMSG_MODULE));

  main_thread_start_up();

  if (do_in_jni_thread(FROM_HERE, base::Bind(btif_init_ok, 0, nullptr)) !=
      BT_STATUS_SUCCESS) {
    LOG(FATAL) << __func__ << ": unable to continue starting Bluetooth";
  }

  if (future_await(local_hack_future) != FUTURE_SUCCESS) {
    LOG_ERROR("%s failed to start up the stack", __func__);
+1 −24
Original line number Diff line number Diff line
@@ -108,26 +108,7 @@ bt_status_t do_in_main_thread_delayed(const base::Location& from_here,
  return BT_STATUS_SUCCESS;
}

void btu_task_start_up() {
  LOG(INFO) << "Bluetooth chip preload is complete";

  /* Initialize the mandatory core stack control blocks
     (BTU, BTM, L2CAP, and SDP)
   */
  btu_init_core();

  /* Initialize any optional stack components */
  BTE_InitStack();

  bta_sys_init();

  /* Initialise platform trace levels at this point as BTE_InitStack() and
   * bta_sys_init()
   * reset the control blocks and preset the trace level with
   * XXX_INITIAL_TRACE_LEVEL
   */
  module_init(get_module(BTE_LOGMSG_MODULE));

void main_thread_start_up() {
  main_thread.StartUp();
  if (!main_thread.IsRunning()) {
    LOG(FATAL) << __func__ << ": unable to start btu message loop thread.";
@@ -135,10 +116,6 @@ void btu_task_start_up() {
  if (!main_thread.EnableRealTimeScheduling()) {
    LOG(FATAL) << __func__ << ": unable to enable real time scheduling";
  }
  if (do_in_jni_thread(FROM_HERE, base::Bind(btif_init_ok, 0, nullptr)) !=
      BT_STATUS_SUCCESS) {
    LOG(FATAL) << __func__ << ": unable to continue starting Bluetooth";
  }
}

void btu_task_shut_down() {