diff --git a/android/handsfree.c b/android/handsfree.c
index 356dbe0..595919a 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
hfp_gw_send_info(dev->gw, "+BCS: %u", type);
}
+static bool codec_negotiation_supported(struct hf_device *dev)
+{
+ return (dev->features & HFP_HF_FEAT_CODEC) &&
+ (hfp_ag_features & HFP_AG_FEAT_CODEC);
+}
+
static void connect_sco_cb(GIOChannel *chan, GError *err, gpointer user_data)
{
struct hf_device *dev = user_data;
set_audio_state(dev, HAL_EV_HANDSFREE_AUDIO_STATE_DISCONNECTED);
- if (!(dev->features & HFP_HF_FEAT_CODEC))
+ if (!codec_negotiation_supported(dev))
return;
/* If other failed, try connecting with CVSD */
if (dev->sco)
return false;
- if (!(dev->features & HFP_HF_FEAT_CODEC))
+ if (!codec_negotiation_supported(dev))
voice_settings = 0;
else if (dev->negotiated_codec != CODEC_ID_CVSD)
voice_settings = BT_VOICE_TRANSPARENT;
switch (type) {
case HFP_GW_CMD_TYPE_COMMAND:
- if (!(dev->features & HFP_HF_FEAT_CODEC))
+ if (!codec_negotiation_supported(dev))
break;
if (hfp_gw_result_has_next(result))
* If device supports Codec Negotiation, AT+BAC should be
* received first
*/
- if ((dev->features & HFP_HF_FEAT_CODEC) &&
+ if (codec_negotiation_supported(dev) &&
!dev->codecs[CVSD_OFFSET].remote_supported)
break;
switch (type) {
case HFP_GW_CMD_TYPE_SET:
- if (!(dev->features & HFP_HF_FEAT_CODEC))
+ if (!codec_negotiation_supported(dev))
goto failed;
/* set codecs to defaults */
return false;
/* we haven't negotiated codec, start selection */
- if ((dev->features & HFP_HF_FEAT_CODEC) && !dev->negotiated_codec) {
+ if (codec_negotiation_supported(dev) && !dev->negotiated_codec) {
select_codec(dev, 0);
return true;
}