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

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

Privatize tBTM_CB::tACL_CB:tACL_CONN[]

Creating ACL API

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working

Change-Id: I1e65fe788158bd6c7a02806385c1fe69b46c7394
parent 65057a0c
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
@@ -100,7 +100,48 @@ typedef struct {
  /****************************************************
   **      ACL Management
   ****************************************************/
 private:
  friend bool BTM_IsBleConnection(uint16_t hci_handle);
  friend bool BTM_IsBleConnection(uint16_t hci_handle);
  friend const RawAddress acl_address_from_handle(uint16_t hci_handle);
  friend int btm_pm_find_acl_ind(const RawAddress& remote_bda);
  friend tACL_CONN* btm_bda_to_acl(const RawAddress& bda,
                                   tBT_TRANSPORT transport);
  friend tBTM_STATUS BTM_SetSsrParams(const RawAddress& remote_bda,
                                      uint16_t max_lat, uint16_t min_rmt_to,
                                      uint16_t min_loc_to);
  friend uint16_t BTM_GetNumAclLinks(void);
  friend uint8_t btm_handle_to_acl_index(uint16_t hci_handle);
  friend void btm_acl_created(const RawAddress& bda, DEV_CLASS dc, BD_NAME bdn,
                              uint16_t hci_handle, uint8_t link_role,
                              tBT_TRANSPORT transport);
  friend void btm_acl_device_down(void);
  friend void btm_acl_encrypt_change(uint16_t handle, uint8_t status,
                                     uint8_t encr_enable);
  friend void btm_acl_update_conn_addr(uint16_t conn_handle,
                                       const RawAddress& address);
  friend void btm_pm_proc_cmd_status(uint8_t status);
  friend void btm_pm_reset(void);
  friend void btm_process_clk_off_comp_evt(uint16_t hci_handle,
                                           uint16_t clock_offset);
  friend void btm_read_automatic_flush_timeout_complete(uint8_t* p);
  friend void btm_read_failed_contact_counter_complete(uint8_t* p);
  friend void btm_read_link_quality_complete(uint8_t* p);
  friend void btm_read_remote_ext_features_complete(uint8_t* p,
                                                    uint8_t evt_len);
  friend void btm_read_remote_ext_features_failed(uint8_t status,
                                                  uint16_t handle);
  friend void btm_read_remote_features_complete(uint8_t* p);
  friend void btm_read_remote_version_complete(uint8_t* p);
  friend void btm_read_rssi_complete(uint8_t* p);
  friend void btm_read_tx_power_complete(uint8_t* p, bool is_ble);

  friend struct StackAclBtmPm;
  friend struct StackAclBtmAcl;

  tACL_CONN acl_db[MAX_L2CAP_LINKS];

 public:
  uint8_t btm_scn[BTM_MAX_SCN_]; /* current SCNs: true if SCN is in use */
  uint16_t btm_def_link_policy;

+59 −52

File changed.

Preview size limit exceeded, changes collapsed.

+23 −17
Original line number Diff line number Diff line
@@ -45,6 +45,14 @@
#include "stack/include/acl_api.h"
#include "stack/include/l2cap_hci_link_interface.h"

struct StackAclBtmPm {
  tBTM_STATUS btm_pm_snd_md_req(uint8_t pm_id, int link_ind,
                                const tBTM_PM_PWR_MD* p_mode);
};
namespace {
StackAclBtmPm internal_;
}

/*****************************************************************************/
/*      to handle different modes                                            */
/*****************************************************************************/
@@ -65,9 +73,6 @@ const uint8_t

        BTM_PM_GET_MD1,  BTM_PM_GET_MD2,  BTM_PM_GET_COMP};

/* function prototype */
static tBTM_STATUS btm_pm_snd_md_req(uint8_t pm_id, int link_ind,
                                     const tBTM_PM_PWR_MD* p_mode);
static const char* mode_to_string(const tBTM_PM_MODE mode);

#if (BTM_PM_DEBUG == TRUE)
@@ -226,7 +231,7 @@ tBTM_STATUS BTM_SetPowerMode(uint8_t pm_id, const RawAddress& remote_bda,
    return BTM_CMD_STORED;
  }

  return btm_pm_snd_md_req(pm_id, acl_ind, p_mode);
  return internal_.btm_pm_snd_md_req(pm_id, acl_ind, p_mode);
}

/*******************************************************************************
@@ -358,10 +363,11 @@ void btm_pm_reset(void) {
    btm_cb.pm_reg_db[xx].mask = BTM_PM_REC_NOT_USED;
  }

  if (cb != NULL && btm_cb.acl_cb_.pm_pend_link < MAX_L2CAP_LINKS)
    (*cb)(btm_cb.acl_cb_.acl_db[btm_cb.acl_cb_.pm_pend_link].remote_addr,
          BTM_PM_STS_ERROR, BTM_DEV_RESET, 0);

  if (cb != NULL && btm_cb.acl_cb_.pm_pend_link < MAX_L2CAP_LINKS) {
    const RawAddress raw_address =
        btm_cb.acl_cb_.acl_db[btm_cb.acl_cb_.pm_pend_link].remote_addr;
    (*cb)(raw_address, BTM_PM_STS_ERROR, BTM_DEV_RESET, 0);
  }
  /* no command pending */
  btm_cb.acl_cb_.pm_pend_link = MAX_L2CAP_LINKS;
}
@@ -482,7 +488,7 @@ static tBTM_PM_MODE btm_pm_get_set_mode(uint8_t pm_id, tBTM_PM_MCB* p_cb,
  if (p_md == NULL) {
    if (p_mode)
      *p_res = *((tBTM_PM_PWR_MD*)p_mode);
    else /* p_mode is NULL when btm_pm_snd_md_req is called from
    else /* p_mode is NULL when internal_.btm_pm_snd_md_req is called from
            btm_pm_proc_mode_change */
      return BTM_PM_MD_ACTIVE;
  } else {
@@ -503,7 +509,7 @@ static tBTM_PM_MODE btm_pm_get_set_mode(uint8_t pm_id, tBTM_PM_MCB* p_cb,
 * Returns      tBTM_STATUS
 *, bool    *p_chg_ind
 ******************************************************************************/
static tBTM_STATUS btm_pm_snd_md_req(uint8_t pm_id, int link_ind,
tBTM_STATUS StackAclBtmPm::btm_pm_snd_md_req(uint8_t pm_id, int link_ind,
                                             const tBTM_PM_PWR_MD* p_mode) {
  tBTM_PM_PWR_MD md_res;
  tBTM_PM_MODE mode;
@@ -640,9 +646,9 @@ void btm_pm_proc_cmd_status(uint8_t status) {
  /* notify the caller is appropriate */
  if ((btm_cb.pm_pend_id != BTM_PM_SET_ONLY_ID) &&
      (btm_cb.pm_reg_db[btm_cb.pm_pend_id].mask & BTM_PM_REG_NOTIF)) {
    (*btm_cb.pm_reg_db[btm_cb.pm_pend_id].cback)(
        btm_cb.acl_cb_.acl_db[btm_cb.acl_cb_.pm_pend_link].remote_addr,
        pm_status, 0, status);
    const RawAddress bd_addr =
        btm_cb.acl_cb_.acl_db[btm_cb.acl_cb_.pm_pend_link].remote_addr;
    (*btm_cb.pm_reg_db[btm_cb.pm_pend_id].cback)(bd_addr, pm_status, 0, status);
  }

/* no pending cmd now */
@@ -669,7 +675,7 @@ void btm_pm_proc_cmd_status(uint8_t status) {
    if (btm_cb.acl_cb_.pm_mode_db[xx].state & BTM_PM_STORED_MASK) {
      btm_cb.acl_cb_.pm_mode_db[xx].state &= ~BTM_PM_STORED_MASK;
      BTM_TRACE_DEBUG("btm_pm_check_stored :%d", xx);
      btm_pm_snd_md_req(BTM_PM_SET_ONLY_ID, xx, NULL);
      internal_.btm_pm_snd_md_req(BTM_PM_SET_ONLY_ID, xx, NULL);
      break;
    }
  }
@@ -730,14 +736,14 @@ void btm_pm_proc_mode_change(uint8_t hci_status, uint16_t hci_handle,
#if (BTM_PM_DEBUG == TRUE)
    BTM_TRACE_DEBUG("btm_pm_proc_mode_change: Sending stored req:%d", xx);
#endif  // BTM_PM_DEBUG
    btm_pm_snd_md_req(BTM_PM_SET_ONLY_ID, xx, NULL);
    internal_.btm_pm_snd_md_req(BTM_PM_SET_ONLY_ID, xx, NULL);
  } else {
    for (zz = 0; zz < MAX_L2CAP_LINKS; zz++) {
      if (btm_cb.acl_cb_.pm_mode_db[zz].chg_ind) {
#if (BTM_PM_DEBUG == TRUE)
        BTM_TRACE_DEBUG("btm_pm_proc_mode_change: Sending PM req :%d", zz);
#endif  // BTM_PM_DEBUG
        btm_pm_snd_md_req(BTM_PM_SET_ONLY_ID, zz, NULL);
        internal_.btm_pm_snd_md_req(BTM_PM_SET_ONLY_ID, zz, NULL);
        break;
      }
    }