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

Commit 7bb156c0 authored by Chris Manton's avatar Chris Manton
Browse files

Use stack/acl/btm_acl::BTM_SetLinkPolicyActiveMode

Bug: 175344733
Test: cert
Tag: #refactor

Change-Id: Id326a5ebc521b536f54202c32ec70bed29612592
parent f19a3d70
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -566,13 +566,8 @@ tBTM_STATUS BTM_SwitchRoleToCentral(const RawAddress& remote_bd_addr) {
  };

  if (pwr_mode == BTM_PM_MD_PARK || pwr_mode == BTM_PM_MD_SNIFF) {
    tBTM_PM_PWR_MD settings;
    memset((void*)&settings, 0, sizeof(settings));
    settings.mode = BTM_PM_MD_ACTIVE;
    tBTM_STATUS status =
        BTM_SetPowerMode(BTM_PM_SET_ONLY_ID, p_acl->remote_addr, &settings);
    if (status != BTM_CMD_STARTED) {
      LOG_WARN("Unable to set power mode before attempting switch");
    if (!BTM_SetLinkPolicyActiveMode(p_acl->remote_addr)) {
      LOG_WARN("Unable to set link policy active before attempting switch");
      return BTM_WRONG_MODE;
    }
    p_acl->set_switch_role_changing();
+4 −3
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@

#include "device/include/controller.h"
#include "device/include/esco_parameters.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"
#include "stack/btm/btm_sec.h"
#include "stack/btm/security_device_record.h"
@@ -382,9 +383,9 @@ tBTM_STATUS BTM_CreateSco(const RawAddress* remote_bda, bool is_orig,
              LOG(INFO) << __func__ << ": " << *remote_bda
                        << " in sniff, park or pending mode "
                        << unsigned(state);
              tBTM_PM_PWR_MD pm = {};
              pm.mode = BTM_PM_MD_ACTIVE;
              BTM_SetPowerMode(BTM_PM_SET_ONLY_ID, *remote_bda, &pm);
              if (!BTM_SetLinkPolicyActiveMode(*remote_bda)) {
                LOG_WARN("Unable to set link policy active");
              }
              p->state = SCO_ST_PEND_UNPARK;
            }
          } else {
+9 −30
Original line number Diff line number Diff line
@@ -248,14 +248,9 @@ static void l2c_csm_closed(tL2C_CCB* p_ccb, uint16_t event, void* p_data) {
        l2ble_sec_access_req(p_ccb->p_lcb->remote_bd_addr, p_ccb->p_rcb->psm,
                             true, &l2c_link_sec_comp2, p_ccb);
      } else {
        /* Cancel sniff mode if needed */
        tBTM_PM_PWR_MD settings;
        memset((void*)&settings, 0, sizeof(settings));
        settings.mode = BTM_PM_MD_ACTIVE;

        BTM_SetPowerMode(BTM_PM_SET_ONLY_ID, p_ccb->p_lcb->remote_bd_addr,
                         &settings);

        if (!BTM_SetLinkPolicyActiveMode(p_ccb->p_lcb->remote_bd_addr)) {
          LOG_WARN("Unable to set link policy active");
        }
        /* If sec access does not result in started SEC_COM or COMP_NEG are
         * already processed */
        if (btm_sec_l2cap_access_req(
@@ -321,16 +316,9 @@ static void l2c_csm_closed(tL2C_CCB* p_ccb, uint16_t event, void* p_data) {
            break;
        }
      } else {
        /* Cancel sniff mode if needed */
        {
          tBTM_PM_PWR_MD settings;
          memset((void*)&settings, 0, sizeof(settings));
          settings.mode = BTM_PM_MD_ACTIVE;

          BTM_SetPowerMode(BTM_PM_SET_ONLY_ID, p_ccb->p_lcb->remote_bd_addr,
                           &settings);
        if (!BTM_SetLinkPolicyActiveMode(p_ccb->p_lcb->remote_bd_addr)) {
          LOG_WARN("Unable to set link policy active");
        }

        p_ccb->chnl_state = CST_TERM_W4_SEC_COMP;
        auto status = btm_sec_l2cap_access_req(p_ccb->p_lcb->remote_bd_addr,
                                               p_ccb->p_rcb->psm, false,
@@ -1248,13 +1236,8 @@ static void l2c_csm_open(tL2C_CCB* p_ccb, uint16_t event, void* p_data) {

    case L2CEVT_L2CAP_DISCONNECT_REQ: /* Peer disconnected request */
      if (p_ccb->p_lcb->transport != BT_TRANSPORT_LE) {
        /* Make sure we are not in sniff mode */
        {
          tBTM_PM_PWR_MD settings;
          memset((void*)&settings, 0, sizeof(settings));
          settings.mode = BTM_PM_MD_ACTIVE;
          BTM_SetPowerMode(BTM_PM_SET_ONLY_ID, p_ccb->p_lcb->remote_bd_addr,
                           &settings);
        if (!BTM_SetLinkPolicyActiveMode(p_ccb->p_lcb->remote_bd_addr)) {
          LOG_WARN("Unable to set link policy active");
        }
      }

@@ -1276,12 +1259,8 @@ static void l2c_csm_open(tL2C_CCB* p_ccb, uint16_t event, void* p_data) {
    case L2CEVT_L2CA_DISCONNECT_REQ: /* Upper wants to disconnect */
      if (p_ccb->p_lcb->transport != BT_TRANSPORT_LE) {
        /* Make sure we are not in sniff mode */
        {
          tBTM_PM_PWR_MD settings;
          memset((void*)&settings, 0, sizeof(settings));
          settings.mode = BTM_PM_MD_ACTIVE;
          BTM_SetPowerMode(BTM_PM_SET_ONLY_ID, p_ccb->p_lcb->remote_bd_addr,
                           &settings);
        if (!BTM_SetLinkPolicyActiveMode(p_ccb->p_lcb->remote_bd_addr)) {
          LOG_WARN("Unable to set link policy active");
        }
      }