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

Commit 93697c1a authored by Zach Johnson's avatar Zach Johnson
Browse files

Remove notion of app_id from role switch blocking

It's only called for one app_id

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: Ic6cddf83d590165be7f0109a6270f3cd0abc0cc1
parent c215f6c6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -849,7 +849,7 @@ void bta_av_do_disc_a2dp(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {

    if (bta_av_cb.audio_open_cnt == 1) {
      /* there's already an A2DP connection. do not allow switch */
      BTA_dm_block_role_switch(BTA_ID_AV);
      BTA_dm_block_role_switch();
    }
  }
  /* store peer addr other parameters */
+1 −1
Original line number Diff line number Diff line
@@ -1270,7 +1270,7 @@ void bta_av_conn_chg(tBTA_AV_DATA* p_data) {
    if (p_cb->audio_open_cnt == 1) {
      /* one audio channel goes down and there's one audio channel remains open.
       * restore the switch role in default link policy */
      BTA_dm_unblock_role_switch(BTA_ID_AV);
      BTA_dm_unblock_role_switch();
      bta_av_restore_switch();
    }
    if (p_cb->audio_open_cnt) {
+4 −11
Original line number Diff line number Diff line
@@ -851,19 +851,12 @@ void BTA_dm_clear_policy(uint8_t policy, const RawAddress& peer_addr) {
  }
}

void BTA_dm_unblock_role_switch(uint8_t app_id) {
  uint32_t mask = (uint32_t)(1 << app_id);
  bta_dm_cb.role_policy_mask &= ~mask;
  if (0 == bta_dm_cb.role_policy_mask) {
    /* if nobody wants to insist on the role */
void BTA_dm_unblock_role_switch() {
  bta_dm_cb.cur_policy |= HCI_ENABLE_MASTER_SLAVE_SWITCH;
  BTM_SetDefaultLinkPolicy(bta_dm_cb.cur_policy);
}
}

void BTA_dm_block_role_switch(uint8_t app_id) {
  uint32_t mask = (uint32_t)(1 << app_id);
  bta_dm_cb.role_policy_mask |= mask;
void BTA_dm_block_role_switch() {
  bta_dm_cb.cur_policy &= ~HCI_ENABLE_MASTER_SLAVE_SWITCH;
  BTM_SetDefaultLinkPolicy(bta_dm_cb.cur_policy);
}
+0 −3
Original line number Diff line number Diff line
@@ -296,9 +296,6 @@ typedef struct {
  uint8_t num_master_only;
  uint8_t pm_id;
  tBTA_PM_TIMER pm_timer[BTA_DM_NUM_PM_TIMER];
  uint32_t
      role_policy_mask;   /* the bits set indicates the modules that wants to
                             remove role switch from the default link policy */
  uint16_t cur_policy;    /* current default link policy */
  uint16_t rs_event;      /* the event waiting for role switch */
  uint8_t cur_av_count;   /* current AV connecions */
+2 −2
Original line number Diff line number Diff line
@@ -246,7 +246,7 @@ extern void bta_sys_set_policy(uint8_t id, uint8_t policy,
extern void bta_sys_clear_policy(uint8_t id, uint8_t policy,
                                 const RawAddress& peer_addr);

void BTA_dm_unblock_role_switch(uint8_t app_id);
void BTA_dm_block_role_switch(uint8_t app_id);
void BTA_dm_unblock_role_switch();
void BTA_dm_block_role_switch();

#endif /* BTA_SYS_H */