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

Commit 2c5ce1d4 authored by Chris Manton's avatar Chris Manton
Browse files

Formalize acl API BTM_ReadPowerMode

Creating ACL API

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I0794b585c1b5c206c7b44616518eb9359bfa12cb
parent de9fc4e5
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -1880,8 +1880,7 @@ tBTM_STATUS BTM_SetPowerMode(uint8_t pm_id, const RawAddress& remote_bda,
 *                  BTM_UNKNOWN_ADDR if bd addr is not active or bad
 *
 ******************************************************************************/
tBTM_STATUS BTM_ReadPowerMode(const RawAddress& remote_bda,
                              tBTM_PM_MODE* p_mode);
bool BTM_ReadPowerMode(const RawAddress& remote_bda, tBTM_PM_MODE* p_mode);

/*******************************************************************************
 *
+2 −2
Original line number Diff line number Diff line
@@ -177,9 +177,9 @@ typedef struct {
  uint8_t acl_disc_reason;

 private:
  friend tBTM_PM_MCB* acl_power_mode_from_handle(uint16_t hci_handle);
  friend tBTM_STATUS BTM_ReadPowerMode(const RawAddress& remote_bda,
  friend bool BTM_ReadPowerMode(const RawAddress& remote_bda,
                                tBTM_PM_MODE* p_mode);
  friend tBTM_PM_MCB* acl_power_mode_from_handle(uint16_t hci_handle);
  friend tBTM_STATUS BTM_SetPowerMode(uint8_t pm_id,
                                      const RawAddress& remote_bda,
                                      const tBTM_PM_PWR_MD* p_mode);
+3 −2
Original line number Diff line number Diff line
@@ -588,8 +588,9 @@ tBTM_STATUS BTM_SwitchRole(const RawAddress& remote_bd_addr, uint8_t new_role) {
    return BTM_DEV_BLACKLISTED;
  }

  status = BTM_ReadPowerMode(p->remote_addr, &pwr_mode);
  if (status != BTM_SUCCESS) return (status);
  if (!BTM_ReadPowerMode(p->remote_addr, &pwr_mode)) {
    return BTM_UNKNOWN_ADDR;
  };

  /* Wake up the link if in sniff or park before attempting switch */
  if (pwr_mode == BTM_PM_MD_PARK || pwr_mode == BTM_PM_MD_SNIFF) {
+10 −9
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@
#include "device/include/controller.h"
#include "hcidefs.h"
#include "hcimsgs.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"
#include "stack/include/acl_api.h"
#include "stack/include/l2cap_hci_link_interface.h"
@@ -250,19 +251,19 @@ tBTM_STATUS BTM_SetPowerMode(uint8_t pm_id, const RawAddress& remote_bda,
 *                          BTM_ACL_MODE_PARK
 *                          (valid only if return code is BTM_SUCCESS)
 *
 * Returns          BTM_SUCCESS if successful,
 *                  BTM_UNKNOWN_ADDR if bd addr is not active or bad
 * Returns          true if successful, false otherwise
 *
 ******************************************************************************/
tBTM_STATUS BTM_ReadPowerMode(const RawAddress& remote_bda,
                              tBTM_PM_MODE* p_mode) {
  int acl_ind;

  acl_ind = btm_pm_find_acl_ind(remote_bda);
  if (acl_ind == MAX_L2CAP_LINKS) return (BTM_UNKNOWN_ADDR);
bool BTM_ReadPowerMode(const RawAddress& remote_bda, tBTM_PM_MODE* p_mode) {
  if (p_mode == nullptr) {
    LOG_ERROR("%s power mode is nullptr", __func__);
    return false;
  }
  int acl_ind = btm_pm_find_acl_ind(remote_bda);
  if (acl_ind == MAX_L2CAP_LINKS) return false;

  *p_mode = btm_cb.acl_cb_.pm_mode_db[acl_ind].state;
  return BTM_SUCCESS;
  return true;
}

/*******************************************************************************
+21 −0
Original line number Diff line number Diff line
@@ -321,3 +321,24 @@ tBTM_STATUS btm_read_power_mode_state(const RawAddress& remote_bda,
void btm_acl_notif_conn_collision(const RawAddress& bda);

void btm_acl_update_conn_addr(uint16_t conn_handle, const RawAddress& address);

/*******************************************************************************
 *
 * Function         BTM_ReadPowerMode
 *
 * Description      This returns the current mode for a specific
 *                  ACL connection.
 *
 * Input Param      remote_bda - device address of desired ACL connection
 *
 * Output Param     p_mode - address where the current mode is copied into.
 *                          BTM_ACL_MODE_NORMAL
 *                          BTM_ACL_MODE_HOLD
 *                          BTM_ACL_MODE_SNIFF
 *                          BTM_ACL_MODE_PARK
 *                          (valid only if return code is BTM_SUCCESS)
 *
 * Returns          true if successful, false otherwise.
 *
 ******************************************************************************/
bool BTM_ReadPowerMode(const RawAddress& remote_bda, tBTM_PM_MODE* p_mode);
Loading