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

Commit 53fb7bed authored by Zach Johnson's avatar Zach Johnson
Browse files

Factor BTA_SYS_PLCY_SET into its own function

no need pass a bunch of extra stuff that's not used

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: Iec1e469b82c6c767ec9dd07fb47e4e465b70619a
parent e0e49f33
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -827,6 +827,15 @@ void bta_dm_pin_reply(std::unique_ptr<tBTA_DM_API_PIN_REPLY> msg) {
  }
}

void BTA_dm_set_policy(uint8_t policy, const RawAddress& peer_addr) {
  auto p_dev = bta_dm_find_peer_device(peer_addr);
  if (!p_dev) {
    return;
  }
  p_dev->link_policy |= policy;
  BTM_SetLinkPolicy(p_dev->peer_bdaddr, &(p_dev->link_policy));
}

/*******************************************************************************
 *
 * Function         bta_dm_policy_cback
@@ -848,13 +857,6 @@ void BTA_dm_update_policy(tBTA_SYS_CONN_STATUS status, uint8_t id,

  APPL_TRACE_DEBUG(" cmd:%d, policy:0x%x", status, policy);
  switch (status) {
    case BTA_SYS_PLCY_SET:
      if (!p_dev) return;
      /* restore the default link policy */
      p_dev->link_policy |= policy;
      BTM_SetLinkPolicy(p_dev->peer_bdaddr, &(p_dev->link_policy));
      break;

    case BTA_SYS_PLCY_CLR:
      if (!p_dev) return;
      /* clear the policy from the default link policy */
+0 −1
Original line number Diff line number Diff line
@@ -111,7 +111,6 @@ typedef uint8_t tBTA_SYS_ID;
#define BTA_SYS_CONN_BUSY 0x07

/* for link policy */
#define BTA_SYS_PLCY_SET 0x10     /* set the link policy to the given addr */
#define BTA_SYS_PLCY_CLR 0x11     /* clear the link policy to the given addr */
#define BTA_SYS_PLCY_DEF_SET 0x12 /* set the default link policy */
#define BTA_SYS_PLCY_DEF_CLR 0x13 /* clear the default link policy */
+2 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@

void BTA_dm_update_policy(tBTA_SYS_CONN_STATUS status, uint8_t id,
                          uint8_t app_id, const RawAddress& peer_addr);
void BTA_dm_set_policy(uint8_t policy, const RawAddress& peer_addr);

/*******************************************************************************
 *
@@ -359,7 +360,7 @@ void bta_sys_set_policy(uint8_t id, uint8_t policy,
                        const RawAddress& peer_addr) {
  APPL_TRACE_DEBUG("%s: peer %s id:%d policy:0x%x", __func__,
                   peer_addr.ToString().c_str(), id, policy);
  BTA_dm_update_policy(BTA_SYS_PLCY_SET, id, policy, peer_addr);
  BTA_dm_set_policy(policy, peer_addr);
}

/*******************************************************************************