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

Commit 61fc7d0c authored by Zach Johnson's avatar Zach Johnson Committed by Gerrit Code Review
Browse files

Merge changes I1bd2a3c5,I3c65d97c,I1fd446a1,I6946791b,Ie1f73bc1, ...

* changes:
  Remove bta_sys_free, it's empty
  No need to bounce BTA_sys_signal_hw_error through main thread
  No need to bounce through BTA_dm_on_hw_error
  Delete bta_sys_sm_execute
  Delete bta_sys state machine, freaking finally
  Inline bta_sys_hw_api_disable
  Replace BTA_SYS_API_DISABLE_EVT with direct call
  Send BTA_SYS_API_DISABLE_EVT from stack manager
  Inline BTA_DisableBluetooth
  Remove now unused bt_startup_thread
  Inline btif_disable_bluetooth
  tBTA_DM_ENABLE status is always successful
  bta_dm_enable is guaranteed mutually exclusive
  Flatten BTA_SYS_EVT_STACK_ENABLED_EVT out of the state matchine
  Pull BTA_SYS_EVT_STACK_ENABLED_EVT out of BTM_reset_complete
parents fd7b785c 0a0989e7
Loading
Loading
Loading
Loading
+2 −22
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@
#include "stack/gatt/connection_manager.h"
#include "stack/include/acl_api.h"
#include "stack/include/gatt_api.h"
#include "stack_manager.h"
#include "utl.h"

#if (GAP_INCLUDED == TRUE)
@@ -250,17 +251,6 @@ static uint8_t btm_local_io_caps;

/** Initialises the BT device manager */
void bta_dm_enable(tBTA_DM_SEC_CBACK* p_sec_cback) {
  /* if already in use, return an error */
  if (bta_dm_cb.is_bta_dm_active) {
    tBTA_DM_SEC enable_event;
    APPL_TRACE_WARNING("%s Device already started by another application",
                       __func__);
    memset(&enable_event, 0, sizeof(tBTA_DM_SEC));
    enable_event.enable.status = BTA_FAILURE;
    if (p_sec_cback != NULL) p_sec_cback(BTA_DM_ENABLE_EVT, &enable_event);
    return;
  }

  /* make sure security callback is saved - if no callback, do not erase the
  previous one,
  it could be an error recovery mechanism */
@@ -317,12 +307,6 @@ void bta_dm_deinit_cb(void) {
  memset(&bta_dm_cb, 0, sizeof(bta_dm_cb));
}

void BTA_dm_on_hw_error() {
  if (bta_dm_cb.p_sec_cback != NULL) {
    bta_dm_cb.p_sec_cback(BTA_DM_HW_ERROR_EVT, NULL);
  }
}

void BTA_dm_on_hw_off() {
  if (bta_dm_cb.p_sec_cback != NULL)
    bta_dm_cb.p_sec_cback(BTA_DM_DISABLE_EVT, NULL);
@@ -2464,8 +2448,6 @@ static uint8_t bta_dm_sp_cback(tBTM_SP_EVT event, tBTM_SP_EVT_DATA* p_data) {
static void bta_dm_local_name_cback(UNUSED_ATTR void* p_name) {
  tBTA_DM_SEC sec_event;

  sec_event.enable.status = BTA_SUCCESS;

  if (bta_dm_cb.p_sec_cback)
    bta_dm_cb.p_sec_cback(BTA_DM_ENABLE_EVT, &sec_event);
}
@@ -2706,10 +2688,8 @@ static void bta_dm_disable_conn_down_timer_cback(UNUSED_ATTR void* data) {
  /* disable the power managment module */
  bta_dm_disable_pm();

  /* register our callback to SYS HW manager */
  send_bta_sys_hw_event(BTA_SYS_API_DISABLE_EVT);

  bta_dm_cb.disabling = false;
  future_ready(stack_manager_get_hack_future(), FUTURE_SUCCESS);
}

/*******************************************************************************
+0 −15
Original line number Diff line number Diff line
@@ -49,21 +49,6 @@ void BTA_dm_init() {
  bta_sys_eir_register(bta_dm_eir_update_uuid);
}

/*******************************************************************************
 *
 * Function         BTA_DisableBluetooth
 *
 * Description      Disables bluetooth service.  This function is called when
 *                  the application no longer needs bluetooth service
 *
 * Returns          void
 *
 ******************************************************************************/
tBTA_STATUS BTA_DisableBluetooth(void) {
  do_in_main_thread(FROM_HERE, base::Bind(bta_dm_disable));
  return BTA_SUCCESS;
}

/** Enables bluetooth device under test mode */
void BTA_EnableTestMode(void) {
  do_in_main_thread(FROM_HERE,
+0 −18
Original line number Diff line number Diff line
@@ -364,7 +364,6 @@ typedef uint8_t tBTA_SIG_STRENGTH_MASK;
  23 /* Simple Pairing Remote OOB Extended Data request. */
#define BTA_DM_BLE_AUTH_CMPL_EVT 24 /* BLE Auth complete */
#define BTA_DM_DEV_UNPAIRED_EVT 25
#define BTA_DM_HW_ERROR_EVT 26 /* BT Chip H/W error */
#define BTA_DM_LE_FEATURES_READ                                             \
  27                             /* Cotroller specific LE features are read \
                                    */
@@ -372,9 +371,6 @@ typedef uint8_t tBTA_SIG_STRENGTH_MASK;
#define BTA_DM_BLE_SC_OOB_REQ_EVT 29 /* SMP SC OOB request event */
typedef uint8_t tBTA_DM_SEC_EVT;

/* Structure associated with BTA_DM_ENABLE_EVT */
typedef struct { tBTA_STATUS status; } tBTA_DM_ENABLE;

/* Structure associated with BTA_DM_PIN_REQ_EVT */
typedef struct {
  /* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in
@@ -610,7 +606,6 @@ typedef struct {

/* Union of all security callback structures */
typedef union {
  tBTA_DM_ENABLE enable;          /* BTA enabled */
  tBTA_DM_PIN_REQ pin_req;        /* PIN request. */
  tBTA_DM_AUTH_CMPL auth_cmpl;    /* Authentication complete indication. */
  tBTA_DM_LINK_UP link_up;        /* ACL connection down event */
@@ -954,19 +949,6 @@ typedef uint8_t tBTA_DM_LINK_TYPE;
 ****************************************************************************/

void BTA_dm_init();
/*******************************************************************************
 *
 * Function         BTA_DisableBluetooth
 *
 * Description      This function disables BTA and the Bluetooth protocol
 *                  stack.  It is called when BTA is no longer being used
 *                  by any application in the system.
 *
 *
 * Returns          void
 *
 ******************************************************************************/
extern tBTA_STATUS BTA_DisableBluetooth(void);

/*******************************************************************************
 *
+2 −12
Original line number Diff line number Diff line
@@ -173,28 +173,18 @@ enum {
};
typedef uint8_t tBTA_SYS_HW_EVT;

/* SYS HW state */
enum {
  BTA_SYS_HW_OFF,
  BTA_SYS_HW_STARTING,
  BTA_SYS_HW_ON,
  BTA_SYS_HW_STOPPING
};
typedef uint8_t tBTA_SYS_HW_STATE;

/*****************************************************************************
 *  Function declarations
 ****************************************************************************/
void bta_sys_set_state(tBTA_SYS_HW_STATE value);
void bta_set_forward_hw_failures(bool value);
void BTA_sys_signal_hw_error();

extern void bta_sys_init(void);
extern void bta_sys_free(void);
extern void bta_sys_event(BT_HDR* p_msg);
extern void bta_sys_set_trace_level(uint8_t level);
extern void bta_sys_register(uint8_t id, const tBTA_SYS_REG* p_reg);
extern void bta_sys_deregister(uint8_t id);
extern bool bta_sys_is_register(uint8_t id);
extern void send_bta_sys_hw_event(tBTA_SYS_HW_EVT event);
extern void bta_sys_sendmsg(void* p_msg);
extern void bta_sys_sendmsg_delayed(void* p_msg, const base::TimeDelta& delay);
extern void bta_sys_start_timer(alarm_t* alarm, uint64_t interval_ms,
+1 −7
Original line number Diff line number Diff line
@@ -44,8 +44,7 @@ typedef struct {
typedef struct {
  tBTA_SYS_REG* reg[BTA_ID_MAX]; /* registration structures */
  bool is_reg[BTA_ID_MAX];       /* registration structures */
  tBTA_SYS_HW_STATE state;
  bool bluetooth_active;
  bool forward_hw_failures;
  uint16_t sys_features;         /* Bitmask of sys features */

  tBTA_SYS_CONN_CBACK* prm_cb; /* role management callback registered by DM */
@@ -73,9 +72,4 @@ typedef struct {
/* system manager control block */
extern tBTA_SYS_CB bta_sys_cb;

/* functions used for BTA SYS HW state machine */
void bta_sys_hw_error();
void bta_sys_hw_api_disable();
void bta_sys_hw_evt_enabled();

#endif /* BTA_SYS_INT_H */
Loading