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

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

IA2: Properly type a2dp ACL role switch callback

Bug: 298708986
Test: m .

Change-Id: Iee38a7f0c4abf159473ee37910691e4dca041abd
parent 99f3237e
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -27,14 +27,15 @@
#include <cstdint>
#include <string>

#include "bta/av/bta_av_int.h"
#include "bta/include/bta_av_api.h"
#include "bta/include/bta_av_co.h"
#include "bta/sys/bta_sys.h"
#include "include/hardware/bt_av.h"
#include "osi/include/list.h"
#include "stack/include/a2dp_error_codes.h"
#include "stack/include/avdt_api.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_types.h"
#include "stack/include/hci_error_code.h"
#include "types/hci_role.h"
#include "types/raw_address.h"

#define CASE_RETURN_TEXT(code) \
@@ -400,8 +401,8 @@ typedef struct {
/* data type for BTA_AV_ROLE_CHANGE_EVT */
typedef struct {
  BT_HDR_RIGID hdr;
  uint8_t new_role;
  uint8_t hci_status;
  tHCI_ROLE new_role;
  tHCI_STATUS hci_status;
} tBTA_AV_ROLE_RES;

/* data type for BTA_AV_SDP_DISC_OK_EVT */
+16 −13
Original line number Diff line number Diff line
@@ -31,19 +31,19 @@
#include "bt_target.h"  // Must be first to define build configuration
#include "bta/av/bta_av_int.h"
#include "bta/include/bta_ar_api.h"
#include "bta/include/bta_av_co.h"
#include "bta/include/utl.h"
#include "btif/avrcp/avrcp_service.h"
#include "btif/include/btif_av.h"
#include "btif/include/btif_av_co.h"
#include "btif/include/btif_config.h"
#include "main/shim/dumpsys.h"
#include "gd/os/log.h"
#include "osi/include/allocator.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"  // UNUSED_ATTR
#include "osi/include/properties.h"
#include "stack/include/acl_api.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/btm_api.h"
#include "stack/include/hci_error_code.h"
#include "stack/include/sdp_api.h"
#include "types/hci_role.h"
#include "types/raw_address.h"
@@ -107,8 +107,9 @@ static void bta_av_api_to_ssm(tBTA_AV_DATA* p_data);

static void bta_av_sco_chg_cback(tBTA_SYS_CONN_STATUS status, uint8_t id,
                                 uint8_t app_id, const RawAddress& peer_addr);
static void bta_av_sys_rs_cback(tBTA_SYS_CONN_STATUS status, uint8_t id,
                                uint8_t app_id, const RawAddress& peer_addr);
static void bta_av_sys_rs_cback(tBTA_SYS_CONN_STATUS status, tHCI_ROLE new_role,
                                tHCI_STATUS hci_status,
                                const RawAddress& peer_addr);

/*****************************************************************************
 * Global data
@@ -925,7 +926,7 @@ void bta_av_restore_switch(void) {
 *
 ******************************************************************************/
static void bta_av_sys_rs_cback(UNUSED_ATTR tBTA_SYS_CONN_STATUS status,
                                uint8_t id, uint8_t app_id,
                                tHCI_ROLE new_role, tHCI_STATUS hci_status,
                                const RawAddress& peer_addr) {
  int i;
  tBTA_AV_SCB* p_scb = NULL;
@@ -934,7 +935,8 @@ static void bta_av_sys_rs_cback(UNUSED_ATTR tBTA_SYS_CONN_STATUS status,

  APPL_TRACE_DEBUG(
      "%s: peer %s new_role:%d hci_status:0x%x bta_av_cb.rs_idx:%d", __func__,
      ADDRESS_TO_LOGGABLE_CSTR(peer_addr), id, app_id, bta_av_cb.rs_idx);
      ADDRESS_TO_LOGGABLE_CSTR(peer_addr), new_role, hci_status,
      bta_av_cb.rs_idx);

  for (i = 0; i < BTA_AV_NUM_STRS; i++) {
    /* loop through all the SCBs to find matching peer addresses and report the
@@ -946,12 +948,12 @@ static void bta_av_sys_rs_cback(UNUSED_ATTR tBTA_SYS_CONN_STATUS status,
          (tBTA_AV_ROLE_RES*)osi_malloc(sizeof(tBTA_AV_ROLE_RES));
      APPL_TRACE_DEBUG(
          "%s: peer %s found: new_role:%d, hci_status:0x%x bta_handle:0x%x",
          __func__, ADDRESS_TO_LOGGABLE_CSTR(peer_addr), id, app_id,
          __func__, ADDRESS_TO_LOGGABLE_CSTR(peer_addr), new_role, hci_status,
          p_scb->hndl);
      p_buf->hdr.event = BTA_AV_ROLE_CHANGE_EVT;
      p_buf->hdr.layer_specific = p_scb->hndl;
      p_buf->new_role = id;
      p_buf->hci_status = app_id;
      p_buf->new_role = new_role;
      p_buf->hci_status = hci_status;
      bta_sys_sendmsg(p_buf);

      peer_idx = p_scb->hdi + 1; /* Handle index for the peer_addr */
@@ -959,7 +961,7 @@ static void bta_av_sys_rs_cback(UNUSED_ATTR tBTA_SYS_CONN_STATUS status,
  }

  /* restore role switch policy, if role switch failed */
  if ((HCI_SUCCESS != app_id) &&
  if ((HCI_SUCCESS != hci_status) &&
      (BTM_GetRole(peer_addr, &cur_role) == BTM_SUCCESS) &&
      (cur_role == HCI_ROLE_PERIPHERAL)) {
    BTM_unblock_role_switch_for(peer_addr);
@@ -977,14 +979,15 @@ static void bta_av_sys_rs_cback(UNUSED_ATTR tBTA_SYS_CONN_STATUS status,
                       __func__, ADDRESS_TO_LOGGABLE_CSTR(p_scb->PeerAddress()),
                       bta_av_cb.rs_idx, p_scb->hndl, p_scb->q_tag);

      if (HCI_SUCCESS == app_id || HCI_ERR_NO_CONNECTION == app_id) {
      if (HCI_SUCCESS == hci_status || HCI_ERR_NO_CONNECTION == hci_status) {
        p_scb->q_info.open.switch_res = BTA_AV_RS_OK;
      } else {
        APPL_TRACE_ERROR(
            "%s: peer %s (p_scb peer %s) role switch failed: new_role:%d "
            "hci_status:0x%x",
            __func__, ADDRESS_TO_LOGGABLE_CSTR(peer_addr),
            ADDRESS_TO_LOGGABLE_CSTR(p_scb->PeerAddress()), id, app_id);
            ADDRESS_TO_LOGGABLE_CSTR(p_scb->PeerAddress()), new_role,
            hci_status);
        p_scb->q_info.open.switch_res = BTA_AV_RS_FAIL;
      }

+8 −4
Original line number Diff line number Diff line
@@ -162,12 +162,16 @@ inline std::string bta_sys_conn_status_text(tBTA_SYS_CONN_STATUS status) {
  }
}

/* conn callback for role / low power manager*/
/* conn callback for power mode manager */
typedef void(tBTA_SYS_CONN_CBACK)(tBTA_SYS_CONN_STATUS status,
                                  const tBTA_SYS_ID id, uint8_t app_id,
                                  const RawAddress& peer_addr);

/* conn callback for role / low power manager*/
/* callback for role switch */
typedef void(tBTA_SYS_ROLE_SWITCH_CBACK)(tBTA_SYS_CONN_STATUS status,
                                         tHCI_ROLE new_role,
                                         tHCI_STATUS hci_status,
                                         const RawAddress& peer_addr);
/* callback for sniff subrating updates */
typedef void(tBTA_SYS_SSR_CFG_CBACK)(uint8_t id, uint8_t app_id,
                                     uint16_t latency, uint16_t tout);

@@ -238,7 +242,7 @@ void bta_sys_ssr_cfg_register(tBTA_SYS_SSR_CFG_CBACK* p_cback);
void bta_sys_chg_ssr_config(uint8_t id, uint8_t app_id, uint16_t max_latency,
                            uint16_t min_tout);

void bta_sys_role_chg_register(tBTA_SYS_CONN_CBACK* p_cback);
void bta_sys_role_chg_register(tBTA_SYS_ROLE_SWITCH_CBACK* p_cback);
void bta_sys_notify_role_chg(const RawAddress& peer_addr, tHCI_ROLE new_role,
                             tHCI_STATUS hci_status);
void bta_sys_collision_register(uint8_t bta_id, tBTA_SYS_CONN_CBACK* p_cback);
+1 −1
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ void bta_sys_rm_register(tBTA_SYS_CONN_CBACK* p_cback) {
 * Returns          void
 *
 ******************************************************************************/
void bta_sys_role_chg_register(tBTA_SYS_CONN_CBACK* p_cback) {
void bta_sys_role_chg_register(tBTA_SYS_ROLE_SWITCH_CBACK* p_cback) {
  bta_sys_cb.p_role_cb = p_cback;
}
/*******************************************************************************
+2 −1
Original line number Diff line number Diff line
@@ -55,7 +55,8 @@ typedef struct {
      ppm_cb; /* low power management callback registered by DM */
  tBTA_SYS_CONN_CBACK*
      p_sco_cb; /* SCO connection change callback registered by AV */
  tBTA_SYS_CONN_CBACK* p_role_cb; /* role change callback registered by AV */
  tBTA_SYS_ROLE_SWITCH_CBACK*
      p_role_cb;                  /* role change callback registered by AV */
  tBTA_SYS_COLLISION colli_reg;   /* collision handling module */
#if (BTA_EIR_CANNED_UUID_LIST != TRUE)
  tBTA_SYS_EIR_CBACK* eir_cb; /* add/remove UUID into EIR */