diff options
-rw-r--r-- | flags/a2dp.aconfig | 10 | ||||
-rw-r--r-- | system/bta/ar/bta_ar.cc | 125 | ||||
-rw-r--r-- | system/bta/av/bta_av_main.cc | 101 | ||||
-rw-r--r-- | system/btif/avrcp/avrcp_service.cc | 103 |
4 files changed, 80 insertions, 259 deletions
diff --git a/flags/a2dp.aconfig b/flags/a2dp.aconfig index d615a631d2..eff73a2cf0 100644 --- a/flags/a2dp.aconfig +++ b/flags/a2dp.aconfig @@ -22,16 +22,6 @@ flag { } flag { - name: "avrcp_sdp_records" - namespace: "bluetooth" - description: "Update SDP records for AVRC" - bug: "341353017" - metadata { - purpose: PURPOSE_BUGFIX - } -} - -flag { name: "a2dp_variable_aac_capability" namespace: "bluetooth" description: "Enable AAC 48 kHz sampling rate for sink devices in the allow list" diff --git a/system/bta/ar/bta_ar.cc b/system/bta/ar/bta_ar.cc index 8f41416ead..45e6010e31 100644 --- a/system/bta/ar/bta_ar.cc +++ b/system/bta/ar/bta_ar.cc @@ -201,58 +201,21 @@ void bta_ar_reg_avrc(uint16_t service_uuid, const char* service_name, const char return; } - if (com::android::bluetooth::flags::avrcp_sdp_records()) { - const std::shared_ptr<AvrcpSdpService>& avrcp_sdp_service = AvrcpSdpService::Get(); - AvrcpSdpRecord add_record_request = {service_uuid, - service_name, - provider_name, - categories, - browse_supported, - profile_version, - 0}; - if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET) { - avrcp_sdp_service->AddRecord(add_record_request, bta_ar_cb.sdp_tg_request_id); - log::debug("Assigned target request id {}", bta_ar_cb.sdp_tg_request_id); - } else if (service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL || - service_uuid == UUID_SERVCLASS_AV_REM_CTRL_CONTROL) { - avrcp_sdp_service->AddRecord(add_record_request, bta_ar_cb.sdp_ct_request_id); - log::debug("Assigned control request id {}", bta_ar_cb.sdp_ct_request_id); - } - return; - } - uint8_t mask = BTA_AR_AV_MASK; - uint8_t temp[8], *p; - + const std::shared_ptr<AvrcpSdpService>& avrcp_sdp_service = AvrcpSdpService::Get(); + AvrcpSdpRecord add_record_request = {service_uuid, + service_name, + provider_name, + categories, + browse_supported, + profile_version, + 0}; if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET) { - if (bta_ar_cb.sdp_tg_handle == 0) { - bta_ar_cb.tg_registered = mask; - bta_ar_cb.sdp_tg_handle = get_legacy_stack_sdp_api()->handle.SDP_CreateRecord(); - AVRC_AddRecord(service_uuid, service_name, provider_name, categories, bta_ar_cb.sdp_tg_handle, - browse_supported, profile_version, 0); - bta_sys_add_uuid(service_uuid); - } - /* only one TG is allowed (first-come, first-served). - * If sdp_tg_handle is non-0, ignore this request */ - } else if ((service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL) || - (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_CONTROL)) { - bta_ar_cb.ct_categories[mask - 1] = categories; - categories = bta_ar_cb.ct_categories[0] | bta_ar_cb.ct_categories[1]; - if (bta_ar_cb.sdp_ct_handle == 0) { - bta_ar_cb.sdp_ct_handle = get_legacy_stack_sdp_api()->handle.SDP_CreateRecord(); - AVRC_AddRecord(service_uuid, service_name, provider_name, categories, bta_ar_cb.sdp_ct_handle, - browse_supported, profile_version, 0); - bta_sys_add_uuid(service_uuid); - } else { - /* multiple CTs are allowed. - * Change supported categories on the second one */ - p = temp; - UINT16_TO_BE_STREAM(p, categories); - if (!get_legacy_stack_sdp_api()->handle.SDP_AddAttribute( - bta_ar_cb.sdp_ct_handle, ATTR_ID_SUPPORTED_FEATURES, UINT_DESC_TYPE, (uint32_t)2, - (uint8_t*)temp)) { - log::warn("Unable to add supported features handle:{}", bta_ar_cb.sdp_ct_handle); - } - } + avrcp_sdp_service->AddRecord(add_record_request, bta_ar_cb.sdp_tg_request_id); + log::debug("Assigned target request id {}", bta_ar_cb.sdp_tg_request_id); + } else if (service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL || + service_uuid == UUID_SERVCLASS_AV_REM_CTRL_CONTROL) { + avrcp_sdp_service->AddRecord(add_record_request, bta_ar_cb.sdp_ct_request_id); + log::debug("Assigned control request id {}", bta_ar_cb.sdp_ct_request_id); } } @@ -268,57 +231,17 @@ void bta_ar_reg_avrc(uint16_t service_uuid, const char* service_name, const char *****************************************************************************/ void bta_ar_dereg_avrc(uint16_t service_uuid) { log::verbose("Deregister AVRC 0x{:x}", service_uuid); - if (com::android::bluetooth::flags::avrcp_sdp_records()) { - const std::shared_ptr<AvrcpSdpService>& avrcp_sdp_service = AvrcpSdpService::Get(); - if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET && - bta_ar_cb.sdp_tg_request_id != UNASSIGNED_REQUEST_ID) { - avrcp_sdp_service->RemoveRecord(UUID_SERVCLASS_AV_REM_CTRL_TARGET, - bta_ar_cb.sdp_tg_request_id); - bta_ar_cb.sdp_tg_request_id = UNASSIGNED_REQUEST_ID; - } else if ((service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL || - service_uuid == UUID_SERVCLASS_AV_REM_CTRL_CONTROL) && - bta_ar_cb.sdp_ct_request_id != UNASSIGNED_REQUEST_ID) { - avrcp_sdp_service->RemoveRecord(UUID_SERVCLASS_AV_REMOTE_CONTROL, - bta_ar_cb.sdp_ct_request_id); - bta_ar_cb.sdp_ct_request_id = UNASSIGNED_REQUEST_ID; - } - return; - } - uint8_t mask = BTA_AR_AV_MASK; - uint16_t categories = 0; - uint8_t temp[8], *p; - if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET) { - if (bta_ar_cb.sdp_tg_handle && mask == bta_ar_cb.tg_registered) { - bta_ar_cb.tg_registered = 0; - if (!get_legacy_stack_sdp_api()->handle.SDP_DeleteRecord(bta_ar_cb.sdp_tg_handle)) { - log::warn("Unable to delete SDP record handle:{}", bta_ar_cb.sdp_tg_handle); - } - bta_ar_cb.sdp_tg_handle = 0; - bta_sys_remove_uuid(service_uuid); - } - } else if (service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL) { - if (bta_ar_cb.sdp_ct_handle) { - bta_ar_cb.ct_categories[mask - 1] = 0; - categories = bta_ar_cb.ct_categories[0] | bta_ar_cb.ct_categories[1]; - if (!categories) { - /* no CT is still registered - cleanup */ - if (get_legacy_stack_sdp_api()->handle.SDP_DeleteRecord(bta_ar_cb.sdp_ct_handle)) { - log::warn("Unable to delete SDP record handle:{}", bta_ar_cb.sdp_ct_handle); - } - bta_ar_cb.sdp_ct_handle = 0; - bta_sys_remove_uuid(service_uuid); - } else { - /* change supported categories to the remaining one */ - p = temp; - UINT16_TO_BE_STREAM(p, categories); - if (!get_legacy_stack_sdp_api()->handle.SDP_AddAttribute( - bta_ar_cb.sdp_ct_handle, ATTR_ID_SUPPORTED_FEATURES, UINT_DESC_TYPE, - (uint32_t)2, (uint8_t*)temp)) { - log::warn("Unable to add SDP supported features handle:{}", bta_ar_cb.sdp_ct_handle); - } - } - } + const std::shared_ptr<AvrcpSdpService>& avrcp_sdp_service = AvrcpSdpService::Get(); + if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET && + bta_ar_cb.sdp_tg_request_id != UNASSIGNED_REQUEST_ID) { + avrcp_sdp_service->RemoveRecord(UUID_SERVCLASS_AV_REM_CTRL_TARGET, bta_ar_cb.sdp_tg_request_id); + bta_ar_cb.sdp_tg_request_id = UNASSIGNED_REQUEST_ID; + } else if ((service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL || + service_uuid == UUID_SERVCLASS_AV_REM_CTRL_CONTROL) && + bta_ar_cb.sdp_ct_request_id != UNASSIGNED_REQUEST_ID) { + avrcp_sdp_service->RemoveRecord(UUID_SERVCLASS_AV_REMOTE_CONTROL, bta_ar_cb.sdp_ct_request_id); + bta_ar_cb.sdp_ct_request_id = UNASSIGNED_REQUEST_ID; } } diff --git a/system/bta/av/bta_av_main.cc b/system/bta/av/bta_av_main.cc index 65ec7276c0..f32dea2bf2 100644 --- a/system/bta/av/bta_av_main.cc +++ b/system/bta/av/bta_av_main.cc @@ -512,38 +512,14 @@ static void bta_av_api_register(tBTA_AV_DATA* p_data) { */ bta_ar_reg_avct(); - if (com::android::bluetooth::flags::avrcp_sdp_records()) { - // Add target record for - // a) A2DP sink profile. or - // b) A2DP source profile only if new avrcp service is disabled. - if (profile_initialized == UUID_SERVCLASS_AUDIO_SINK || - (profile_initialized == UUID_SERVCLASS_AUDIO_SOURCE && !is_new_avrcp_enabled())) { - bta_ar_reg_avrc(UUID_SERVCLASS_AV_REM_CTRL_TARGET, "AV Remote Control Target", "", - p_bta_av_cfg->avrc_tg_cat, (bta_av_cb.features & BTA_AV_FEAT_BROWSE), - avrcp_version); - } - } else { - /* For the Audio Sink role we support additional TG to support - * absolute volume. - */ - if (is_new_avrcp_enabled()) { - log::verbose( - "newavrcp is the owner of the AVRCP Target SDP record. Don't " - "create the SDP record"); - } else { - log::verbose("newavrcp is not enabled. Create SDP record"); - - if (btif_av_src_sink_coexist_enabled()) { - bta_ar_reg_avrc_for_src_sink_coexist( - UUID_SERVCLASS_AV_REM_CTRL_TARGET, "AV Remote Control Target", NULL, - p_bta_av_cfg->avrc_tg_cat, static_cast<tBTA_SYS_ID>(BTA_ID_AV + local_role), - (bta_av_cb.features & BTA_AV_FEAT_BROWSE), avrcp_version); - } else { - bta_ar_reg_avrc(UUID_SERVCLASS_AV_REM_CTRL_TARGET, "AV Remote Control Target", NULL, - p_bta_av_cfg->avrc_tg_cat, (bta_av_cb.features & BTA_AV_FEAT_BROWSE), - avrcp_version); - } - } + // Add target record for + // a) A2DP sink profile. or + // b) A2DP source profile only if new avrcp service is disabled. + if (profile_initialized == UUID_SERVCLASS_AUDIO_SINK || + (profile_initialized == UUID_SERVCLASS_AUDIO_SOURCE && !is_new_avrcp_enabled())) { + bta_ar_reg_avrc(UUID_SERVCLASS_AV_REM_CTRL_TARGET, "AV Remote Control Target", "", + p_bta_av_cfg->avrc_tg_cat, bta_av_cb.features & BTA_AV_FEAT_BROWSE, + avrcp_version); } } @@ -672,56 +648,25 @@ static void bta_av_api_register(tBTA_AV_DATA* p_data) { bta_ar_reg_avct(); bta_av_rc_create(&bta_av_cb, AVCT_ROLE_ACCEPTOR, 0, BTA_AV_NUM_LINKS + 1); } - if (com::android::bluetooth::flags::avrcp_sdp_records()) { - // Add control record for sink profile. - // Also adds control record for source profile when new avrcp service is not enabled. - if (profile_initialized == UUID_SERVCLASS_AUDIO_SINK || - (profile_initialized == UUID_SERVCLASS_AUDIO_SOURCE && !is_new_avrcp_enabled())) { - uint16_t control_version = AVRC_GetControlProfileVersion(); - /* Create an SDP record as AVRC CT. We create 1.3 for SOURCE - * because we rely on feature bits being scanned by external - * devices more than the profile version itself. - */ - if (profile_initialized == UUID_SERVCLASS_AUDIO_SOURCE && !is_new_avrcp_enabled()) { - control_version = AVRC_REV_1_3; - } - if (!btif_av_src_sink_coexist_enabled() && - profile_initialized == UUID_SERVCLASS_AUDIO_SINK) { - control_version = AVRC_REV_1_6; - } - bta_ar_reg_avrc(UUID_SERVCLASS_AV_REMOTE_CONTROL, "AV Remote Control", "", - p_bta_av_cfg->avrc_ct_cat, (bta_av_cb.features & BTA_AV_FEAT_BROWSE), - control_version); - } - } else { - /* create an SDP record as AVRC CT. We create 1.3 for SOURCE + // Add control record for sink profile. + // Also adds control record for source profile when new avrcp service is not enabled. + if (profile_initialized == UUID_SERVCLASS_AUDIO_SINK || + (profile_initialized == UUID_SERVCLASS_AUDIO_SOURCE && !is_new_avrcp_enabled())) { + uint16_t control_version = AVRC_GetControlProfileVersion(); + /* Create an SDP record as AVRC CT. We create 1.3 for SOURCE * because we rely on feature bits being scanned by external * devices more than the profile version itself. - * - * We create 1.4 for SINK since we support browsing. */ - if (btif_av_src_sink_coexist_enabled()) { - if (profile_initialized == UUID_SERVCLASS_AUDIO_SOURCE) { - bta_ar_reg_avrc_for_src_sink_coexist( - UUID_SERVCLASS_AV_REMOTE_CONTROL, NULL, NULL, p_bta_av_cfg->avrc_ct_cat, - BTA_ID_AV, (bta_av_cb.features & BTA_AV_FEAT_BROWSE), AVRC_REV_1_5); - } else if (profile_initialized == UUID_SERVCLASS_AUDIO_SINK) { - bta_ar_reg_avrc_for_src_sink_coexist(UUID_SERVCLASS_AV_REMOTE_CONTROL, NULL, NULL, - p_bta_av_cfg->avrc_ct_cat, BTA_ID_AVK, - (bta_av_cb.features & BTA_AV_FEAT_BROWSE), - AVRC_GetControlProfileVersion()); - } - } else { - if (profile_initialized == UUID_SERVCLASS_AUDIO_SOURCE && !is_new_avrcp_enabled()) { - bta_ar_reg_avrc(UUID_SERVCLASS_AV_REMOTE_CONTROL, NULL, NULL, - p_bta_av_cfg->avrc_ct_cat, (bta_av_cb.features & BTA_AV_FEAT_BROWSE), - AVRC_REV_1_3); - } else if (profile_initialized == UUID_SERVCLASS_AUDIO_SINK) { - bta_ar_reg_avrc(UUID_SERVCLASS_AV_REMOTE_CONTROL, NULL, NULL, - p_bta_av_cfg->avrc_ct_cat, (bta_av_cb.features & BTA_AV_FEAT_BROWSE), - AVRC_REV_1_6); - } + if (profile_initialized == UUID_SERVCLASS_AUDIO_SOURCE && !is_new_avrcp_enabled()) { + control_version = AVRC_REV_1_3; + } + if (!btif_av_src_sink_coexist_enabled() && + profile_initialized == UUID_SERVCLASS_AUDIO_SINK) { + control_version = AVRC_REV_1_6; } + bta_ar_reg_avrc(UUID_SERVCLASS_AV_REMOTE_CONTROL, "AV Remote Control", "", + p_bta_av_cfg->avrc_ct_cat, bta_av_cb.features & BTA_AV_FEAT_BROWSE, + control_version); } } } diff --git a/system/btif/avrcp/avrcp_service.cc b/system/btif/avrcp/avrcp_service.cc index a1a4574d04..955d5cc4d6 100644 --- a/system/btif/avrcp/avrcp_service.cc +++ b/system/btif/avrcp/avrcp_service.cc @@ -397,40 +397,25 @@ void AvrcpService::Init(MediaInterface* media_interface, VolumeInterface* volume profile_version = avrcp_interface_.GetAvrcpVersion(); uint16_t supported_features = GetSupportedFeatures(profile_version); - if (com::android::bluetooth::flags::avrcp_sdp_records()) { - const std::shared_ptr<AvrcpSdpService>& avrcp_sdp_service = AvrcpSdpService::Get(); - AvrcpSdpRecord target_add_record_request = {UUID_SERVCLASS_AV_REM_CTRL_TARGET, - "AV Remote Control Target", - "", - supported_features, - true, - profile_version, - 0}; - avrcp_sdp_service->AddRecord(target_add_record_request, target_sdp_request_id_); - log::verbose("Target request id {}", target_sdp_request_id_); - AvrcpSdpRecord control_add_record_request = {UUID_SERVCLASS_AV_REMOTE_CONTROL, - "AV Remote Control", - "", - AVRCP_SUPF_TG_CT, - false, - avrcp_interface_.GetAvrcpControlVersion(), - 0}; - avrcp_sdp_service->AddRecord(control_add_record_request, control_sdp_request_id_); - log::verbose("Control request id {}", control_sdp_request_id_); - } else { - sdp_record_handle = get_legacy_stack_sdp_api()->handle.SDP_CreateRecord(); - - avrcp_interface_.AddRecord(UUID_SERVCLASS_AV_REM_CTRL_TARGET, "AV Remote Control Target", NULL, - supported_features, sdp_record_handle, true, profile_version, 0); - bta_sys_add_uuid(UUID_SERVCLASS_AV_REM_CTRL_TARGET); - - ct_sdp_record_handle = get_legacy_stack_sdp_api()->handle.SDP_CreateRecord(); - - avrcp_interface_.AddRecord(UUID_SERVCLASS_AV_REMOTE_CONTROL, "AV Remote Control", NULL, - AVRCP_SUPF_TG_CT, ct_sdp_record_handle, false, - avrcp_interface_.GetAvrcpControlVersion(), 0); - bta_sys_add_uuid(UUID_SERVCLASS_AV_REMOTE_CONTROL); - } + const std::shared_ptr<AvrcpSdpService>& avrcp_sdp_service = AvrcpSdpService::Get(); + AvrcpSdpRecord target_add_record_request = {UUID_SERVCLASS_AV_REM_CTRL_TARGET, + "AV Remote Control Target", + "", + supported_features, + true, + profile_version, + 0}; + avrcp_sdp_service->AddRecord(target_add_record_request, target_sdp_request_id_); + log::verbose("Target request id {}", target_sdp_request_id_); + AvrcpSdpRecord control_add_record_request = {UUID_SERVCLASS_AV_REMOTE_CONTROL, + "AV Remote Control", + "", + AVRCP_SUPF_TG_CT, + false, + avrcp_interface_.GetAvrcpControlVersion(), + 0}; + avrcp_sdp_service->AddRecord(control_add_record_request, control_sdp_request_id_); + log::verbose("Control request id {}", control_sdp_request_id_); media_interface_ = new MediaInterfaceWrapper(media_interface); media_interface->RegisterUpdateCallback(instance_); @@ -472,20 +457,13 @@ uint16_t AvrcpService::GetSupportedFeatures(uint16_t profile_version) { void AvrcpService::Cleanup() { log::info("AVRCP Target Service stopped"); - if (com::android::bluetooth::flags::avrcp_sdp_records()) { - const std::shared_ptr<AvrcpSdpService>& avrcp_sdp_service = AvrcpSdpService::Get(); - avrcp_sdp_service->RemoveRecord(UUID_SERVCLASS_AV_REM_CTRL_TARGET, target_sdp_request_id_); - target_sdp_request_id_ = UNASSIGNED_REQUEST_ID; - avrcp_sdp_service->RemoveRecord(UUID_SERVCLASS_AV_REMOTE_CONTROL, control_sdp_request_id_); - control_sdp_request_id_ = UNASSIGNED_REQUEST_ID; - } else { - avrcp_interface_.RemoveRecord(sdp_record_handle); - bta_sys_remove_uuid(UUID_SERVCLASS_AV_REM_CTRL_TARGET); - sdp_record_handle = -1; - avrcp_interface_.RemoveRecord(ct_sdp_record_handle); - bta_sys_remove_uuid(UUID_SERVCLASS_AV_REMOTE_CONTROL); - ct_sdp_record_handle = -1; - } + + const std::shared_ptr<AvrcpSdpService>& avrcp_sdp_service = AvrcpSdpService::Get(); + avrcp_sdp_service->RemoveRecord(UUID_SERVCLASS_AV_REM_CTRL_TARGET, target_sdp_request_id_); + target_sdp_request_id_ = UNASSIGNED_REQUEST_ID; + avrcp_sdp_service->RemoveRecord(UUID_SERVCLASS_AV_REMOTE_CONTROL, control_sdp_request_id_); + control_sdp_request_id_ = UNASSIGNED_REQUEST_ID; + connection_handler_->CleanUp(); connection_handler_ = nullptr; if (player_settings_interface_ != nullptr) { @@ -499,32 +477,17 @@ void AvrcpService::Cleanup() { void AvrcpService::RegisterBipServer(int psm) { log::info("AVRCP Target Service has registered a BIP OBEX server, psm={}", psm); - if (com::android::bluetooth::flags::avrcp_sdp_records()) { - const std::shared_ptr<AvrcpSdpService>& avrcp_sdp_service = AvrcpSdpService::Get(); - avrcp_sdp_service->EnableCovertArt(UUID_SERVCLASS_AV_REM_CTRL_TARGET, psm, - target_sdp_request_id_); - } else { - avrcp_interface_.RemoveRecord(sdp_record_handle); - uint16_t supported_features = - GetSupportedFeatures(profile_version) | AVRC_SUPF_TG_PLAYER_COVER_ART; - sdp_record_handle = get_legacy_stack_sdp_api()->handle.SDP_CreateRecord(); - avrcp_interface_.AddRecord(UUID_SERVCLASS_AV_REM_CTRL_TARGET, "AV Remote Control Target", NULL, - supported_features, sdp_record_handle, true, profile_version, psm); - } + + const std::shared_ptr<AvrcpSdpService>& avrcp_sdp_service = AvrcpSdpService::Get(); + avrcp_sdp_service->EnableCovertArt(UUID_SERVCLASS_AV_REM_CTRL_TARGET, psm, + target_sdp_request_id_); } void AvrcpService::UnregisterBipServer() { log::info("AVRCP Target Service has unregistered a BIP OBEX server"); - if (com::android::bluetooth::flags::avrcp_sdp_records()) { - const std::shared_ptr<AvrcpSdpService>& avrcp_sdp_service = AvrcpSdpService::Get(); - avrcp_sdp_service->DisableCovertArt(UUID_SERVCLASS_AV_REM_CTRL_TARGET, target_sdp_request_id_); - } else { - avrcp_interface_.RemoveRecord(sdp_record_handle); - uint16_t supported_features = GetSupportedFeatures(profile_version); - sdp_record_handle = get_legacy_stack_sdp_api()->handle.SDP_CreateRecord(); - avrcp_interface_.AddRecord(UUID_SERVCLASS_AV_REM_CTRL_TARGET, "AV Remote Control Target", NULL, - supported_features, sdp_record_handle, true, profile_version, 0); - } + + const std::shared_ptr<AvrcpSdpService>& avrcp_sdp_service = AvrcpSdpService::Get(); + avrcp_sdp_service->DisableCovertArt(UUID_SERVCLASS_AV_REM_CTRL_TARGET, target_sdp_request_id_); avrcp_interface_.RemoveRecord(sdp_record_handle); uint16_t supported_features = GetSupportedFeatures(profile_version); sdp_record_handle = get_legacy_stack_sdp_api()->handle.SDP_CreateRecord(); |