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

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

Flatten BTA_DM_DISABLE_EVT

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: Idd6991175ec75e002ff9aff591aebda903b35679
parent 1f590496
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@
using bluetooth::Uuid;

void BTIF_dm_enable();
void BTIF_dm_disable();

static void bta_dm_inq_results_cb(tBTM_INQ_RESULTS* p_inq, uint8_t* p_eir,
                                  uint16_t eir_len);
@@ -310,8 +311,7 @@ void bta_dm_deinit_cb(void) {
}

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);
  BTIF_dm_disable();

  /* reinitialize the control block */
  bta_dm_deinit_cb();
@@ -481,7 +481,7 @@ static void bta_dm_disable_timer_cback(void* data) {
    bta_dm_cb.disabling = false;

    bta_sys_remove_uuid(UUID_SERVCLASS_PNP_INFORMATION);
    bta_dm_cb.p_sec_cback(BTA_DM_DISABLE_EVT, NULL);
    BTIF_dm_disable();
  }
}

+0 −1
Original line number Diff line number Diff line
@@ -340,7 +340,6 @@ typedef uint8_t tBTA_DM_LINK_QUALITY_VALUE;
typedef uint8_t tBTA_SIG_STRENGTH_MASK;

/* Security Callback Events */
#define BTA_DM_DISABLE_EVT 1   /* Disable Event */
#define BTA_DM_PIN_REQ_EVT 2   /* PIN request. */
#define BTA_DM_AUTH_CMPL_EVT 3 /* Authentication complete indication. */
#define BTA_DM_AUTHORIZE_EVT 4 /* Authorization request. */
+13 −16
Original line number Diff line number Diff line
@@ -1547,6 +1547,19 @@ void BTIF_dm_enable() {
  btif_enable_bluetooth_evt();
}

void BTIF_dm_disable() {
  /* for each of the enabled services in the mask, trigger the profile
   * disable */
  tBTA_SERVICE_MASK service_mask = btif_get_enabled_services_mask();
  for (uint32_t i = 0; i <= BTA_MAX_SERVICE_ID; i++) {
    if (service_mask & (tBTA_SERVICE_MASK)(BTA_SERVICE_ID_TO_SERVICE_MASK(i))) {
      btif_in_execute_service_request(i, false);
    }
  }
  bluetooth::bqr::EnableBtQualityReport(false);
  future_ready(stack_manager_get_hack_future(), FUTURE_SUCCESS);
}

/*******************************************************************************
 *
 * Function         btif_dm_upstreams_cback
@@ -1558,27 +1571,11 @@ void BTIF_dm_enable() {
 ******************************************************************************/
static void btif_dm_upstreams_evt(uint16_t event, char* p_param) {
  tBTA_DM_SEC* p_data = (tBTA_DM_SEC*)p_param;
  tBTA_SERVICE_MASK service_mask;
  uint32_t i;
  RawAddress bd_addr;

  BTIF_TRACE_EVENT("%s: ev: %s", __func__, dump_dm_event(event));

  switch (event) {
    case BTA_DM_DISABLE_EVT:
      /* for each of the enabled services in the mask, trigger the profile
       * disable */
      service_mask = btif_get_enabled_services_mask();
      for (i = 0; i <= BTA_MAX_SERVICE_ID; i++) {
        if (service_mask &
            (tBTA_SERVICE_MASK)(BTA_SERVICE_ID_TO_SERVICE_MASK(i))) {
          btif_in_execute_service_request(i, false);
        }
      }
      bluetooth::bqr::EnableBtQualityReport(false);
      future_ready(stack_manager_get_hack_future(), FUTURE_SUCCESS);
      break;

    case BTA_DM_PIN_REQ_EVT:
      btif_dm_pin_req_evt(&p_data->pin_req);
      break;
+0 −1
Original line number Diff line number Diff line
@@ -144,7 +144,6 @@ const char* dump_property_type(bt_property_type_t type) {

const char* dump_dm_event(uint16_t event) {
  switch (event) {
    CASE_RETURN_STR(BTA_DM_DISABLE_EVT)
    CASE_RETURN_STR(BTA_DM_PIN_REQ_EVT)
    CASE_RETURN_STR(BTA_DM_AUTH_CMPL_EVT)
    CASE_RETURN_STR(BTA_DM_LINK_UP_EVT)