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

Commit 5ece122c authored by Jack He's avatar Jack He
Browse files

HFP: Add interface to disable in-band ringing through BSIR (1/2)

* Add send_bsir(bool, RawAddress*) to turn
  in-band ringtone feature ON and OFF dynamically during a service
  level connection with a headset

Bug: 70173881
Test: make
Change-Id: I358e39a9176d75dfb8682e77cf567f87eb417d1a
parent 3fc73871
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -1034,6 +1034,25 @@ static bt_status_t set_sco_allowed(bool value) {
  return BT_STATUS_SUCCESS;
}

static bt_status_t send_bsir(bool value, RawAddress* bd_addr) {
  CHECK_BTHF_INIT();
  int idx = btif_hf_idx_by_bdaddr(bd_addr);
  if ((idx < 0) || (idx >= BTIF_HF_NUM_CB)) {
    BTIF_TRACE_ERROR("%s: Invalid index %d for %s", __func__, idx,
                     bd_addr->ToString().c_str());
    return BT_STATUS_FAIL;
  }
  if (!is_connected(bd_addr)) {
    BTIF_TRACE_ERROR("%s: Device not connected %s", __func__,
                     bd_addr->ToString().c_str());
    return BT_STATUS_FAIL;
  }
  tBTA_AG_RES_DATA ag_result = {};
  ag_result.state = value;
  BTA_AgResult(btif_hf_cb[idx].handle, BTA_AG_INBAND_RING_RES, &ag_result);
  return BT_STATUS_SUCCESS;
}

/*******************************************************************************
 *
 * Function         formatted_at_response
@@ -1453,6 +1472,7 @@ static const bthf_interface_t bthfInterface = {
    phone_state_change,
    cleanup,
    set_sco_allowed,
    send_bsir,
};

/*******************************************************************************
+9 −0
Original line number Diff line number Diff line
@@ -319,6 +319,15 @@ typedef struct {

  /** Whether we will initiate SCO or not **/
  bt_status_t (*set_sco_allowed)(bool value);

  /**
   * Send +BSIR response code to enable/disable in-band ringtone in an active
   * HFP service level connection
   *
   * @param value true for enabled, false for disable
   * @param bd_addr remote device address
   */
  bt_status_t (*send_bsir)(bool value, RawAddress* bd_addr);
} bthf_interface_t;

__END_DECLS