system/bt
Revision | 9cb269c25be642526c4152ed7c14158300f28969 (tree) |
---|---|
Zeit | 2017-04-13 07:23:46 |
Autor | Jack He <siyuanh@goog...> |
Commiter | Jack He |
Add support for inband ringing feature
* Change HFP init API so that the HFP feature bit field depends on
* Feature disabled by default unless system property enables it
Bug: 19171297
Test: mm -j 40, HFP regression test, testplans/82144
Change-Id: Ib8ba28ac6e70eb23b2a2ad11c5805793911a4e43
(cherry picked from commit 7a9892c63bad8f8d93681fb74d5532a79387b60e)
@@ -1316,15 +1316,14 @@ void bta_ag_hsp_result(tBTA_AG_SCB* p_scb, tBTA_AG_API_RESULT* p_result) { | ||
1316 | 1316 | if (bta_ag_sco_is_open(p_scb) || !bta_ag_inband_enabled(p_scb) || |
1317 | 1317 | (p_scb->features & BTA_AG_FEAT_NOSCO)) { |
1318 | 1318 | bta_ag_send_ring(p_scb, (tBTA_AG_DATA*)p_result); |
1319 | - } | |
1320 | - /* else open sco, send ring after sco opened */ | |
1321 | - else { | |
1319 | + } else { | |
1320 | + /* else open sco, send ring after sco opened */ | |
1322 | 1321 | /* HSPv1.2: AG shall not send RING if using in-band ring tone. */ |
1323 | - if (p_scb->hsp_version >= HSP_VERSION_1_2) | |
1322 | + if (p_scb->hsp_version >= HSP_VERSION_1_2) { | |
1324 | 1323 | p_scb->post_sco = BTA_AG_POST_SCO_NONE; |
1325 | - else | |
1324 | + } else { | |
1326 | 1325 | p_scb->post_sco = BTA_AG_POST_SCO_RING; |
1327 | - | |
1326 | + } | |
1328 | 1327 | bta_ag_sco_open(p_scb, (tBTA_AG_DATA*)p_result); |
1329 | 1328 | } |
1330 | 1329 | break; |
@@ -1337,12 +1336,14 @@ void bta_ag_hsp_result(tBTA_AG_SCB* p_scb, tBTA_AG_API_RESULT* p_result) { | ||
1337 | 1336 | } |
1338 | 1337 | |
1339 | 1338 | if (!(p_scb->features & BTA_AG_FEAT_NOSCO)) { |
1340 | - /* if audio connected to this scb open sco */ | |
1341 | - if (p_result->data.audio_handle == bta_ag_scb_to_idx(p_scb)) { | |
1339 | + /* if audio connected to this scb AND sco is not opened, open sco */ | |
1340 | + if (p_result->data.audio_handle == bta_ag_scb_to_idx(p_scb) && | |
1341 | + !bta_ag_sco_is_open(p_scb)) { | |
1342 | 1342 | bta_ag_sco_open(p_scb, (tBTA_AG_DATA*)p_result); |
1343 | 1343 | } |
1344 | 1344 | /* else if no audio at call close sco */ |
1345 | - else if (p_result->data.audio_handle == BTA_AG_HANDLE_NONE) { | |
1345 | + else if (p_result->data.audio_handle == BTA_AG_HANDLE_NONE && | |
1346 | + bta_ag_sco_is_open(p_scb)) { | |
1346 | 1347 | bta_ag_sco_close(p_scb, (tBTA_AG_DATA*)p_result); |
1347 | 1348 | } |
1348 | 1349 | } |
@@ -1435,9 +1436,8 @@ void bta_ag_hfp_result(tBTA_AG_SCB* p_scb, tBTA_AG_API_RESULT* p_result) { | ||
1435 | 1436 | if (bta_ag_sco_is_open(p_scb) || !bta_ag_inband_enabled(p_scb) || |
1436 | 1437 | (p_scb->features & BTA_AG_FEAT_NOSCO)) { |
1437 | 1438 | bta_ag_send_ring(p_scb, (tBTA_AG_DATA*)p_result); |
1438 | - } | |
1439 | - /* else open sco, send ring after sco opened */ | |
1440 | - else { | |
1439 | + } else { | |
1440 | + /* else open sco, send ring after sco opened */ | |
1441 | 1441 | p_scb->post_sco = BTA_AG_POST_SCO_RING; |
1442 | 1442 | bta_ag_sco_open(p_scb, (tBTA_AG_DATA*)p_result); |
1443 | 1443 | } |
@@ -1453,7 +1453,8 @@ void bta_ag_hfp_result(tBTA_AG_SCB* p_scb, tBTA_AG_API_RESULT* p_result) { | ||
1453 | 1453 | bta_ag_send_call_inds(p_scb, p_result->result); |
1454 | 1454 | |
1455 | 1455 | if (!(p_scb->features & BTA_AG_FEAT_NOSCO)) { |
1456 | - if (p_result->data.audio_handle == bta_ag_scb_to_idx(p_scb)) { | |
1456 | + if (p_result->data.audio_handle == bta_ag_scb_to_idx(p_scb) && | |
1457 | + !bta_ag_sco_is_open(p_scb)) { | |
1457 | 1458 | bta_ag_sco_open(p_scb, (tBTA_AG_DATA*)p_result); |
1458 | 1459 | } else if ((p_result->data.audio_handle == BTA_AG_HANDLE_NONE) && |
1459 | 1460 | bta_ag_sco_is_open(p_scb)) { |
@@ -41,6 +41,7 @@ | ||
41 | 41 | #include "btif_hf.h" |
42 | 42 | #include "btif_profile_queue.h" |
43 | 43 | #include "btif_util.h" |
44 | +#include "osi/include/properties.h" | |
44 | 45 | |
45 | 46 | /******************************************************************************* |
46 | 47 | * Constants & Macros |
@@ -84,6 +85,9 @@ | ||
84 | 85 | #endif |
85 | 86 | #endif |
86 | 87 | |
88 | +/* HF features supported at runtime */ | |
89 | +static uint32_t btif_hf_features = BTIF_HF_FEATURES; | |
90 | + | |
87 | 91 | #define BTIF_HF_CALL_END_TIMEOUT 6 |
88 | 92 | |
89 | 93 | #define BTIF_HF_INVALID_IDX (-1) |
@@ -671,6 +675,17 @@ static void btif_in_hf_generic_evt(uint16_t event, char* p_param) { | ||
671 | 675 | } |
672 | 676 | } |
673 | 677 | |
678 | +static bool inband_ringing_property_enabled() { | |
679 | + char inband_ringing_flag[PROPERTY_VALUE_MAX] = {0}; | |
680 | + osi_property_get("persist.bluetooth.enableinbandringing", inband_ringing_flag, | |
681 | + "false"); | |
682 | + if (strncmp(inband_ringing_flag, "true", 4) == 0) { | |
683 | + BTIF_TRACE_DEBUG("%s: In-band ringing enabled by property", __func__); | |
684 | + return true; | |
685 | + } | |
686 | + return false; | |
687 | +} | |
688 | + | |
674 | 689 | /******************************************************************************* |
675 | 690 | * |
676 | 691 | * Function btif_hf_init |
@@ -680,10 +695,20 @@ static void btif_in_hf_generic_evt(uint16_t event, char* p_param) { | ||
680 | 695 | * Returns bt_status_t |
681 | 696 | * |
682 | 697 | ******************************************************************************/ |
683 | -static bt_status_t init(bthf_callbacks_t* callbacks, int max_hf_clients) { | |
698 | +static bt_status_t init(bthf_callbacks_t* callbacks, int max_hf_clients, | |
699 | + bool inband_ringing_supported) { | |
700 | + bool inband_ringing_property_enable = inband_ringing_property_enabled(); | |
701 | + if (inband_ringing_supported && inband_ringing_property_enable) { | |
702 | + btif_hf_features |= BTA_AG_FEAT_INBAND; | |
703 | + } else { | |
704 | + btif_hf_features &= ~BTA_AG_FEAT_INBAND; | |
705 | + } | |
684 | 706 | btif_max_hf_clients = max_hf_clients; |
685 | - BTIF_TRACE_DEBUG("%s - max_hf_clients=%d", __func__, btif_max_hf_clients); | |
686 | - | |
707 | + BTIF_TRACE_DEBUG( | |
708 | + "%s: btif_hf_features=%zu, max_hf_clients=%d, " | |
709 | + "inband_ringing=[supported=%d, enabled=%d]", | |
710 | + __func__, btif_hf_features, btif_max_hf_clients, inband_ringing_supported, | |
711 | + inband_ringing_property_enable); | |
687 | 712 | bt_hf_callbacks = callbacks; |
688 | 713 | memset(&btif_hf_cb, 0, sizeof(btif_hf_cb)); |
689 | 714 |
@@ -1331,10 +1356,11 @@ static bt_status_t phone_state_change(int num_active, int num_held, | ||
1331 | 1356 | } break; |
1332 | 1357 | |
1333 | 1358 | case BTHF_CALL_STATE_INCOMING: |
1334 | - if (num_active || num_held) | |
1359 | + if (num_active || num_held) { | |
1335 | 1360 | res = BTA_AG_CALL_WAIT_RES; |
1336 | - else | |
1361 | + } else { | |
1337 | 1362 | res = BTA_AG_IN_CALL_RES; |
1363 | + } | |
1338 | 1364 | if (number) { |
1339 | 1365 | int xx = 0; |
1340 | 1366 | if ((type == BTHF_CALL_ADDRTYPE_INTERNATIONAL) && (*number != '+')) |
@@ -1560,7 +1586,7 @@ bt_status_t btif_hf_execute_service(bool b_enable) { | ||
1560 | 1586 | /* Enable and register with BTA-AG */ |
1561 | 1587 | BTA_AgEnable(BTA_AG_PARSE, bte_hf_evt); |
1562 | 1588 | for (i = 0; i < btif_max_hf_clients; i++) { |
1563 | - BTA_AgRegister(BTIF_HF_SERVICES, BTIF_HF_SECURITY, BTIF_HF_FEATURES, | |
1589 | + BTA_AgRegister(BTIF_HF_SERVICES, BTIF_HF_SECURITY, btif_hf_features, | |
1564 | 1590 | p_service_names, bthf_hf_id[i]); |
1565 | 1591 | } |
1566 | 1592 | } else { |