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

Commit d5a9835a authored by Chris Manton's avatar Chris Manton
Browse files

Bypass bta_sys bta/hh/bta_hh::enable

Bug: 188297078
Test: gd/cert/run
Tag: #refactor

Change-Id: I2410aa0810553ac5536bab97186cd7852c351c3f
parent 3033b04f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ static const char* bta_hh_hid_event_name(uint16_t event);
 * Returns          void
 *
 ******************************************************************************/
void bta_hh_api_enable(tBTA_HH_DATA* p_data) {
void bta_hh_api_enable(const tBTA_HH_DATA* p_data) {
  tBTA_HH_STATUS status = BTA_HH_ERR;
  uint8_t xx;

+15 −11
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#include "bta/sys/bta_sys.h"
#include "osi/include/allocator.h"
#include "osi/include/osi.h"  // UNUSED_ATTR
#include "stack/include/btu.h"
#include "types/raw_address.h"

/*****************************************************************************
@@ -56,16 +57,22 @@ static const tBTA_SYS_REG bta_hh_reg = {bta_hh_hdl_event, BTA_HhDisable};
 *
 ******************************************************************************/
void BTA_HhEnable(tBTA_HH_CBACK* p_cback) {
  tBTA_HH_API_ENABLE* p_buf =
      (tBTA_HH_API_ENABLE*)osi_calloc(sizeof(tBTA_HH_API_ENABLE));

  /* register with BTA system manager */
  bta_sys_register(BTA_ID_HH, &bta_hh_reg);

  p_buf->hdr.event = BTA_HH_API_ENABLE_EVT;
  p_buf->p_cback = p_cback;

  bta_sys_sendmsg(p_buf);
  post_on_bt_main([p_cback]() {
    tBTA_HH_DATA data = {
        .api_enable =
            {
                .hdr =
                    {
                        .event = BTA_HH_API_ENABLE_EVT,
                    },
                .p_cback = p_cback,
            },
    };
    bta_hh_api_enable(&data);
  });
}

/*******************************************************************************
@@ -79,12 +86,9 @@ void BTA_HhEnable(tBTA_HH_CBACK* p_cback) {
 *
 ******************************************************************************/
void BTA_HhDisable(void) {
  BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR));

  bta_sys_deregister(BTA_ID_HH);
  p_buf->event = BTA_HH_API_DISABLE_EVT;

  bta_sys_sendmsg(p_buf);
  post_on_bt_main([]() { bta_hh_api_disable(); });
}

/*******************************************************************************
+1 −1
Original line number Diff line number Diff line
@@ -297,7 +297,7 @@ extern void bta_hh_cleanup_disable(tBTA_HH_STATUS status);
extern uint8_t bta_hh_dev_handle_to_cb_idx(uint8_t dev_handle);

/* action functions used outside state machine */
extern void bta_hh_api_enable(tBTA_HH_DATA* p_data);
extern void bta_hh_api_enable(const tBTA_HH_DATA* p_data);
extern void bta_hh_api_disable(void);
extern void bta_hh_disc_cmpl(void);