1 /****************************************************************************** 2 * 3 * Copyright 2003-2012 Broadcom Corporation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 /****************************************************************************** 20 * 21 * This is the private interface file for the BTA audio gateway. 22 * 23 ******************************************************************************/ 24 #ifndef BTA_AG_INT_H 25 #define BTA_AG_INT_H 26 27 #include <bluetooth/log.h> 28 29 #include <cstdint> 30 #include <string> 31 32 #include "bta/ag/bta_ag_at.h" 33 #include "bta/include/bta_ag_api.h" 34 #include "bta/include/bta_api.h" 35 #include "bta/sys/bta_sys.h" 36 #include "internal_include/bt_target.h" 37 #include "stack/include/bt_hdr.h" 38 #include "stack/include/btm_api_types.h" 39 #include "stack/sdp/sdp_discovery_db.h" 40 #include "types/raw_address.h" 41 42 /***************************************************************************** 43 * Constants 44 ****************************************************************************/ 45 /* Time to wait for retry in case of collision */ 46 #ifndef BTA_AG_COLLISION_TIMEOUT_MS 47 #define BTA_AG_COLLISION_TIMEOUT_MS (2 * 1000) /* 2 seconds */ 48 #endif 49 50 /* RFCOMM MTU SIZE */ 51 #define BTA_AG_MTU 256 52 53 /* Max number of peer and local HF indicators */ 54 #define BTA_AG_MAX_NUM_PEER_HF_IND 20 55 #define BTA_AG_MAX_NUM_LOCAL_HF_IND 4 56 57 /* Internal profile indexes */ 58 #define BTA_AG_HSP 0 /* index for HSP */ 59 #define BTA_AG_HFP 1 /* index for HFP */ 60 #define BTA_AG_NUM_IDX 2 /* number of profile indexes */ 61 62 /* profile role for connection */ 63 #define BTA_AG_ACP 0 /* accepted connection */ 64 #define BTA_AG_INT 1 /* initiating connection */ 65 66 #define BTA_AG_SDP_FEAT_SPEC \ 67 (BTA_AG_FEAT_3WAY | BTA_AG_FEAT_ECNR | BTA_AG_FEAT_VREC | \ 68 BTA_AG_FEAT_INBAND | BTA_AG_FEAT_VTAG) 69 70 /* Timeout for alarm in 2018 toyota camry carkit workaround */ 71 #define BTA_AG_BIND_TIMEOUT_MS 500 72 73 enum { 74 /* these events are handled by the state machine */ 75 BTA_AG_API_REGISTER_EVT = BTA_SYS_EVT_START(BTA_ID_AG), 76 BTA_AG_API_DEREGISTER_EVT, 77 BTA_AG_API_OPEN_EVT, 78 BTA_AG_API_CLOSE_EVT, 79 BTA_AG_API_AUDIO_OPEN_EVT, 80 BTA_AG_API_AUDIO_CLOSE_EVT, 81 BTA_AG_API_RESULT_EVT, 82 BTA_AG_API_SETCODEC_EVT, 83 BTA_AG_RFC_OPEN_EVT, 84 BTA_AG_RFC_CLOSE_EVT, 85 BTA_AG_RFC_SRV_CLOSE_EVT, 86 BTA_AG_RFC_DATA_EVT, 87 BTA_AG_SCO_OPEN_EVT, 88 BTA_AG_SCO_CLOSE_EVT, 89 BTA_AG_DISC_ACP_RES_EVT, 90 BTA_AG_DISC_INT_RES_EVT, 91 BTA_AG_DISC_OK_EVT, 92 BTA_AG_DISC_FAIL_EVT, 93 BTA_AG_RING_TIMEOUT_EVT, 94 BTA_AG_SVC_TIMEOUT_EVT, 95 BTA_AG_COLLISION_EVT, 96 BTA_AG_MAX_EVT, 97 }; 98 99 /* Local events which will not trigger a higher layer callback */ 100 enum { 101 BTA_AG_LOCAL_EVT_FIRST = 0x100, 102 BTA_AG_LOCAL_EVT_CCWA, 103 BTA_AG_LOCAL_EVT_CLIP, 104 BTA_AG_LOCAL_EVT_CMER, 105 BTA_AG_LOCAL_EVT_BRSF, 106 BTA_AG_LOCAL_EVT_CMEE, 107 BTA_AG_LOCAL_EVT_BCC, 108 }; 109 110 /* Actions to perform after a SCO event */ 111 enum { 112 BTA_AG_POST_SCO_NONE, /* no action */ 113 BTA_AG_POST_SCO_CLOSE_RFC, /* close RFCOMM channel after SCO closes */ 114 BTA_AG_POST_SCO_RING, /* send RING result code after SCO opens */ 115 BTA_AG_POST_SCO_CALL_CONN, /* send call indicators after SCO opens/closes */ 116 BTA_AG_POST_SCO_CALL_ORIG, /* send call indicators after SCO closes */ 117 BTA_AG_POST_SCO_CALL_END, /* send call indicators after SCO closes */ 118 BTA_AG_POST_SCO_CALL_END_INCALL /* send call indicators for end call & 119 incoming call after SCO closes */ 120 }; 121 122 /* sco states */ 123 typedef enum : uint8_t { 124 BTA_AG_SCO_SHUTDOWN_ST, /* no sco listening, all sco connections closed */ 125 BTA_AG_SCO_LISTEN_ST, /* sco listening */ 126 BTA_AG_SCO_CODEC_ST, /* sco codec negotiation */ 127 BTA_AG_SCO_OPENING_ST, /* sco connection opening */ 128 BTA_AG_SCO_OPEN_CL_ST, /* opening sco connection being closed */ 129 BTA_AG_SCO_OPEN_XFER_ST, /* opening sco connection being transferred */ 130 BTA_AG_SCO_OPEN_ST, /* sco open */ 131 BTA_AG_SCO_CLOSING_ST, /* sco closing */ 132 BTA_AG_SCO_CLOSE_OP_ST, /* closing sco being opened */ 133 BTA_AG_SCO_CLOSE_XFER_ST, /* closing sco being transferred */ 134 BTA_AG_SCO_SHUTTING_ST /* sco shutting down */ 135 } tBTA_AG_SCO; 136 137 /***************************************************************************** 138 * Data types 139 ****************************************************************************/ 140 141 /* data type for BTA_AG_API_REGISTER_EVT */ 142 typedef struct { 143 char p_name[2][BTA_SERVICE_NAME_LEN + 1]; 144 tBTA_SERVICE_MASK services; 145 tBTA_AG_FEAT features; 146 uint8_t app_id; 147 } tBTA_AG_API_REGISTER; 148 149 /* data type for BTA_AG_API_OPEN_EVT */ 150 typedef struct { 151 RawAddress bd_addr; 152 } tBTA_AG_API_OPEN; 153 154 /* data type for BTA_AG_API_AUDIO_OPEN_EVT */ 155 typedef struct { 156 tBTA_AG_PEER_CODEC disabled_codecs; 157 } tBTA_AG_API_AUDIO_OPEN; 158 159 /* data type for BTA_AG_API_RESULT_EVT */ 160 typedef struct { 161 tBTA_AG_RES result; 162 tBTA_AG_RES_DATA data; ToString__anon6fb7a5891b08163 std::string ToString() const { 164 return base::StringPrintf("result:%s", bta_ag_result_text(result).c_str()); 165 } 166 } tBTA_AG_API_RESULT; 167 168 /* data type for BTA_AG_API_SETCODEC_EVT */ 169 typedef struct { 170 tBTA_AG_PEER_CODEC codec; 171 } tBTA_AG_API_SETCODEC; 172 173 /* data type for BTA_AG_DISC_RESULT_EVT */ 174 typedef struct { 175 uint16_t status; 176 } tBTA_AG_DISC_RESULT; 177 178 /* data type for RFCOMM events */ 179 typedef struct { 180 uint16_t port_handle; 181 } tBTA_AG_RFC; 182 183 /* union of all event datatypes */ 184 union tBTA_AG_DATA { 185 tBTA_AG_API_REGISTER api_register; 186 tBTA_AG_API_OPEN api_open; 187 tBTA_AG_API_AUDIO_OPEN api_audio_open; 188 tBTA_AG_API_RESULT api_result; 189 tBTA_AG_API_SETCODEC api_setcodec; 190 tBTA_AG_DISC_RESULT disc_result; 191 tBTA_AG_RFC rfc; 192 static const tBTA_AG_DATA kEmpty; 193 194 /** 195 * Check if two tBTA_AG_DATA are equal in memory 196 * 197 * @param rhs other tBTA_AG_DATA 198 * @return true if both unions are equal in memory 199 */ 200 bool operator==(const tBTA_AG_DATA& rhs) const { 201 return (std::memcmp(this, &rhs, sizeof(tBTA_AG_DATA)) == 0); 202 } 203 204 /** 205 * Check if this union is empty by comparing it to the kEmpty constant 206 * 207 * @return true if this union is empty 208 */ IsEmpty()209 bool IsEmpty() const { return *this == kEmpty; } 210 }; 211 212 /* type for each profile */ 213 typedef struct { 214 uint32_t sdp_handle; 215 uint8_t scn; 216 } tBTA_AG_PROFILE; 217 218 typedef enum { 219 BTA_AG_SCO_CVSD_SETTINGS_S4 = 0, /* preferred/default when codec is CVSD */ 220 BTA_AG_SCO_CVSD_SETTINGS_S3, 221 BTA_AG_SCO_CVSD_SETTINGS_S1, 222 } tBTA_AG_SCO_CVSD_SETTINGS; 223 224 typedef enum { 225 BTA_AG_SCO_MSBC_SETTINGS_T2 = 0, /* preferred/default when codec is mSBC */ 226 BTA_AG_SCO_MSBC_SETTINGS_T1, 227 } tBTA_AG_SCO_MSBC_SETTINGS; 228 229 typedef enum { 230 BTA_AG_SCO_LC3_SETTINGS_T2 = 0, /* preferred/default when codec is LC3 */ 231 BTA_AG_SCO_LC3_SETTINGS_T1, 232 } tBTA_AG_SCO_LC3_SETTINGS; 233 234 typedef enum { 235 BTA_AG_SCO_APTX_SWB_SETTINGS_Q0 = 0, /* preferred/default when codec is SWB */ 236 BTA_AG_SCO_APTX_SWB_SETTINGS_Q1 = 4, 237 BTA_AG_SCO_APTX_SWB_SETTINGS_Q2 = 6, 238 BTA_AG_SCO_APTX_SWB_SETTINGS_Q3 = 7, 239 BTA_AG_SCO_APTX_SWB_SETTINGS_UNKNOWN = 0xFFFF, 240 } tBTA_AG_SCO_APTX_SWB_SETTINGS; 241 242 /* state machine states */ 243 typedef enum { 244 BTA_AG_INIT_ST, 245 BTA_AG_OPENING_ST, 246 BTA_AG_OPEN_ST, 247 BTA_AG_CLOSING_ST 248 } tBTA_AG_STATE; 249 250 /* type for each service control block */ 251 struct tBTA_AG_SCB { 252 char clip[BTA_AG_AT_MAX_LEN + 1]; /* number string used for CLIP */ 253 uint16_t serv_handle[BTA_AG_NUM_IDX]; /* RFCOMM server handles */ 254 tBTA_AG_AT_CB at_cb; /* AT command interpreter */ 255 RawAddress peer_addr; /* peer bd address */ 256 tSDP_DISCOVERY_DB* p_disc_db; /* pointer to discovery database */ 257 tBTA_SERVICE_MASK reg_services; /* services specified in register API */ 258 tBTA_SERVICE_MASK open_services; /* services specified in open API */ 259 uint16_t conn_handle; /* RFCOMM handle of connected service */ 260 tBTA_AG_FEAT features; /* features registered by application */ 261 tBTA_AG_FEAT masked_features; /* local BRSF features for this connection */ 262 tBTA_AG_PEER_FEAT peer_features; /* peer device features */ 263 uint16_t peer_sdp_features; /* peer device SDP features */ 264 uint16_t peer_version; /* profile version of peer device */ 265 uint16_t hsp_version; /* HSP profile version before SDP */ 266 uint16_t sco_idx; /* SCO handle */ 267 bool in_use; /* scb in use */ 268 bool dealloc; /* true if service shutting down */ 269 bool clip_enabled; /* set to true if HF enables CLIP reporting */ 270 bool ccwa_enabled; /* set to true if HF enables CCWA reporting */ 271 bool cmer_enabled; /* set to true if HF enables CMER reporting */ 272 bool cmee_enabled; /* set to true if HF enables CME ERROR reporting */ 273 bool inband_enabled; /* set to true if inband ring enabled */ 274 bool nrec_enabled; /* noise reduction & echo canceling */ 275 bool svc_conn; /* set to true when service level connection up */ 276 tBTA_AG_STATE state; /* state machine state */ 277 uint8_t conn_service; /* connected service */ 278 uint8_t peer_scn; /* peer scn */ 279 uint8_t app_id; /* application id */ 280 uint8_t role; /* initiator/acceptor role */ 281 uint8_t post_sco; /* action to perform after sco event */ 282 uint8_t call_ind; /* CIEV call indicator value */ 283 uint8_t callsetup_ind; /* CIEV callsetup indicator value */ 284 uint8_t service_ind; /* CIEV service indicator value */ 285 uint8_t signal_ind; /* CIEV signal indicator value */ 286 uint8_t roam_ind; /* CIEV roam indicator value */ 287 uint8_t battchg_ind; /* CIEV battery charge indicator value */ 288 uint8_t callheld_ind; /* CIEV call held indicator value */ 289 uint32_t bia_masked_out; /* indicators HF does not want us to send */ 290 alarm_t* bind_timer; /* Timer for toyota camry 2018 carkit workaround */ 291 alarm_t* collision_timer; 292 alarm_t* ring_timer; 293 alarm_t* codec_negotiation_timer; 294 bool received_at_bac; /* indicate AT+BAC is received at least once */ 295 tBTA_AG_PEER_CODEC 296 disabled_codecs; /* set by app to block certain codecs from being used */ 297 tBTA_AG_PEER_CODEC peer_codecs; /* codecs for eSCO supported by the peer */ 298 tBTA_AG_PEER_CODEC sco_codec; /* codec to be used for eSCO connection */ 299 tBTA_AG_PEER_CODEC 300 inuse_codec; /* codec being used for the current SCO connection */ 301 bool codec_updated; /* set to true whenever the app updates codec type */ 302 bool codec_fallback; /* If sco nego fails for mSBC, fallback to CVSD */ 303 bool trying_cvsd_safe_settings; /* set to true whenever we are trying CVSD 304 safe settings */ 305 uint8_t retransmission_effort_retries; /* Retry eSCO 306 with retransmission_effort value*/ 307 tBTA_AG_SCO_MSBC_SETTINGS codec_msbc_settings; /* settings to be used for the 308 impending eSCO on WB */ 309 tBTA_AG_SCO_LC3_SETTINGS codec_lc3_settings; /* settings to be used for the 310 impending eSCO on SWB */ 311 tBTA_AG_SCO_CVSD_SETTINGS codec_cvsd_settings; /* settings to be used for the 312 impending eSCO on CVSD */ 313 tBTA_AG_SCO_APTX_SWB_SETTINGS 314 codec_aptx_settings; /* settings to be used for the 315 aptX Voice SWB eSCO */ 316 bool is_aptx_swb_codec; /* Flag to determine aptX Voice SWB codec */ 317 318 tBTA_AG_HF_IND 319 peer_hf_indicators[BTA_AG_MAX_NUM_PEER_HF_IND]; /* Peer supported 320 HF indicators */ 321 tBTA_AG_HF_IND 322 local_hf_indicators[BTA_AG_MAX_NUM_LOCAL_HF_IND]; /* Local supported 323 HF indicators */ 324 ToStringtBTA_AG_SCB325 std::string ToString() const { 326 return base::StringPrintf( 327 "codec_updated=%d, codec_fallback=%d, nrec=%d" 328 "sco_codec=%d, peer_codec=%d, msbc_settings=%d, lc3_settings=%d, " 329 "device=%s", 330 codec_updated, codec_fallback, nrec_enabled, sco_codec, peer_codecs, 331 codec_msbc_settings, codec_lc3_settings, 332 ADDRESS_TO_LOGGABLE_CSTR(peer_addr)); 333 } 334 }; 335 336 /* type for sco data */ 337 typedef struct { 338 tBTM_ESCO_CONN_REQ_EVT_DATA conn_data; /* SCO data for pending conn request */ 339 tBTA_AG_SCB* p_curr_scb; /* SCB associated with SCO connection */ 340 tBTA_AG_SCB* p_xfer_scb; /* SCB associated with SCO transfer */ 341 uint16_t cur_idx; /* SCO handle */ 342 tBTA_AG_SCO state; /* SCO state variable */ 343 bool is_local; /* SCO connection initiated locally or remotely */ 344 } tBTA_AG_SCO_CB; 345 346 /* type for AG control block */ 347 typedef struct { 348 tBTA_AG_SCB scb[BTA_AG_MAX_NUM_CLIENTS]; /* service control blocks */ 349 tBTA_AG_PROFILE profile[BTA_AG_NUM_IDX]; /* profile-specific data */ 350 tBTA_AG_SCO_CB sco; /* SCO data */ 351 tBTA_AG_CBACK* p_cback; /* application callback */ 352 } tBTA_AG_CB; 353 354 /***************************************************************************** 355 * Global data 356 ****************************************************************************/ 357 358 /* constant lookup tables */ 359 extern const uint16_t bta_ag_uuid[BTA_AG_NUM_IDX]; 360 extern const uint8_t bta_ag_sec_id[BTA_AG_NUM_IDX]; 361 extern const tBTA_AG_AT_CMD* bta_ag_at_tbl[BTA_AG_NUM_IDX]; 362 363 /* control block declaration */ 364 extern tBTA_AG_CB bta_ag_cb; 365 366 /* config struct */ 367 extern const tBTA_AG_CFG* p_bta_ag_cfg; 368 extern const tBTA_AG_HF_IND bta_ag_local_hf_ind_cfg[]; 369 370 /***************************************************************************** 371 * Function prototypes 372 ****************************************************************************/ 373 bool bta_ag_hdl_event(const BT_HDR_RIGID* p_msg); 374 375 /* API functions */ 376 void bta_ag_api_enable(tBTA_AG_CBACK* p_cback); 377 void bta_ag_api_disable(); 378 void bta_ag_api_set_active_device(const RawAddress& new_active_device); 379 void bta_ag_api_register(tBTA_SERVICE_MASK services, tBTA_AG_FEAT features, 380 const std::vector<std::string>& service_names, 381 uint8_t app_id); 382 void bta_ag_api_result(uint16_t handle, tBTA_AG_RES result, 383 const tBTA_AG_RES_DATA& result_data); 384 385 /* main functions */ 386 void bta_ag_scb_dealloc(tBTA_AG_SCB* p_scb); 387 uint16_t bta_ag_scb_to_idx(tBTA_AG_SCB* p_scb); 388 tBTA_AG_SCB* bta_ag_scb_by_idx(uint16_t idx); 389 uint8_t bta_ag_service_to_idx(tBTA_SERVICE_MASK services); 390 uint16_t bta_ag_idx_by_bdaddr(const RawAddress* peer_addr); 391 bool bta_ag_other_scb_open(tBTA_AG_SCB* p_curr_scb); 392 bool bta_ag_scb_open(tBTA_AG_SCB* p_curr_scb); 393 void bta_ag_sm_execute(tBTA_AG_SCB* p_scb, uint16_t event, 394 const tBTA_AG_DATA& data); 395 void bta_ag_sm_execute_by_handle(uint16_t handle, uint16_t event, 396 const tBTA_AG_DATA& data); 397 void bta_ag_collision_cback(tBTA_SYS_CONN_STATUS status, tBTA_SYS_ID id, 398 uint8_t app_id, const RawAddress& peer_addr); 399 void bta_ag_resume_open(tBTA_AG_SCB* p_scb); 400 const std::string bta_ag_state_str(tBTA_AG_STATE state); 401 402 /* SDP functions */ 403 bool bta_ag_add_record(uint16_t service_uuid, const char* p_service_name, 404 uint8_t scn, tBTA_AG_FEAT features, uint32_t sdp_handle); 405 void bta_ag_create_records(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 406 void bta_ag_del_records(tBTA_AG_SCB* p_scb); 407 bool bta_ag_sdp_find_attr(tBTA_AG_SCB* p_scb, tBTA_SERVICE_MASK service); 408 void bta_ag_do_disc(tBTA_AG_SCB* p_scb, tBTA_SERVICE_MASK service); 409 void bta_ag_free_db(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 410 411 /* RFCOMM functions */ 412 void bta_ag_start_servers(tBTA_AG_SCB* p_scb, tBTA_SERVICE_MASK services); 413 void bta_ag_close_servers(tBTA_AG_SCB* p_scb, tBTA_SERVICE_MASK services); 414 bool bta_ag_is_server_closed(tBTA_AG_SCB* p_scb); 415 void bta_ag_rfc_do_close(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 416 void bta_ag_rfc_do_open(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 417 418 /* SCO functions */ 419 bool bta_ag_sco_is_active_device(const RawAddress& bd_addr); 420 bool bta_ag_sco_is_open(tBTA_AG_SCB* p_scb); 421 bool bta_ag_sco_is_opening(tBTA_AG_SCB* p_scb); 422 void bta_ag_sco_conn_rsp(tBTA_AG_SCB* p_scb, tBTM_ESCO_CONN_REQ_EVT_DATA* data); 423 // Testonly 424 void bta_ag_create_sco(tBTA_AG_SCB* p_scb, bool is_orig); 425 426 /* AT command functions */ 427 void bta_ag_at_hsp_cback(tBTA_AG_SCB* p_scb, uint16_t cmd, uint8_t arg_type, 428 char* p_arg, char* p_end, int16_t int_arg); 429 void bta_ag_at_hfp_cback(tBTA_AG_SCB* p_scb, uint16_t cmd, uint8_t arg_type, 430 char* p_arg, char* p_end, int16_t int_arg); 431 void bta_ag_at_err_cback(tBTA_AG_SCB* p_scb, bool unknown, const char* p_arg); 432 bool bta_ag_inband_enabled(tBTA_AG_SCB* p_scb); 433 void bta_ag_send_call_inds(tBTA_AG_SCB* p_scb, tBTA_AG_RES result); 434 435 /* Action functions */ 436 void bta_ag_register(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 437 void bta_ag_deregister(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 438 void bta_ag_start_dereg(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 439 void bta_ag_start_close(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 440 void bta_ag_start_open(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 441 void bta_ag_disc_int_res(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 442 void bta_ag_disc_acp_res(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 443 void bta_ag_disc_fail(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 444 void bta_ag_open_fail(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 445 void bta_ag_rfc_fail(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 446 void bta_ag_rfc_close(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 447 void bta_ag_rfc_open(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 448 void bta_ag_rfc_acp_open(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 449 void bta_ag_rfc_data(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 450 void bta_ag_sco_listen(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 451 void bta_ag_sco_open(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 452 void bta_ag_sco_close(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 453 void bta_ag_sco_shutdown(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 454 void bta_ag_sco_conn_open(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 455 void bta_ag_sco_conn_close(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 456 void bta_ag_post_sco_open(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 457 void bta_ag_post_sco_close(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 458 void bta_ag_svc_conn_open(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 459 void bta_ag_result(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 460 void bta_ag_setcodec(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 461 void bta_ag_send_ring(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 462 void bta_ag_handle_collision(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data); 463 464 /* Internal utility functions */ 465 void bta_ag_sco_codec_nego(tBTA_AG_SCB* p_scb, bool result); 466 void bta_ag_codec_negotiate(tBTA_AG_SCB* p_scb); 467 bool bta_ag_is_sco_open_allowed(tBTA_AG_SCB* p_scb, const std::string event); 468 void bta_ag_send_bcs(tBTA_AG_SCB* p_scb); 469 bool bta_ag_get_sco_offload_enabled(); 470 void bta_ag_set_sco_offload_enabled(bool value); 471 void bta_ag_set_sco_allowed(bool value); 472 const RawAddress& bta_ag_get_active_device(); 473 void bta_clear_active_device(); 474 void bta_ag_send_qac(tBTA_AG_SCB* p_scb, tBTA_AG_DATA* p_data); 475 void bta_ag_send_qcs(tBTA_AG_SCB* p_scb, tBTA_AG_DATA* p_data); 476 /** 477 * Check if SCO is managed by Audio is enabled. This is set via the system property 478 * bluetooth.sco.managed_by_audio. 479 * <p>When set to false, Bluetooth will manage the start and end of the SCO. 480 * <p>When set to true, Audio will manage the start and end of the SCO through 481 * HAL. 482 * 483 * @return true if SCO managed by Audio is enabled, false otherwise 484 */ 485 bool bta_ag_is_sco_managed_by_audio(); 486 487 namespace fmt { 488 template <> 489 struct formatter<tBTA_AG_SCO_APTX_SWB_SETTINGS> 490 : enum_formatter<tBTA_AG_SCO_APTX_SWB_SETTINGS> {}; 491 template <> 492 struct formatter<tBTA_AG_SCO> : enum_formatter<tBTA_AG_SCO> {}; 493 } // namespace fmt 494 495 #endif /* BTA_AG_INT_H */ 496