Loading system/bta/ag/bta_ag_act.cc +10 −0 Original line number Diff line number Diff line Loading @@ -29,8 +29,14 @@ #include "bta/ag/bta_ag_int.h" #include "bta/include/bta_dm_api.h" #ifdef OS_ANDROID #include "bta/le_audio/devices.h" #endif #include "btif/include/btif_config.h" #include "device/include/device_iot_config.h" #include "os/system_properties.h" #include "osi/include/osi.h" // UNUSED_ATTR #include "stack/include/l2c_api.h" #include "stack/include/port_api.h" Loading Loading @@ -760,6 +766,10 @@ void bta_ag_post_sco_close(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data) { if (bta_ag_inband_enabled(p_scb) && !(p_scb->features & BTA_AG_FEAT_NOSCO)) { p_scb->post_sco = BTA_AG_POST_SCO_RING; if (!bta_ag_is_sco_open_allowed(p_scb, "BTA_AG_POST_SCO_CALL_END_INCALL")) { break; } bta_ag_sco_open(p_scb, data); } else { p_scb->post_sco = BTA_AG_POST_SCO_NONE; Loading system/bta/ag/bta_ag_cmd.cc +77 −2 Original line number Diff line number Diff line Loading @@ -27,7 +27,13 @@ #include "bta/ag/bta_ag_int.h" #include "bta/include/bta_ag_api.h" #include "bta/include/utl.h" #ifdef OS_ANDROID #include "bta/le_audio/devices.h" #endif #include "device/include/interop.h" #include "os/system_properties.h" #include "osi/include/compat.h" #include "osi/include/log.h" #include "osi/include/osi.h" // UNUSED_ATTR Loading Loading @@ -1317,11 +1323,18 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB* p_scb, uint16_t cmd, uint8_t arg_type, } case BTA_AG_LOCAL_EVT_BCC: { if (!bta_ag_sco_is_active_device(p_scb->peer_addr)) { LOG(WARNING) << __func__ << ": AT+BCC rejected as " << p_scb->peer_addr << " is not the active device"; LOG_WARN( "NOT opening SCO for EVT %s as %s is not the active HFP device", "BTA_AG_LOCAL_EVT_BCC", p_scb->peer_addr.ToStringForLogging().c_str()); bta_ag_send_error(p_scb, BTA_AG_ERR_OP_NOT_ALLOWED); break; } if (!bta_ag_is_sco_open_allowed(p_scb, "BTA_AG_LOCAL_EVT_BCC")) { bta_ag_send_error(p_scb, BTA_AG_ERR_OP_NOT_ALLOWED); break; } bta_ag_send_ok(p_scb); bta_ag_sco_open(p_scb, tBTA_AG_DATA::kEmpty); break; Loading Loading @@ -1404,6 +1417,11 @@ static void bta_ag_hsp_result(tBTA_AG_SCB* p_scb, } else { p_scb->post_sco = BTA_AG_POST_SCO_RING; } if (!bta_ag_is_sco_open_allowed(p_scb, bta_ag_result_text(result.result))) { break; } bta_ag_sco_open(p_scb, tBTA_AG_DATA::kEmpty); } break; Loading @@ -1419,6 +1437,10 @@ static void bta_ag_hsp_result(tBTA_AG_SCB* p_scb, /* if audio connected to this scb AND sco is not opened, open sco */ if (result.data.audio_handle == bta_ag_scb_to_idx(p_scb) && !bta_ag_sco_is_open(p_scb)) { if (!bta_ag_is_sco_open_allowed(p_scb, bta_ag_result_text(result.result))) { break; } bta_ag_sco_open(p_scb, tBTA_AG_DATA::kEmpty); } else if (result.data.audio_handle == BTA_AG_HANDLE_NONE && bta_ag_sco_is_open(p_scb)) { Loading Loading @@ -1508,6 +1530,11 @@ static void bta_ag_hfp_result(tBTA_AG_SCB* p_scb, } else { /* else open sco, send ring after sco opened */ p_scb->post_sco = BTA_AG_POST_SCO_RING; if (!bta_ag_is_sco_open_allowed(p_scb, bta_ag_result_text(result.result))) { break; } bta_ag_sco_open(p_scb, tBTA_AG_DATA::kEmpty); } } Loading @@ -1524,6 +1551,10 @@ static void bta_ag_hfp_result(tBTA_AG_SCB* p_scb, if (!(p_scb->features & BTA_AG_FEAT_NOSCO)) { if (result.data.audio_handle == bta_ag_scb_to_idx(p_scb) && !bta_ag_sco_is_open(p_scb)) { if (!bta_ag_is_sco_open_allowed(p_scb, bta_ag_result_text(result.result))) { break; } bta_ag_sco_open(p_scb, tBTA_AG_DATA::kEmpty); } else if ((result.data.audio_handle == BTA_AG_HANDLE_NONE) && bta_ag_sco_is_open(p_scb)) { Loading @@ -1543,6 +1574,10 @@ static void bta_ag_hfp_result(tBTA_AG_SCB* p_scb, bta_ag_send_call_inds(p_scb, result.result); if (result.data.audio_handle == bta_ag_scb_to_idx(p_scb) && !(p_scb->features & BTA_AG_FEAT_NOSCO)) { if (!bta_ag_is_sco_open_allowed(p_scb, bta_ag_result_text(result.result))) { break; } bta_ag_sco_open(p_scb, tBTA_AG_DATA::kEmpty); } break; Loading @@ -1552,6 +1587,10 @@ static void bta_ag_hfp_result(tBTA_AG_SCB* p_scb, bta_ag_send_call_inds(p_scb, result.result); if (result.data.audio_handle == bta_ag_scb_to_idx(p_scb) && !(p_scb->features & BTA_AG_FEAT_NOSCO)) { if (!bta_ag_is_sco_open_allowed(p_scb, bta_ag_result_text(result.result))) { break; } bta_ag_sco_open(p_scb, tBTA_AG_DATA::kEmpty); } break; Loading @@ -1561,6 +1600,10 @@ static void bta_ag_hfp_result(tBTA_AG_SCB* p_scb, APPL_TRACE_DEBUG("Headset Connected in three way call"); if (!(p_scb->features & BTA_AG_FEAT_NOSCO)) { if (result.data.audio_handle == bta_ag_scb_to_idx(p_scb)) { if (!bta_ag_is_sco_open_allowed(p_scb, bta_ag_result_text(result.result))) { break; } bta_ag_sco_open(p_scb, tBTA_AG_DATA::kEmpty); } else if (result.data.audio_handle == BTA_AG_HANDLE_NONE) { bta_ag_sco_close(p_scb, tBTA_AG_DATA::kEmpty); Loading @@ -1575,6 +1618,10 @@ static void bta_ag_hfp_result(tBTA_AG_SCB* p_scb, /* open or close sco */ if (!(p_scb->features & BTA_AG_FEAT_NOSCO)) { if (result.data.audio_handle == bta_ag_scb_to_idx(p_scb)) { if (!bta_ag_is_sco_open_allowed(p_scb, bta_ag_result_text(result.result))) { break; } bta_ag_sco_open(p_scb, tBTA_AG_DATA::kEmpty); } else if (result.data.audio_handle == BTA_AG_HANDLE_NONE) { bta_ag_sco_close(p_scb, tBTA_AG_DATA::kEmpty); Loading Loading @@ -1803,6 +1850,34 @@ void bta_ag_send_bcs(tBTA_AG_SCB* p_scb) { bta_ag_send_result(p_scb, BTA_AG_LOCAL_RES_BCS, nullptr, codec_uuid); } /******************************************************************************* * * Function bta_ag_is_sco_open_allowed * * Description Check if we can open SCO from the BT stack * * Returns true if we can, false if not * ******************************************************************************/ bool bta_ag_is_sco_open_allowed(tBTA_AG_SCB* p_scb, const std::string event) { #ifdef OS_ANDROID /* Do not open SCO if 1. the dual mode audio system property is enabled, 2. LEA is active, and 3. LEA is preferred for DUPLEX */ if (bluetooth::os::GetSystemPropertyBool( bluetooth::os::kIsDualModeAudioEnabledProperty, false)) { if (LeAudioClient::Get()->isDuplexPreferenceLeAudio(p_scb->peer_addr)) { LOG_INFO("NOT opening SCO for EVT %s on dual mode device %s", event.c_str(), p_scb->peer_addr.ToStringForLogging().c_str()); return false; } else { LOG_INFO("Opening SCO for EVT %s on dual mode device %s", event.c_str(), p_scb->peer_addr.ToStringForLogging().c_str()); } } #endif return true; } /******************************************************************************* * * Function bta_ag_send_ring Loading system/bta/ag/bta_ag_int.h +2 −0 Original line number Diff line number Diff line Loading @@ -418,6 +418,8 @@ extern void bta_ag_handle_collision(tBTA_AG_SCB* p_scb, /* Internal utility functions */ extern void bta_ag_sco_codec_nego(tBTA_AG_SCB* p_scb, bool result); extern void bta_ag_codec_negotiate(tBTA_AG_SCB* p_scb); extern bool bta_ag_is_sco_open_allowed(tBTA_AG_SCB* p_scb, const std::string event); extern void bta_ag_send_bcs(tBTA_AG_SCB* p_scb); extern void bta_ag_set_sco_offload_enabled(bool value); extern void bta_ag_set_sco_allowed(bool value); Loading system/bta/ag/bta_ag_main.cc +4 −0 Original line number Diff line number Diff line Loading @@ -560,6 +560,7 @@ static void bta_ag_better_state_machine(tBTA_AG_SCB* p_scb, uint16_t event, bta_ag_sco_listen(p_scb, data); break; case BTA_AG_SCO_OPEN_EVT: LOG_INFO("Opening sco for EVT BTA_AG_SCO_OPEN_EVT"); bta_ag_sco_conn_open(p_scb, data); break; case BTA_AG_SCO_CLOSE_EVT: Loading Loading @@ -597,6 +598,7 @@ static void bta_ag_better_state_machine(tBTA_AG_SCB* p_scb, uint16_t event, bta_ag_rfc_fail(p_scb, data); break; case BTA_AG_SCO_OPEN_EVT: LOG_INFO("Opening sco for EVT BTA_AG_SCO_OPEN_EVT"); bta_ag_sco_conn_open(p_scb, data); break; case BTA_AG_SCO_CLOSE_EVT: Loading Loading @@ -655,6 +657,7 @@ static void bta_ag_better_state_machine(tBTA_AG_SCB* p_scb, uint16_t event, bta_ag_rfc_data(p_scb, data); break; case BTA_AG_SCO_OPEN_EVT: LOG_INFO("Opening sco for EVT BTA_AG_SCO_OPEN_EVT"); bta_ag_sco_conn_open(p_scb, data); bta_ag_post_sco_open(p_scb, data); break; Loading Loading @@ -690,6 +693,7 @@ static void bta_ag_better_state_machine(tBTA_AG_SCB* p_scb, uint16_t event, bta_ag_rfc_close(p_scb, data); break; case BTA_AG_SCO_OPEN_EVT: LOG_INFO("Opening sco for EVT BTA_AG_SCO_OPEN_EVT"); bta_ag_sco_conn_open(p_scb, data); break; case BTA_AG_SCO_CLOSE_EVT: Loading system/gd/os/system_properties.h +4 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,10 @@ namespace bluetooth { namespace os { /* System Property to indicate if the dual mode audio feature is enabled */ static const std::string kIsDualModeAudioEnabledProperty = "persist.bluetooth.enable_dual_mode_audio"; // Get |property| keyed system property from supported platform, return std::nullopt if the property does not exist // or if the platform does not support system property std::optional<std::string> GetSystemProperty(const std::string& property); Loading Loading
system/bta/ag/bta_ag_act.cc +10 −0 Original line number Diff line number Diff line Loading @@ -29,8 +29,14 @@ #include "bta/ag/bta_ag_int.h" #include "bta/include/bta_dm_api.h" #ifdef OS_ANDROID #include "bta/le_audio/devices.h" #endif #include "btif/include/btif_config.h" #include "device/include/device_iot_config.h" #include "os/system_properties.h" #include "osi/include/osi.h" // UNUSED_ATTR #include "stack/include/l2c_api.h" #include "stack/include/port_api.h" Loading Loading @@ -760,6 +766,10 @@ void bta_ag_post_sco_close(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data) { if (bta_ag_inband_enabled(p_scb) && !(p_scb->features & BTA_AG_FEAT_NOSCO)) { p_scb->post_sco = BTA_AG_POST_SCO_RING; if (!bta_ag_is_sco_open_allowed(p_scb, "BTA_AG_POST_SCO_CALL_END_INCALL")) { break; } bta_ag_sco_open(p_scb, data); } else { p_scb->post_sco = BTA_AG_POST_SCO_NONE; Loading
system/bta/ag/bta_ag_cmd.cc +77 −2 Original line number Diff line number Diff line Loading @@ -27,7 +27,13 @@ #include "bta/ag/bta_ag_int.h" #include "bta/include/bta_ag_api.h" #include "bta/include/utl.h" #ifdef OS_ANDROID #include "bta/le_audio/devices.h" #endif #include "device/include/interop.h" #include "os/system_properties.h" #include "osi/include/compat.h" #include "osi/include/log.h" #include "osi/include/osi.h" // UNUSED_ATTR Loading Loading @@ -1317,11 +1323,18 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB* p_scb, uint16_t cmd, uint8_t arg_type, } case BTA_AG_LOCAL_EVT_BCC: { if (!bta_ag_sco_is_active_device(p_scb->peer_addr)) { LOG(WARNING) << __func__ << ": AT+BCC rejected as " << p_scb->peer_addr << " is not the active device"; LOG_WARN( "NOT opening SCO for EVT %s as %s is not the active HFP device", "BTA_AG_LOCAL_EVT_BCC", p_scb->peer_addr.ToStringForLogging().c_str()); bta_ag_send_error(p_scb, BTA_AG_ERR_OP_NOT_ALLOWED); break; } if (!bta_ag_is_sco_open_allowed(p_scb, "BTA_AG_LOCAL_EVT_BCC")) { bta_ag_send_error(p_scb, BTA_AG_ERR_OP_NOT_ALLOWED); break; } bta_ag_send_ok(p_scb); bta_ag_sco_open(p_scb, tBTA_AG_DATA::kEmpty); break; Loading Loading @@ -1404,6 +1417,11 @@ static void bta_ag_hsp_result(tBTA_AG_SCB* p_scb, } else { p_scb->post_sco = BTA_AG_POST_SCO_RING; } if (!bta_ag_is_sco_open_allowed(p_scb, bta_ag_result_text(result.result))) { break; } bta_ag_sco_open(p_scb, tBTA_AG_DATA::kEmpty); } break; Loading @@ -1419,6 +1437,10 @@ static void bta_ag_hsp_result(tBTA_AG_SCB* p_scb, /* if audio connected to this scb AND sco is not opened, open sco */ if (result.data.audio_handle == bta_ag_scb_to_idx(p_scb) && !bta_ag_sco_is_open(p_scb)) { if (!bta_ag_is_sco_open_allowed(p_scb, bta_ag_result_text(result.result))) { break; } bta_ag_sco_open(p_scb, tBTA_AG_DATA::kEmpty); } else if (result.data.audio_handle == BTA_AG_HANDLE_NONE && bta_ag_sco_is_open(p_scb)) { Loading Loading @@ -1508,6 +1530,11 @@ static void bta_ag_hfp_result(tBTA_AG_SCB* p_scb, } else { /* else open sco, send ring after sco opened */ p_scb->post_sco = BTA_AG_POST_SCO_RING; if (!bta_ag_is_sco_open_allowed(p_scb, bta_ag_result_text(result.result))) { break; } bta_ag_sco_open(p_scb, tBTA_AG_DATA::kEmpty); } } Loading @@ -1524,6 +1551,10 @@ static void bta_ag_hfp_result(tBTA_AG_SCB* p_scb, if (!(p_scb->features & BTA_AG_FEAT_NOSCO)) { if (result.data.audio_handle == bta_ag_scb_to_idx(p_scb) && !bta_ag_sco_is_open(p_scb)) { if (!bta_ag_is_sco_open_allowed(p_scb, bta_ag_result_text(result.result))) { break; } bta_ag_sco_open(p_scb, tBTA_AG_DATA::kEmpty); } else if ((result.data.audio_handle == BTA_AG_HANDLE_NONE) && bta_ag_sco_is_open(p_scb)) { Loading @@ -1543,6 +1574,10 @@ static void bta_ag_hfp_result(tBTA_AG_SCB* p_scb, bta_ag_send_call_inds(p_scb, result.result); if (result.data.audio_handle == bta_ag_scb_to_idx(p_scb) && !(p_scb->features & BTA_AG_FEAT_NOSCO)) { if (!bta_ag_is_sco_open_allowed(p_scb, bta_ag_result_text(result.result))) { break; } bta_ag_sco_open(p_scb, tBTA_AG_DATA::kEmpty); } break; Loading @@ -1552,6 +1587,10 @@ static void bta_ag_hfp_result(tBTA_AG_SCB* p_scb, bta_ag_send_call_inds(p_scb, result.result); if (result.data.audio_handle == bta_ag_scb_to_idx(p_scb) && !(p_scb->features & BTA_AG_FEAT_NOSCO)) { if (!bta_ag_is_sco_open_allowed(p_scb, bta_ag_result_text(result.result))) { break; } bta_ag_sco_open(p_scb, tBTA_AG_DATA::kEmpty); } break; Loading @@ -1561,6 +1600,10 @@ static void bta_ag_hfp_result(tBTA_AG_SCB* p_scb, APPL_TRACE_DEBUG("Headset Connected in three way call"); if (!(p_scb->features & BTA_AG_FEAT_NOSCO)) { if (result.data.audio_handle == bta_ag_scb_to_idx(p_scb)) { if (!bta_ag_is_sco_open_allowed(p_scb, bta_ag_result_text(result.result))) { break; } bta_ag_sco_open(p_scb, tBTA_AG_DATA::kEmpty); } else if (result.data.audio_handle == BTA_AG_HANDLE_NONE) { bta_ag_sco_close(p_scb, tBTA_AG_DATA::kEmpty); Loading @@ -1575,6 +1618,10 @@ static void bta_ag_hfp_result(tBTA_AG_SCB* p_scb, /* open or close sco */ if (!(p_scb->features & BTA_AG_FEAT_NOSCO)) { if (result.data.audio_handle == bta_ag_scb_to_idx(p_scb)) { if (!bta_ag_is_sco_open_allowed(p_scb, bta_ag_result_text(result.result))) { break; } bta_ag_sco_open(p_scb, tBTA_AG_DATA::kEmpty); } else if (result.data.audio_handle == BTA_AG_HANDLE_NONE) { bta_ag_sco_close(p_scb, tBTA_AG_DATA::kEmpty); Loading Loading @@ -1803,6 +1850,34 @@ void bta_ag_send_bcs(tBTA_AG_SCB* p_scb) { bta_ag_send_result(p_scb, BTA_AG_LOCAL_RES_BCS, nullptr, codec_uuid); } /******************************************************************************* * * Function bta_ag_is_sco_open_allowed * * Description Check if we can open SCO from the BT stack * * Returns true if we can, false if not * ******************************************************************************/ bool bta_ag_is_sco_open_allowed(tBTA_AG_SCB* p_scb, const std::string event) { #ifdef OS_ANDROID /* Do not open SCO if 1. the dual mode audio system property is enabled, 2. LEA is active, and 3. LEA is preferred for DUPLEX */ if (bluetooth::os::GetSystemPropertyBool( bluetooth::os::kIsDualModeAudioEnabledProperty, false)) { if (LeAudioClient::Get()->isDuplexPreferenceLeAudio(p_scb->peer_addr)) { LOG_INFO("NOT opening SCO for EVT %s on dual mode device %s", event.c_str(), p_scb->peer_addr.ToStringForLogging().c_str()); return false; } else { LOG_INFO("Opening SCO for EVT %s on dual mode device %s", event.c_str(), p_scb->peer_addr.ToStringForLogging().c_str()); } } #endif return true; } /******************************************************************************* * * Function bta_ag_send_ring Loading
system/bta/ag/bta_ag_int.h +2 −0 Original line number Diff line number Diff line Loading @@ -418,6 +418,8 @@ extern void bta_ag_handle_collision(tBTA_AG_SCB* p_scb, /* Internal utility functions */ extern void bta_ag_sco_codec_nego(tBTA_AG_SCB* p_scb, bool result); extern void bta_ag_codec_negotiate(tBTA_AG_SCB* p_scb); extern bool bta_ag_is_sco_open_allowed(tBTA_AG_SCB* p_scb, const std::string event); extern void bta_ag_send_bcs(tBTA_AG_SCB* p_scb); extern void bta_ag_set_sco_offload_enabled(bool value); extern void bta_ag_set_sco_allowed(bool value); Loading
system/bta/ag/bta_ag_main.cc +4 −0 Original line number Diff line number Diff line Loading @@ -560,6 +560,7 @@ static void bta_ag_better_state_machine(tBTA_AG_SCB* p_scb, uint16_t event, bta_ag_sco_listen(p_scb, data); break; case BTA_AG_SCO_OPEN_EVT: LOG_INFO("Opening sco for EVT BTA_AG_SCO_OPEN_EVT"); bta_ag_sco_conn_open(p_scb, data); break; case BTA_AG_SCO_CLOSE_EVT: Loading Loading @@ -597,6 +598,7 @@ static void bta_ag_better_state_machine(tBTA_AG_SCB* p_scb, uint16_t event, bta_ag_rfc_fail(p_scb, data); break; case BTA_AG_SCO_OPEN_EVT: LOG_INFO("Opening sco for EVT BTA_AG_SCO_OPEN_EVT"); bta_ag_sco_conn_open(p_scb, data); break; case BTA_AG_SCO_CLOSE_EVT: Loading Loading @@ -655,6 +657,7 @@ static void bta_ag_better_state_machine(tBTA_AG_SCB* p_scb, uint16_t event, bta_ag_rfc_data(p_scb, data); break; case BTA_AG_SCO_OPEN_EVT: LOG_INFO("Opening sco for EVT BTA_AG_SCO_OPEN_EVT"); bta_ag_sco_conn_open(p_scb, data); bta_ag_post_sco_open(p_scb, data); break; Loading Loading @@ -690,6 +693,7 @@ static void bta_ag_better_state_machine(tBTA_AG_SCB* p_scb, uint16_t event, bta_ag_rfc_close(p_scb, data); break; case BTA_AG_SCO_OPEN_EVT: LOG_INFO("Opening sco for EVT BTA_AG_SCO_OPEN_EVT"); bta_ag_sco_conn_open(p_scb, data); break; case BTA_AG_SCO_CLOSE_EVT: Loading
system/gd/os/system_properties.h +4 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,10 @@ namespace bluetooth { namespace os { /* System Property to indicate if the dual mode audio feature is enabled */ static const std::string kIsDualModeAudioEnabledProperty = "persist.bluetooth.enable_dual_mode_audio"; // Get |property| keyed system property from supported platform, return std::nullopt if the property does not exist // or if the platform does not support system property std::optional<std::string> GetSystemProperty(const std::string& property); Loading