summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Eisenbach <eisenbach@google.com>2015-03-12 10:09:14 -0700
committerAndre Eisenbach <eisenbach@google.com>2015-03-19 15:20:02 -0700
commit02c530503feb46150d013bf87b0570a781fb10ec (patch)
tree4cfac9527ba53c873e62845e0d017a8a67af011a
parenta40848a8810b95ad279d4294c8e6cbba2b09347a (diff)
downloadandroid_system_bt-02c530503feb46150d013bf87b0570a781fb10ec.tar.gz
android_system_bt-02c530503feb46150d013bf87b0570a781fb10ec.tar.bz2
android_system_bt-02c530503feb46150d013bf87b0570a781fb10ec.zip
DO NOT MERGE - Remove ACL connection reference counting
In addition to maintaining ACL link control blocks, which carry a "in_use" flag, ACL links are reference counted in the num_acl links variable. The reference counting is thrown off when a SM connection initiated for pairing is followed up by a GATT connection after pairing completes. The 2nd connection is counted against num_acl, even so other parts of the code recognize the connection as a duplicate ACL connection to the same BDA. This patch removes the unecessary reference counting and relies on the control block status instead, which is correctly maintained. The BTM_BUSY_LEVEL_CHANGE_INCLUDED flag encapsulating the num_acl tracking should be removed in the future. Bug: 19019189 Change-Id: I4cc88c24f1c4d1273361d879bc62e9fade3f3ee9
-rw-r--r--stack/btm/btm_acl.c18
-rw-r--r--stack/btm/btm_int.h1
-rw-r--r--stack/btm/btm_pm.c7
3 files changed, 6 insertions, 20 deletions
diff --git a/stack/btm/btm_acl.c b/stack/btm/btm_acl.c
index fa742e58d..0e33bf802 100644
--- a/stack/btm/btm_acl.c
+++ b/stack/btm/btm_acl.c
@@ -525,18 +525,9 @@ void btm_acl_update_busy_level (tBTM_BLI_EVENT event)
{
case BTM_BLI_ACL_UP_EVT:
BTM_TRACE_DEBUG ("BTM_BLI_ACL_UP_EVT");
- btm_cb.num_acl++;
break;
case BTM_BLI_ACL_DOWN_EVT:
- if (btm_cb.num_acl)
- {
- btm_cb.num_acl--;
- BTM_TRACE_DEBUG ("BTM_BLI_ACL_DOWN_EVT", btm_cb.num_acl);
- }
- else
- {
- BTM_TRACE_ERROR ("BTM_BLI_ACL_DOWN_EVT issued, but num_acl already zero !!!");
- }
+ BTM_TRACE_DEBUG ("BTM_BLI_ACL_DOWN_EVT");
break;
case BTM_BLI_PAGE_EVT:
BTM_TRACE_DEBUG ("BTM_BLI_PAGE_EVT");
@@ -568,7 +559,7 @@ void btm_acl_update_busy_level (tBTM_BLI_EVENT event)
if (btm_cb.is_paging || btm_cb.is_inquiry)
busy_level = 10;
else
- busy_level = (UINT8)btm_cb.num_acl;
+ busy_level = BTM_GetNumAclLinks();
if ((busy_level != btm_cb.busy_level) ||(old_inquiry_state != btm_cb.is_inquiry))
{
@@ -1648,6 +1639,7 @@ void btm_establish_continue (tACL_CONN *p_acl_cb)
(*btm_cb.p_bl_changed_cb)(&evt_data);
}
+
btm_acl_update_busy_level (BTM_BLI_ACL_UP_EVT);
#else
if (btm_cb.p_acl_changed_cb)
@@ -2132,9 +2124,6 @@ BOOLEAN BTM_IsAclConnectionUp (BD_ADDR remote_bda, tBT_TRANSPORT transport)
*******************************************************************************/
UINT16 BTM_GetNumAclLinks (void)
{
-#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE)
- return(UINT16)btm_cb.num_acl;
-#else
tACL_CONN *p = &btm_cb.acl_db[0];
UINT16 xx, yy;
BTM_TRACE_DEBUG ("BTM_GetNumAclLinks");
@@ -2145,7 +2134,6 @@ UINT16 BTM_GetNumAclLinks (void)
}
return(yy);
-#endif
}
/*******************************************************************************
diff --git a/stack/btm/btm_int.h b/stack/btm/btm_int.h
index fcb17bb5c..7032177f2 100644
--- a/stack/btm/btm_int.h
+++ b/stack/btm/btm_int.h
@@ -916,7 +916,6 @@ typedef struct
UINT8 acl_disc_reason;
UINT8 trace_level;
#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE)
- UINT8 num_acl; /* num of active ACL links */
UINT8 busy_level; /* the current busy level */
BOOLEAN is_paging; /* TRUE, if paging is in progess */
BOOLEAN is_inquiry; /* TRUE, if inquiry is in progess */
diff --git a/stack/btm/btm_pm.c b/stack/btm/btm_pm.c
index 76bfc048b..ffa4acf57 100644
--- a/stack/btm/btm_pm.c
+++ b/stack/btm/btm_pm.c
@@ -1020,9 +1020,9 @@ BOOLEAN btm_pm_device_in_active_or_sniff_mode(void)
/* The active state is the highest state-includes connected device and sniff mode*/
/* Covers active and sniff modes */
- if (btm_cb.num_acl > 0)
+ if (BTM_GetNumAclLinks() > 0)
{
- BTM_TRACE_DEBUG("btm_pm_device_in_active_or_sniff_mode-acl:%d", btm_cb.num_acl);
+ BTM_TRACE_DEBUG("%s() - ACL links: %d", __FUNCTION__, BTM_GetNumAclLinks());
return TRUE;
}
@@ -1030,8 +1030,7 @@ BOOLEAN btm_pm_device_in_active_or_sniff_mode(void)
/* Check BLE states */
if (btm_ble_get_conn_st() != BLE_CONN_IDLE)
{
- BTM_TRACE_DEBUG("btm_pm_device_in_active_or_sniff_mode- BLE state: %x",
- btm_ble_get_conn_st());
+ BTM_TRACE_DEBUG("%s() - BLE state: %x", __FUNCTION__, btm_ble_get_conn_st());
return TRUE;
}
#endif