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

Commit 5a3f0c90 authored by Zach Johnson's avatar Zach Johnson
Browse files

Pull hw off out of BTA_dm_sys_hw_cback

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I92f1a18cb347edef98f7e826efa4e85535026096
parent 03bcbae4
Loading
Loading
Loading
Loading
+17 −15
Original line number Diff line number Diff line
@@ -322,6 +322,22 @@ void BTA_dm_on_hw_error() {
    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);

  /* reinitialize the control block */
  bta_dm_deinit_cb();

  /* hw is ready, go on with BTA DM initialization */
  alarm_free(bta_dm_search_cb.search_timer);
  alarm_free(bta_dm_search_cb.gatt_close_timer);
  memset(&bta_dm_search_cb, 0, sizeof(bta_dm_search_cb));

  /* notify BTA DM is now unactive */
  bta_dm_cb.is_bta_dm_active = false;
}
/*******************************************************************************
 *
 * Function         bta_dm_sys_hw_cback
@@ -340,21 +356,7 @@ void BTA_dm_sys_hw_cback(tBTA_SYS_HW_EVT status) {

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

  if (status == BTA_SYS_HW_OFF_EVT) {
    if (bta_dm_cb.p_sec_cback != NULL)
      bta_dm_cb.p_sec_cback(BTA_DM_DISABLE_EVT, NULL);

    /* reinitialize the control block */
    bta_dm_deinit_cb();

    /* hw is ready, go on with BTA DM initialization */
    alarm_free(bta_dm_search_cb.search_timer);
    alarm_free(bta_dm_search_cb.gatt_close_timer);
    memset(&bta_dm_search_cb, 0, sizeof(bta_dm_search_cb));

    /* notify BTA DM is now unactive */
    bta_dm_cb.is_bta_dm_active = false;
  } else if (status == BTA_SYS_HW_ON_EVT) {
  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 */
+0 −1
Original line number Diff line number Diff line
@@ -180,7 +180,6 @@ enum {

/* SYS HW status events - returned by SYS HW manager to other modules. */
enum {
  BTA_SYS_HW_OFF_EVT,
  BTA_SYS_HW_ON_EVT,
  BTA_SYS_HW_STARTING_EVT,
  BTA_SYS_HW_STOPPING_EVT,
+4 −3
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@

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

/* system manager control block definition */
tBTA_SYS_CB bta_sys_cb;
@@ -104,7 +105,7 @@ static void bta_sys_sm_execute(tBTA_SYS_HW_EVT event) {
          bta_sys_set_state(BTA_SYS_HW_ON);
          break;
        case BTA_SYS_API_DISABLE_EVT:
          BTA_dm_sys_hw_cback(BTA_SYS_HW_OFF_EVT);
          BTA_dm_on_hw_off();
          break;
        default:
          break;
@@ -121,7 +122,7 @@ static void bta_sys_sm_execute(tBTA_SYS_HW_EVT event) {
          break;
        case BTA_SYS_EVT_DISABLED_EVT:
          bta_sys_set_state(BTA_SYS_HW_STARTING);
          BTA_dm_sys_hw_cback(BTA_SYS_HW_OFF_EVT);
          BTA_dm_on_hw_off();
          bta_sys_hw_api_enable();
          break;
        case BTA_SYS_ERROR_EVT:
@@ -159,7 +160,7 @@ static void bta_sys_sm_execute(tBTA_SYS_HW_EVT event) {
          break;
        case BTA_SYS_EVT_DISABLED_EVT:
          bta_sys_set_state(BTA_SYS_HW_OFF);
          BTA_dm_sys_hw_cback(BTA_SYS_HW_OFF_EVT);
          BTA_dm_on_hw_off();
          break;
        case BTA_SYS_ERROR_EVT:
          bta_sys_hw_api_disable();