summaryrefslogtreecommitdiffstats
path: root/btif/src/btif_hf.c
diff options
context:
space:
mode:
authorKausik Sinnaswamy <kausik@broadcom.com>2012-03-06 17:08:42 -0800
committerMatthew Xie <mattx@google.com>2012-07-14 11:19:11 -0700
commitb23905722d8a1c714d66aaee2da5712694596426 (patch)
treebb7ff539fa94fa219d87415253f56c147dac7876 /btif/src/btif_hf.c
parent3d576de19430085695937c04dffb2f0c8daf38e5 (diff)
downloadexternal_bluetooth_bluedroid-b23905722d8a1c714d66aaee2da5712694596426.zip
external_bluetooth_bluedroid-b23905722d8a1c714d66aaee2da5712694596426.tar.gz
external_bluetooth_bluedroid-b23905722d8a1c714d66aaee2da5712694596426.tar.bz2
Dynamic enable/disable profiles using the profile's init/cleanup APIs
Change-Id: I40ed55ada7aad0cc0e017cae16049472ef318542
Diffstat (limited to 'btif/src/btif_hf.c')
-rw-r--r--btif/src/btif_hf.c42
1 files changed, 32 insertions, 10 deletions
diff --git a/btif/src/btif_hf.c b/btif/src/btif_hf.c
index 7f0e6bc..06e7fe3 100644
--- a/btif/src/btif_hf.c
+++ b/btif/src/btif_hf.c
@@ -422,16 +422,13 @@ static void bte_hf_evt(tBTA_AG_EVT event, tBTA_AG *p_data)
*******************************************************************************/
static bt_status_t init( bthf_callbacks_t* callbacks )
{
- char * p_service_names[] = {BTIF_HSAG_SERVICE_NAME, BTIF_HFAG_SERVICE_NAME};
-
BTIF_TRACE_EVENT1("%s", __FUNCTION__);
bt_hf_callbacks = callbacks;
- /* Enable and register with BTA-AG */
- BTA_AgEnable (BTA_AG_PARSE, bte_hf_evt);
- BTA_AgRegister(BTIF_HF_SERVICES, BTIF_HF_SECURITY, BTIF_HF_FEATURES,
- p_service_names, BTIF_HF_ID_1);
+ /* Invoke the enable service API to the core to set the appropriate service_id
+ * Internally, the HSP_SERVICE_ID shall also be enabled */
+ btif_enable_service(BTA_HFP_SERVICE_ID);
return BT_STATUS_SUCCESS;
}
@@ -966,10 +963,7 @@ static void cleanup( void )
if (bt_hf_callbacks)
{
- /* De-register AG */
- BTA_AgDeregister(btif_hf_cb.handle);
- /* Disable AG */
- BTA_AgDisable();
+ btif_disable_service(BTA_HFP_SERVICE_ID);
bt_hf_callbacks = NULL;
}
}
@@ -996,6 +990,34 @@ static const bthf_interface_t bthfInterface = {
/*******************************************************************************
**
+** Function btif_hf_execute_service
+**
+** Description Initializes/Shuts down the service
+**
+** Returns BT_STATUS_SUCCESS on success, BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_hf_execute_service(BOOLEAN b_enable)
+{
+ char * p_service_names[] = {BTIF_HSAG_SERVICE_NAME, BTIF_HFAG_SERVICE_NAME};
+ if (b_enable)
+ {
+ /* Enable and register with BTA-AG */
+ BTA_AgEnable (BTA_AG_PARSE, bte_hf_evt);
+ BTA_AgRegister(BTIF_HF_SERVICES, BTIF_HF_SECURITY, BTIF_HF_FEATURES,
+ p_service_names, BTIF_HF_ID_1);
+ }
+ else {
+ /* De-register AG */
+ BTA_AgDeregister(btif_hf_cb.handle);
+ /* Disable AG */
+ BTA_AgDisable();
+ }
+ return BT_STATUS_SUCCESS;
+}
+
+/*******************************************************************************
+**
** Function btif_hf_get_interface
**
** Description Get the hf callback interface