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

Commit 1216878b authored by Jeremy Wu's avatar Jeremy Wu
Browse files

Floss: rework `force_cvsd` to `disabled_codecs`

We used to have a parameter in `ConnectAudio` during SCO creation to
force using CVSD.

In this CL, we extend it so that we can force un/using certain codecs,
along with the new codec, LC3.

This should be landed only after https://crrev.com/c/4574163.

Bug: 269970706
Tag: #floss
Test: emerge-brya floss
Change-Id: Ie23ee2eff052a8c313c58d9da2c5032a6a4de614
parent 9e9b9300
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -208,7 +208,7 @@ message StopSlcResponse {
message ConnectAudioRequest {
  Connection connection = 1;
  bool is_sco_offload_enabled = 2;
  bool force_cvsd = 3;
  int32 disabled_codecs = 3;
}

message ConnectAudioResponse {
+2 −2
Original line number Diff line number Diff line
@@ -63,13 +63,13 @@ class HfpClient(AsyncClosable):
            facade_pb2.StopSlcRequest(connection=facade_pb2.Connection(cookie=address.encode())))
        return await self._listen_for_event(facade_pb2.EventType.HFP_CONNECTION_STATE)

    async def connect_audio(self, address, is_sco_offload_enabled=False, force_cvsd=False):
    async def connect_audio(self, address, is_sco_offload_enabled=False, disabled_codecs=0):
        """
        """
        await self.__hfp_stub.ConnectAudio(
            facade_pb2.ConnectAudioRequest(connection=facade_pb2.Connection(cookie=address.encode()),
                                           is_sco_offload_enabled=is_sco_offload_enabled,
                                           force_cvsd=force_cvsd))
                                           disabled_codecs=disabled_codecs))

    async def disconnect_audio(self, address):
        """
+6 −4
Original line number Diff line number Diff line
@@ -159,16 +159,18 @@ void BTA_AgClose(uint16_t handle) {
 * Function         BTA_AgAudioOpen
 *
 * Description      Opens an audio connection to the currently connected
 *                  headset or handsfree. Specifying force_cvsd to true to
 *                  force the stack to use CVSD even if mSBC is supported.
 *                  headset or handsfree. Specify `disabled_codecs` to
 *                  force the stack to avoid using certain codecs.
 *
 *                  Note that CVSD is a mandatory codec and cannot be disabled.
 *
 *
 * Returns          void
 *
 ******************************************************************************/
void BTA_AgAudioOpen(uint16_t handle, bool force_cvsd) {
void BTA_AgAudioOpen(uint16_t handle, tBTA_AG_PEER_CODEC disabled_codecs) {
  tBTA_AG_DATA data = {};
  data.api_audio_open.force_cvsd = force_cvsd;
  data.api_audio_open.disabled_codecs = disabled_codecs;
  do_in_main_thread(FROM_HERE, base::Bind(&bta_ag_sm_execute_by_handle, handle,
                                          BTA_AG_API_AUDIO_OPEN_EVT, data));
}
+4 −2
Original line number Diff line number Diff line
@@ -1260,10 +1260,12 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB* p_scb, uint16_t cmd, uint8_t arg_type,

        bool swb_supported = hfp_hal_interface::get_swb_supported();

        if ((p_scb->peer_codecs & BTM_SCO_CODEC_LC3) && swb_supported) {
        if (swb_supported && (p_scb->peer_codecs & BTM_SCO_CODEC_LC3) &&
            !(p_scb->disabled_codecs & BTM_SCO_CODEC_LC3)) {
          p_scb->sco_codec = BTM_SCO_CODEC_LC3;
          APPL_TRACE_DEBUG("Received AT+BAC, updating sco codec to LC3");
        } else if (p_scb->peer_codecs & BTM_SCO_CODEC_MSBC) {
        } else if ((p_scb->peer_codecs & BTM_SCO_CODEC_MSBC) &&
                   !(p_scb->disabled_codecs & BTM_SCO_CODEC_MSBC)) {
          p_scb->sco_codec = BTM_SCO_CODEC_MSBC;
          APPL_TRACE_DEBUG("Received AT+BAC, updating sco codec to MSBC");
        } else {
+3 −1
Original line number Diff line number Diff line
@@ -136,7 +136,7 @@ typedef struct {

/* data type for BTA_AG_API_AUDIO_OPEN_EVT */
typedef struct {
  bool force_cvsd;
  tBTA_AG_PEER_CODEC disabled_codecs;
} tBTA_AG_API_AUDIO_OPEN;

/* data type for BTA_AG_API_RESULT_EVT */
@@ -252,6 +252,8 @@ struct tBTA_AG_SCB {
  alarm_t* ring_timer;
  alarm_t* codec_negotiation_timer;
  bool received_at_bac; /* indicate AT+BAC is received at least once */
  tBTA_AG_PEER_CODEC
      disabled_codecs; /* set by app to block certain codecs from being used */
  tBTA_AG_PEER_CODEC peer_codecs; /* codecs for eSCO supported by the peer */
  tBTA_AG_PEER_CODEC sco_codec;   /* codec to be used for eSCO connection */
  tBTA_AG_PEER_CODEC
Loading