aboutsummaryrefslogtreecommitdiff
path: root/bta/hf_client/bta_hf_client_main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'bta/hf_client/bta_hf_client_main.cc')
-rw-r--r--bta/hf_client/bta_hf_client_main.cc59
1 files changed, 39 insertions, 20 deletions
diff --git a/bta/hf_client/bta_hf_client_main.cc b/bta/hf_client/bta_hf_client_main.cc
index fac61c78a..902af1323 100644
--- a/bta/hf_client/bta_hf_client_main.cc
+++ b/bta/hf_client/bta_hf_client_main.cc
@@ -17,19 +17,14 @@
*
******************************************************************************/
-#include <base/logging.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "bt_utils.h"
-#include "bta_api.h"
-#include "bta_hf_client_api.h"
-#include "bta_hf_client_int.h"
-#include "bta_sys.h"
-#include "osi/include/osi.h"
-#include "osi/include/properties.h"
-#include "utl.h"
+#include <cstdint>
+#include <cstdio>
+
+#include "bta/hf_client/bta_hf_client_int.h"
+#include "bta/include/utl.h"
+#include "osi/include/allocator.h"
+#include "osi/include/osi.h" // UNUSED_ATTR
+#include "stack/include/btm_api.h"
static const char* bta_hf_client_evt_str(uint16_t event);
static const char* bta_hf_client_state_str(uint8_t state);
@@ -302,8 +297,13 @@ void bta_hf_client_cb_init(tBTA_HF_CLIENT_CB* client_cb, uint16_t handle) {
// Free any memory we need to explicity release
alarm_free(client_cb->collision_timer);
+ // release unique pointers
+ client_cb->enabled_hf_indicators.clear();
+ client_cb->peer_hf_indicators.clear();
+
// Memset the rest of the block
- memset(client_cb, 0, sizeof(tBTA_HF_CLIENT_CB));
+ // memset(client_cb, 0, sizeof(tBTA_HF_CLIENT_CB));
+ *client_cb = {};
// Re allocate any variables required
client_cb->collision_timer = alarm_new("bta_hf_client.scb_collision_timer");
@@ -330,7 +330,6 @@ void bta_hf_client_resume_open(tBTA_HF_CLIENT_CB* client_cb) {
tBTA_HF_CLIENT_DATA msg;
msg.hdr.layer_specific = client_cb->handle;
msg.api_open.bd_addr = client_cb->peer_addr;
- msg.api_open.sec_mask = client_cb->cli_sec_mask;
bta_hf_client_start_open(&msg);
}
}
@@ -408,7 +407,6 @@ void bta_hf_client_collision_cback(UNUSED_ATTR tBTA_SYS_CONN_STATUS status,
*
******************************************************************************/
tBTA_STATUS bta_hf_client_api_enable(tBTA_HF_CLIENT_CBACK* p_cback,
- tBTA_SEC sec_mask,
tBTA_HF_CLIENT_FEAT features,
const char* p_service_name) {
/* If already registered then return error */
@@ -424,7 +422,6 @@ tBTA_STATUS bta_hf_client_api_enable(tBTA_HF_CLIENT_CBACK* p_cback,
bta_hf_client_cb_arr_init();
bta_hf_client_cb_arr.p_cback = p_cback;
- bta_hf_client_cb_arr.serv_sec_mask = sec_mask;
bta_hf_client_cb_arr.features = features;
/* create SDP records */
@@ -678,7 +675,7 @@ void bta_hf_client_api_disable() {
* Returns bool
*
******************************************************************************/
-bool bta_hf_client_hdl_event(BT_HDR* p_msg) {
+bool bta_hf_client_hdl_event(BT_HDR_RIGID* p_msg) {
APPL_TRACE_DEBUG("%s: %s (0x%x)", __func__,
bta_hf_client_evt_str(p_msg->event), p_msg->event);
bta_hf_client_sm_execute(p_msg->event, (tBTA_HF_CLIENT_DATA*)p_msg);
@@ -842,6 +839,9 @@ void bta_hf_client_slc_seq(tBTA_HF_CLIENT_CB* client_cb, bool error) {
if (client_cb->peer_features & BTA_HF_CLIENT_PEER_FEAT_3WAY &&
bta_hf_client_cb_arr.features & BTA_HF_CLIENT_FEAT_3WAY) {
bta_hf_client_send_at_chld(client_cb, '?', 0);
+ } else if (bta_hf_client_cb_arr.features & BTA_HF_CLIENT_FEAT_HF_IND &&
+ client_cb->peer_features & BTA_HF_CLIENT_PEER_HF_IND) {
+ bta_hf_client_send_at_bind(client_cb, 0);
} else {
tBTA_HF_CLIENT_DATA msg;
msg.hdr.layer_specific = client_cb->handle;
@@ -850,13 +850,32 @@ void bta_hf_client_slc_seq(tBTA_HF_CLIENT_CB* client_cb, bool error) {
}
break;
- case BTA_HF_CLIENT_AT_CHLD: {
+ case BTA_HF_CLIENT_AT_CHLD:
+ if (bta_hf_client_cb_arr.features & BTA_HF_CLIENT_FEAT_HF_IND &&
+ client_cb->peer_features & BTA_HF_CLIENT_PEER_HF_IND) {
+ bta_hf_client_send_at_bind(client_cb, 0);
+ } else {
+ tBTA_HF_CLIENT_DATA msg;
+ msg.hdr.layer_specific = client_cb->handle;
+ bta_hf_client_svc_conn_open(&msg);
+ send_post_slc_cmd(client_cb);
+ }
+ break;
+
+ case BTA_HF_CLIENT_AT_BIND_SET_IND:
+ bta_hf_client_send_at_bind(client_cb, 1);
+ break;
+
+ case BTA_HF_CLIENT_AT_BIND_READ_SUPPORTED_IND:
+ bta_hf_client_send_at_bind(client_cb, 2);
+ break;
+
+ case BTA_HF_CLIENT_AT_BIND_READ_ENABLED_IND:
tBTA_HF_CLIENT_DATA msg;
msg.hdr.layer_specific = client_cb->handle;
bta_hf_client_svc_conn_open(&msg);
send_post_slc_cmd(client_cb);
break;
- }
default: {
/* If happen there is a bug in SLC creation procedure... */