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

Commit 7cb0440a authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge "AptX Voice: Check sysprop in addition to Flag" into main

parents 13ab066e 0cc31a6c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ static_library("bta") {
    "ag/bta_ag_rfc.cc",
    "ag/bta_ag_sco.cc",
    "ag/bta_ag_sdp.cc",
    "ag/bta_ag_swb_aptx.cc",
    "ar/bta_ar.cc",
    "av/bta_av_aact.cc",
    "av/bta_av_act.cc",
+1 −1
Original line number Diff line number Diff line
@@ -845,7 +845,7 @@ void bta_ag_svc_conn_open(tBTA_AG_SCB* p_scb,
void bta_ag_setcodec(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data) {
  tBTA_AG_PEER_CODEC codec_type = data.api_setcodec.codec;
  tBTA_AG_VAL val = {};
  const bool aptx_voice = IS_FLAG_ENABLED(hfp_codec_aptx_voice) &&
  const bool aptx_voice = is_hfp_aptx_voice_enabled() &&
                          (codec_type == BTA_AG_SCO_APTX_SWB_SETTINGS_Q0);
  LOG_VERBOSE("aptx_voice=%s, codec_type=%#x", logbool(aptx_voice).c_str(),
              codec_type);
+3 −3
Original line number Diff line number Diff line
@@ -1257,7 +1257,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB* p_scb, uint16_t cmd, uint8_t arg_type,
        bool wbs_supported = hfp_hal_interface::get_wbs_supported();
        bool swb_supported = hfp_hal_interface::get_swb_supported();
        const bool aptx_voice =
            IS_FLAG_ENABLED(hfp_codec_aptx_voice) && p_scb->is_aptx_swb_codec;
            is_hfp_aptx_voice_enabled() && p_scb->is_aptx_swb_codec;
        LOG_VERBOSE("BTA_AG_AT_BAC_EVT aptx_voice=%s",
                    logbool(aptx_voice).c_str());

@@ -1345,7 +1345,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB* p_scb, uint16_t cmd, uint8_t arg_type,
      break;
    }
    case BTA_AG_AT_QAC_EVT:
      if (!IS_FLAG_ENABLED(hfp_codec_aptx_voice)) {
      if (!is_hfp_aptx_voice_enabled()) {
        bta_ag_send_error(p_scb, BTA_AG_ERR_OP_NOT_SUPPORTED);
        break;
      }
@@ -1356,7 +1356,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB* p_scb, uint16_t cmd, uint8_t arg_type,
      bta_ag_send_ok(p_scb);
      break;
    case BTA_AG_AT_QCS_EVT:
      if (!IS_FLAG_ENABLED(hfp_codec_aptx_voice)) {
      if (!is_hfp_aptx_voice_enabled()) {
        bta_ag_send_error(p_scb, BTA_AG_ERR_OP_NOT_SUPPORTED);
        break;
      }
+6 −6
Original line number Diff line number Diff line
@@ -198,7 +198,7 @@ static void bta_ag_sco_disc_cback(uint16_t sco_idx) {

  if (handle != 0) {
    const bool aptx_voice =
        IS_FLAG_ENABLED(hfp_codec_aptx_voice) &&
        is_hfp_aptx_voice_enabled() &&
        (bta_ag_cb.sco.p_curr_scb->is_aptx_swb_codec == true) &&
        (bta_ag_cb.sco.p_curr_scb->inuse_codec ==
         BTA_AG_SCO_APTX_SWB_SETTINGS_Q0);
@@ -420,7 +420,7 @@ void bta_ag_create_sco(tBTA_AG_SCB* p_scb, bool is_orig) {
  }
#endif

  if (IS_FLAG_ENABLED(hfp_codec_aptx_voice)) {
  if (is_hfp_aptx_voice_enabled()) {
    if ((p_scb->sco_codec == BTA_AG_SCO_APTX_SWB_SETTINGS_Q0) &&
        !p_scb->codec_fallback) {
      esco_codec = BTA_AG_SCO_APTX_SWB_SETTINGS_Q0;
@@ -464,7 +464,7 @@ void bta_ag_create_sco(tBTA_AG_SCB* p_scb, bool is_orig) {
    } else {
      params = esco_parameters_for_codec(ESCO_CODEC_MSBC_T1, offload);
    }
  } else if (IS_FLAG_ENABLED(hfp_codec_aptx_voice) &&
  } else if (is_hfp_aptx_voice_enabled() &&
             (p_scb->is_aptx_swb_codec == true && !p_scb->codec_updated)) {
    if (p_scb->codec_aptx_settings == BTA_AG_SCO_APTX_SWB_SETTINGS_Q3) {
      params = esco_parameters_for_codec(ESCO_CODEC_SWB_Q3, true);
@@ -548,7 +548,7 @@ void bta_ag_create_pending_sco(tBTA_AG_SCB* p_scb, bool is_local) {
      } else {
        params = esco_parameters_for_codec(ESCO_CODEC_LC3_T1, offload);
      }
    } else if (IS_FLAG_ENABLED(hfp_codec_aptx_voice) &&
    } else if (is_hfp_aptx_voice_enabled() &&
               (p_scb->is_aptx_swb_codec == true && !p_scb->codec_updated)) {
      if (p_scb->codec_aptx_settings == BTA_AG_SCO_APTX_SWB_SETTINGS_Q3) {
        params = esco_parameters_for_codec(ESCO_CODEC_SWB_Q3, true);
@@ -684,7 +684,7 @@ void bta_ag_codec_negotiate(tBTA_AG_SCB* p_scb) {
    p_scb->sco_codec = UUID_CODEC_CVSD;
  }
  const bool aptx_voice =
      IS_FLAG_ENABLED(hfp_codec_aptx_voice) && p_scb->is_aptx_swb_codec &&
      is_hfp_aptx_voice_enabled() && p_scb->is_aptx_swb_codec &&
      (p_scb->peer_codecs & BTA_AG_SCO_APTX_SWB_SETTINGS_Q0_MASK);
  LOG_VERBOSE("aptx_voice=%s, is_aptx_swb_codec=%s, Q0 codec supported=%s",
              logbool(aptx_voice).c_str(),
@@ -1449,7 +1449,7 @@ void bta_ag_sco_conn_close(tBTA_AG_SCB* p_scb,
  /* clear current scb */
  bta_ag_cb.sco.p_curr_scb = nullptr;
  p_scb->sco_idx = BTM_INVALID_SCO_INDEX;
  const bool aptx_voice = IS_FLAG_ENABLED(hfp_codec_aptx_voice) &&
  const bool aptx_voice = is_hfp_aptx_voice_enabled() &&
                          p_scb->codec_fallback &&
                          (p_scb->sco_codec == BTA_AG_SCO_APTX_SWB_SETTINGS_Q0);
  LOG_VERBOSE("aptx_voice=%s, codec_fallback=%#x, sco_codec=%#x",
+7 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

#include "bta_ag_swb_aptx.h"

#include <android_bluetooth_flags.h>
#include <android_bluetooth_sysprop.h>
#include <string.h>
#include <unistd.h>

@@ -29,6 +31,11 @@
#include "types/raw_address.h"
#include "utl.h"

bool is_hfp_aptx_voice_enabled() {
  return IS_FLAG_ENABLED(hfp_codec_aptx_voice) &&
         GET_SYSPROP(Hfp, codec_aptx_voice, false);
}

void bta_ag_swb_handle_vs_at_events(tBTA_AG_SCB* p_scb, uint16_t cmd,
                                    int16_t int_arg, tBTA_AG_VAL* val) {
  switch (cmd) {
Loading