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

Commit 0d3bb65d authored by Zach Johnson's avatar Zach Johnson
Browse files

Make BTA_dm_sys_hw_cback just about hw on

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I9754f2e4e3461ec06fe1ce73d828a54b59f56141
parent 5a3f0c90
Loading
Loading
Loading
Loading
+62 −78
Original line number Diff line number Diff line
@@ -338,25 +338,13 @@ void BTA_dm_on_hw_off() {
  /* notify BTA DM is now unactive */
  bta_dm_cb.is_bta_dm_active = false;
}
/*******************************************************************************
 *
 * Function         bta_dm_sys_hw_cback
 *
 * Description     callback register to SYS to get HW status updates
 *
 *
 * Returns          void
 *
 ******************************************************************************/
void BTA_dm_sys_hw_cback(tBTA_SYS_HW_EVT status) {

void BTA_dm_on_hw_on() {
  DEV_CLASS dev_class;
  tBTA_DM_SEC_CBACK* temp_cback;
  uint8_t key_mask = 0;
  tBTA_BLE_LOCAL_ID_KEYS id_key;

  APPL_TRACE_DEBUG("%s with event: %i", __func__, status);

  if (status == BTA_SYS_HW_ON_EVT) {
  /* save security callback */
  temp_cback = bta_dm_cb.p_sec_cback;
  /* make sure the control block is properly initialized */
@@ -388,8 +376,7 @@ void BTA_dm_sys_hw_cback(tBTA_SYS_HW_EVT status) {
  bta_dm_co_ble_load_local_keys(&key_mask, &er, &id_key);

  if (key_mask & BTA_BLE_LOCAL_KEY_TYPE_ER) {
      BTM_BleLoadLocalKeys(BTA_BLE_LOCAL_KEY_TYPE_ER,
                           (tBTM_BLE_LOCAL_KEYS*)&er);
    BTM_BleLoadLocalKeys(BTA_BLE_LOCAL_KEY_TYPE_ER, (tBTM_BLE_LOCAL_KEYS*)&er);
  }
  if (key_mask & BTA_BLE_LOCAL_KEY_TYPE_ID) {
    BTM_BleLoadLocalKeys(BTA_BLE_LOCAL_KEY_TYPE_ID,
@@ -407,7 +394,7 @@ void BTA_dm_sys_hw_cback(tBTA_SYS_HW_EVT status) {
  BTM_BleReadControllerFeatures(bta_dm_ctrl_features_rd_cmpl_cback);
#else
  /* If VSC multi adv commands are available, advertising will be initialized
     * when capabilities are read. If they are not avaliable, initialize
   * when capabilities are read. If they are not available, initialize
   * advertising here */
  btm_ble_adv_init();
#endif
@@ -432,9 +419,6 @@ void BTA_dm_sys_hw_cback(tBTA_SYS_HW_EVT status) {
  bta_sys_policy_register(bta_dm_policy_cback);

  bta_dm_gattc_register();

  } else
    APPL_TRACE_DEBUG(" --- ignored event");
}

/** Disables the BT device manager */
+0 −10
Original line number Diff line number Diff line
@@ -177,18 +177,8 @@ enum {

  BTA_SYS_MAX_EVT
};

/* SYS HW status events - returned by SYS HW manager to other modules. */
enum {
  BTA_SYS_HW_ON_EVT,
  BTA_SYS_HW_STARTING_EVT,
  BTA_SYS_HW_STOPPING_EVT,
};
typedef uint8_t tBTA_SYS_HW_EVT;

/* HW enable callback type */
typedef void(tBTA_SYS_HW_CBACK)(tBTA_SYS_HW_EVT status);

/*****************************************************************************
 *  Function declarations
 ****************************************************************************/
+0 −1
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ typedef struct {
  tBTA_SYS_REG* reg[BTA_ID_MAX]; /* registration structures */
  bool is_reg[BTA_ID_MAX];       /* registration structures */
  tBTA_SYS_HW_STATE state;
  tBTA_SYS_HW_CBACK* sys_hw_cback;
  bool bluetooth_active;
  uint16_t sys_features;         /* Bitmask of sys features */

+4 −4
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@
#include "bta_ar_api.h"
#endif

void BTA_dm_sys_hw_cback(tBTA_SYS_HW_EVT status);
void BTA_dm_on_hw_on();
void BTA_dm_on_hw_error();
void BTA_dm_on_hw_off();

@@ -115,7 +115,7 @@ static void bta_sys_sm_execute(tBTA_SYS_HW_EVT event) {
      switch (event) {
        case BTA_SYS_EVT_STACK_ENABLED_EVT:
          bta_sys_set_state(BTA_SYS_HW_ON);
          BTA_dm_sys_hw_cback(BTA_SYS_HW_ON_EVT);
          BTA_dm_on_hw_on();
          break;
        case BTA_SYS_API_DISABLE_EVT:
          bta_sys_set_state(BTA_SYS_HW_STOPPING);
@@ -155,7 +155,7 @@ static void bta_sys_sm_execute(tBTA_SYS_HW_EVT event) {
          bta_sys_set_state(BTA_SYS_HW_STARTING);
          break;
        case BTA_SYS_EVT_STACK_ENABLED_EVT:
          BTA_dm_sys_hw_cback(BTA_SYS_HW_ON_EVT);
          BTA_dm_on_hw_on();
          bta_sys_hw_api_disable();
          break;
        case BTA_SYS_EVT_DISABLED_EVT:
@@ -216,7 +216,7 @@ void bta_sys_hw_api_enable() {
    BTM_DeviceReset();
  } else {
    bta_sys_cb.bluetooth_active = true;
    BTA_dm_sys_hw_cback(BTA_SYS_HW_ON_EVT);
    BTA_dm_on_hw_on();
  }
}