if (bta_ag_sco_is_open(p_scb) || !bta_ag_inband_enabled(p_scb) ||
(p_scb->features & BTA_AG_FEAT_NOSCO)) {
bta_ag_send_ring(p_scb, (tBTA_AG_DATA*)p_result);
- }
- /* else open sco, send ring after sco opened */
- else {
+ } else {
+ /* else open sco, send ring after sco opened */
/* HSPv1.2: AG shall not send RING if using in-band ring tone. */
- if (p_scb->hsp_version >= HSP_VERSION_1_2)
+ if (p_scb->hsp_version >= HSP_VERSION_1_2) {
p_scb->post_sco = BTA_AG_POST_SCO_NONE;
- else
+ } else {
p_scb->post_sco = BTA_AG_POST_SCO_RING;
-
+ }
bta_ag_sco_open(p_scb, (tBTA_AG_DATA*)p_result);
}
break;
}
if (!(p_scb->features & BTA_AG_FEAT_NOSCO)) {
- /* if audio connected to this scb open sco */
- if (p_result->data.audio_handle == bta_ag_scb_to_idx(p_scb)) {
+ /* if audio connected to this scb AND sco is not opened, open sco */
+ if (p_result->data.audio_handle == bta_ag_scb_to_idx(p_scb) &&
+ !bta_ag_sco_is_open(p_scb)) {
bta_ag_sco_open(p_scb, (tBTA_AG_DATA*)p_result);
}
/* else if no audio at call close sco */
- else if (p_result->data.audio_handle == BTA_AG_HANDLE_NONE) {
+ else if (p_result->data.audio_handle == BTA_AG_HANDLE_NONE &&
+ bta_ag_sco_is_open(p_scb)) {
bta_ag_sco_close(p_scb, (tBTA_AG_DATA*)p_result);
}
}
if (bta_ag_sco_is_open(p_scb) || !bta_ag_inband_enabled(p_scb) ||
(p_scb->features & BTA_AG_FEAT_NOSCO)) {
bta_ag_send_ring(p_scb, (tBTA_AG_DATA*)p_result);
- }
- /* else open sco, send ring after sco opened */
- else {
+ } else {
+ /* else open sco, send ring after sco opened */
p_scb->post_sco = BTA_AG_POST_SCO_RING;
bta_ag_sco_open(p_scb, (tBTA_AG_DATA*)p_result);
}
bta_ag_send_call_inds(p_scb, p_result->result);
if (!(p_scb->features & BTA_AG_FEAT_NOSCO)) {
- if (p_result->data.audio_handle == bta_ag_scb_to_idx(p_scb)) {
+ if (p_result->data.audio_handle == bta_ag_scb_to_idx(p_scb) &&
+ !bta_ag_sco_is_open(p_scb)) {
bta_ag_sco_open(p_scb, (tBTA_AG_DATA*)p_result);
} else if ((p_result->data.audio_handle == BTA_AG_HANDLE_NONE) &&
bta_ag_sco_is_open(p_scb)) {
#include "btif_hf.h"
#include "btif_profile_queue.h"
#include "btif_util.h"
+#include "osi/include/properties.h"
/*******************************************************************************
* Constants & Macros
#endif
#endif
+/* HF features supported at runtime */
+static uint32_t btif_hf_features = BTIF_HF_FEATURES;
+
#define BTIF_HF_CALL_END_TIMEOUT 6
#define BTIF_HF_INVALID_IDX (-1)
}
}
+static bool inband_ringing_property_enabled() {
+ char inband_ringing_flag[PROPERTY_VALUE_MAX] = {0};
+ osi_property_get("persist.bluetooth.enableinbandringing", inband_ringing_flag,
+ "false");
+ if (strncmp(inband_ringing_flag, "true", 4) == 0) {
+ BTIF_TRACE_DEBUG("%s: In-band ringing enabled by property", __func__);
+ return true;
+ }
+ return false;
+}
+
/*******************************************************************************
*
* Function btif_hf_init
* Returns bt_status_t
*
******************************************************************************/
-static bt_status_t init(bthf_callbacks_t* callbacks, int max_hf_clients) {
+static bt_status_t init(bthf_callbacks_t* callbacks, int max_hf_clients,
+ bool inband_ringing_supported) {
+ bool inband_ringing_property_enable = inband_ringing_property_enabled();
+ if (inband_ringing_supported && inband_ringing_property_enable) {
+ btif_hf_features |= BTA_AG_FEAT_INBAND;
+ } else {
+ btif_hf_features &= ~BTA_AG_FEAT_INBAND;
+ }
btif_max_hf_clients = max_hf_clients;
- BTIF_TRACE_DEBUG("%s - max_hf_clients=%d", __func__, btif_max_hf_clients);
-
+ BTIF_TRACE_DEBUG(
+ "%s: btif_hf_features=%zu, max_hf_clients=%d, "
+ "inband_ringing=[supported=%d, enabled=%d]",
+ __func__, btif_hf_features, btif_max_hf_clients, inband_ringing_supported,
+ inband_ringing_property_enable);
bt_hf_callbacks = callbacks;
memset(&btif_hf_cb, 0, sizeof(btif_hf_cb));
} break;
case BTHF_CALL_STATE_INCOMING:
- if (num_active || num_held)
+ if (num_active || num_held) {
res = BTA_AG_CALL_WAIT_RES;
- else
+ } else {
res = BTA_AG_IN_CALL_RES;
+ }
if (number) {
int xx = 0;
if ((type == BTHF_CALL_ADDRTYPE_INTERNATIONAL) && (*number != '+'))
/* Enable and register with BTA-AG */
BTA_AgEnable(BTA_AG_PARSE, bte_hf_evt);
for (i = 0; i < btif_max_hf_clients; i++) {
- BTA_AgRegister(BTIF_HF_SERVICES, BTIF_HF_SECURITY, BTIF_HF_FEATURES,
+ BTA_AgRegister(BTIF_HF_SERVICES, BTIF_HF_SECURITY, btif_hf_features,
p_service_names, bthf_hf_id[i]);
}
} else {