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

Commit f2d3afc7 authored by Zach Johnson's avatar Zach Johnson
Browse files

Flatten BTA_EnableBluetooth

Keep it on the stack startup context

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I3c9d69e71cdeba4d28319d5c3baf82ade3fdb5b9
parent f1c6465b
Loading
Loading
Loading
Loading
+1 −19
Original line number Diff line number Diff line
@@ -44,28 +44,10 @@ using bluetooth::Uuid;
static const tBTA_SYS_REG bta_dm_search_reg = {bta_dm_search_sm_execute,
                                               bta_dm_search_sm_disable};

/*******************************************************************************
 *
 * Function         BTA_EnableBluetooth
 *
 * Description      Enables bluetooth service.  This function must be
 *                  called before any other functions in the BTA API are called.
 *
 *
 * Returns          tBTA_STATUS
 *
 ******************************************************************************/
tBTA_STATUS BTA_EnableBluetooth(tBTA_DM_SEC_CBACK* p_cback) {
  /* Bluetooth disabling is in progress */
  if (bta_dm_cb.disabling) return BTA_FAILURE;

void BTA_dm_init() {
  bta_sys_register(BTA_ID_DM_SEARCH, &bta_dm_search_reg);

  /* if UUID list is not provided as static data */
  bta_sys_eir_register(bta_dm_eir_update_uuid);

  do_in_main_thread(FROM_HERE, base::Bind(bta_dm_enable, p_cback));
  return BTA_SUCCESS;
}

/*******************************************************************************
+1 −17
Original line number Diff line number Diff line
@@ -953,23 +953,7 @@ typedef uint8_t tBTA_DM_LINK_TYPE;
 *  External Function Declarations
 ****************************************************************************/

/*******************************************************************************
 *
 * Function         BTA_EnableBluetooth
 *
 * Description      This function initializes BTA and prepares BTA and the
 *                  Bluetooth protocol stack for use.  This function is
 *                  typically called at startup or when Bluetooth services
 *                  are required by the phone.  This function must be called
 *                  before calling any other API function.
 *
 *
 * Returns          BTA_SUCCESS if successful.
 *                  BTA_FAIL if internal failure.
 *
 ******************************************************************************/
extern tBTA_STATUS BTA_EnableBluetooth(tBTA_DM_SEC_CBACK* p_cback);

void BTA_dm_init();
/*******************************************************************************
 *
 * Function         BTA_DisableBluetooth
+3 −1
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@
#if (defined BTA_AR_INCLUDED) && (BTA_AR_INCLUDED == TRUE)
#include "bta_ar_api.h"
#endif
#include "bta_dm_int.h"

using bluetooth::common::MessageLoopThread;

@@ -221,7 +222,8 @@ static void event_start_up_stack(UNUSED_ATTR void* context) {
  main_thread_start_up();

  btif_init_ok();
  BTA_EnableBluetooth(bte_dm_evt);
  BTA_dm_init();
  bta_dm_enable(bte_dm_evt);

  if (future_await(local_hack_future) != FUTURE_SUCCESS) {
    LOG_ERROR("%s failed to start up the stack", __func__);