summaryrefslogtreecommitdiffstats
path: root/btif
diff options
context:
space:
mode:
authorKausik Sinnaswamy <kausik@broadcom.com>2012-04-13 17:32:14 +0530
committerMatthew Xie <mattx@google.com>2012-07-14 11:19:16 -0700
commita9a2e99c49b43c64a5bec3a9f9bb636a6c95c9d5 (patch)
tree7d1a3bfa95637a16a46d0afd5ef8288f1fd9e2e1 /btif
parentd9798df11d1061760f03577f93a8083492bb1582 (diff)
downloadexternal_bluetooth_bluedroid-a9a2e99c49b43c64a5bec3a9f9bb636a6c95c9d5.zip
external_bluetooth_bluedroid-a9a2e99c49b43c64a5bec3a9f9bb636a6c95c9d5.tar.gz
external_bluetooth_bluedroid-a9a2e99c49b43c64a5bec3a9f9bb636a6c95c9d5.tar.bz2
Handle the scenario to cancel discovery when inquiry has completed but
remote name fetch is in progress Change-Id: Ie9de5256f616d35a4dba32302a3c61842924d5c5
Diffstat (limited to 'btif')
-rwxr-xr-xbtif/src/btif_dm.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c
index 265b5af..62f247c 100755
--- a/btif/src/btif_dm.c
+++ b/btif/src/btif_dm.c
@@ -96,6 +96,9 @@ typedef struct {
#define BTA_SERVICE_ID_TO_SERVICE_MASK(id) (1 << (id))
+/* This flag will be true if HCI_Inquiry is in progress */
+static BOOLEAN btif_dm_inquiry_in_progress = FALSE;
+
/******************************************************************************
** Static functions
******************************************************************************/
@@ -740,6 +743,22 @@ static void btif_dm_search_devices_evt (UINT16 event, char *p_param)
HAL_CBACK(bt_hal_cbacks, discovery_state_changed_cb, BT_DISCOVERY_STOPPED);
}
break;
+ case BTA_DM_SEARCH_CANCEL_CMPL_EVT:
+ {
+ /* if inquiry is not in progress and we get a cancel event, then
+ * it means we are done with inquiry, but remote_name fetches are in
+ * progress
+ *
+ * if inquiry is in progress, then we don't want to act on this cancel_cmpl_evt
+ * but instead wait for the cancel_cmpl_evt via the Busy Level
+ *
+ */
+ if (btif_dm_inquiry_in_progress == FALSE)
+ {
+ HAL_CBACK(bt_hal_cbacks, discovery_state_changed_cb, BT_DISCOVERY_STOPPED);
+ }
+ }
+ break;
}
}
@@ -976,10 +995,17 @@ static void btif_dm_upstreams_evt(UINT16 event, char* p_param)
{
HAL_CBACK(bt_hal_cbacks, discovery_state_changed_cb,
BT_DISCOVERY_STARTED);
- } else if (busy_level == BTM_BL_INQUIRY_CANCELLED)
+ btif_dm_inquiry_in_progress = TRUE;
+ }
+ else if (busy_level == BTM_BL_INQUIRY_CANCELLED)
{
HAL_CBACK(bt_hal_cbacks, discovery_state_changed_cb,
BT_DISCOVERY_STOPPED);
+ btif_dm_inquiry_in_progress = FALSE;
+ }
+ else if (busy_level == BTM_BL_INQUIRY_COMPLETE)
+ {
+ btif_dm_inquiry_in_progress = FALSE;
}
}
}break;
@@ -1183,6 +1209,8 @@ bt_status_t btif_dm_start_discovery(void)
inq_params.filter_type = BTA_DM_INQ_CLR;
/* TODO: Filter device by BDA needs to be implemented here */
+ /* Will be enabled to TRUE once inquiry busy level has been received */
+ btif_dm_inquiry_in_progress = FALSE;
/* find nearby devices */
BTA_DmSearch(&inq_params, services, bte_search_devices_evt);