From b33b85539fe1a0a1fbffbc93811c0597207f2684 Mon Sep 17 00:00:00 2001 From: Ajay Panicker Date: Fri, 1 Sep 2017 12:07:42 -0700 Subject: [PATCH] Bluetooth: Add AVRCP 1.3 as a developer option for AVRCP version (2/2) This is requied for the 2012 Mazda 3 carkit as the carkit refuses to send AVRCP commands other than passthrough commands when the version is anything else. AVRCP 1.3 is compatible with most carkits on the market and can be used to get most carkits working at the cost of losing many features. Bug: 37943083 Test: Set AVRCP 1.3 in developer options and see that SDP and the AVRCP capabilites have updated to reflect this. TestTracker: 105915/3975 Change-Id: Iffc7ed1dd91eecb699153125b25451de5826f202 (cherry picked from commit 2369a95e6ed0c16f61237fe9c1fc5a90d97129c1) --- bta/av/bta_av_cfg.cc | 4 +++- bta/av/bta_av_main.cc | 23 ++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/bta/av/bta_av_cfg.cc b/bta/av/bta_av_cfg.cc index 10baa33ea..68ca3bee6 100644 --- a/bta/av/bta_av_cfg.cc +++ b/bta/av/bta_av_cfg.cc @@ -84,7 +84,7 @@ const uint16_t bta_av_audio_flush_to[] = { #endif /* - * If the number of event IDs is changed in this array, BTA_AV_ NUM_RC_EVT_IDS + * If the number of event IDs is changed in this array, BTA_AV_NUM_RC_EVT_IDS * also needs to be changed. */ const uint8_t bta_av_meta_caps_evt_ids[] = { @@ -96,6 +96,7 @@ const uint8_t bta_av_meta_caps_evt_ids[] = { AVRC_EVT_APP_SETTING_CHANGE, */ }; + #ifndef BTA_AV_NUM_RC_EVT_IDS #define BTA_AV_NUM_RC_EVT_IDS \ (sizeof(bta_av_meta_caps_evt_ids) / sizeof(bta_av_meta_caps_evt_ids[0])) @@ -106,6 +107,7 @@ const uint8_t bta_avk_meta_caps_evt_ids[] = { AVRC_EVT_VOLUME_CHANGE, #endif }; + #ifndef BTA_AVK_NUM_RC_EVT_IDS #define BTA_AVK_NUM_RC_EVT_IDS \ (sizeof(bta_avk_meta_caps_evt_ids) / sizeof(bta_avk_meta_caps_evt_ids[0])) diff --git a/bta/av/bta_av_main.cc b/bta/av/bta_av_main.cc index d8de1503e..51280180e 100644 --- a/bta/av/bta_av_main.cc +++ b/bta/av/bta_av_main.cc @@ -80,6 +80,10 @@ #define AVRCP_1_4_STRING "avrcp14" #endif +#ifndef AVRCP_1_3_STRING +#define AVRCP_1_3_STRING "avrcp13" +#endif + /* state machine states */ enum { BTA_AV_INIT_ST, BTA_AV_OPEN_ST }; @@ -422,11 +426,20 @@ static void bta_av_api_register(tBTA_AV_DATA* p_data) { registr.app_id = p_data->api_reg.app_id; registr.chnl = (tBTA_AV_CHNL)p_data->hdr.layer_specific; + char avrcp_version[PROPERTY_VALUE_MAX] = {0}; + osi_property_get(AVRCP_VERSION_PROPERTY, avrcp_version, AVRCP_1_4_STRING); + LOG_INFO(LOG_TAG, "AVRCP version used for sdp: \"%s\"", avrcp_version); + uint16_t profile_initialized = p_data->api_reg.service_uuid; if (profile_initialized == UUID_SERVCLASS_AUDIO_SINK) { p_bta_av_cfg = (tBTA_AV_CFG*)&bta_avk_cfg; } else if (profile_initialized == UUID_SERVCLASS_AUDIO_SOURCE) { p_bta_av_cfg = (tBTA_AV_CFG*)&bta_av_cfg; + + if (!strncmp(AVRCP_1_3_STRING, avrcp_version, sizeof(AVRCP_1_3_STRING))) { + LOG_INFO(LOG_TAG, "AVRCP 1.3 capabilites used"); + p_bta_av_cfg = (tBTA_AV_CFG*)&bta_av_cfg_compatibility; + } } APPL_TRACE_DEBUG("%s: profile: 0x%x", __func__, profile_initialized); @@ -479,19 +492,15 @@ static void bta_av_api_register(tBTA_AV_DATA* p_data) { uint16_t profile_version = AVRC_REV_1_0; if (profile_initialized == UUID_SERVCLASS_AUDIO_SOURCE) { - // This check can override the AVRCP profile version with a property - char avrcp_version[PROPERTY_VALUE_MAX] = {0}; - osi_property_get(AVRCP_VERSION_PROPERTY, avrcp_version, - AVRCP_1_4_STRING); - LOG_INFO(LOG_TAG, "AVRCP version used for sdp: \"%s\"", - avrcp_version); - if (!strncmp(AVRCP_1_6_STRING, avrcp_version, sizeof(AVRCP_1_6_STRING))) { profile_version = AVRC_REV_1_6; } else if (!strncmp(AVRCP_1_5_STRING, avrcp_version, sizeof(AVRCP_1_5_STRING))) { profile_version = AVRC_REV_1_5; + } else if (!strncmp(AVRCP_1_3_STRING, avrcp_version, + sizeof(AVRCP_1_3_STRING))) { + profile_version = AVRC_REV_1_3; } else { profile_version = AVRC_REV_1_4; } -- 2.11.0