Move pairing auto-retry workaround to new interop db
Change-Id: I7177aaa0e2d0c3b0fa79ae655c0171f0703c54f3
diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c
index 0a17f37..4a02d11 100644
--- a/btif/src/btif_dm.c
+++ b/btif/src/btif_dm.c
@@ -49,41 +49,13 @@
#include "btif_hh.h"
#include "btif_config.h"
#include "btif_sdp.h"
-
#include "bta_gatt_api.h"
+#include "device/include/interop.h"
#include "include/stack_config.h"
-
#include "osi/include/log.h"
#include "osi/include/allocator.h"
/******************************************************************************
-** Device specific workarounds
-******************************************************************************/
-
-/**
- * The devices below have proven problematic during the pairing process, often
- * requiring multiple retries to complete pairing. To avoid degrading the user
- * experience for other devices, explicitely blacklist troubled devices here.
- */
-static const UINT8 blacklist_pairing_retries[][3] = {
- {0x9C, 0xDF, 0x03} // BMW car kits (Harman/Becker)
-};
-
-BOOLEAN blacklistPairingRetries(BD_ADDR bd_addr)
-{
- const unsigned blacklist_size = sizeof(blacklist_pairing_retries)
- / sizeof(blacklist_pairing_retries[0]);
- for (unsigned i = 0; i != blacklist_size; ++i)
- {
- if (blacklist_pairing_retries[i][0] == bd_addr[0] &&
- blacklist_pairing_retries[i][1] == bd_addr[1] &&
- blacklist_pairing_retries[i][2] == bd_addr[2])
- return TRUE;
- }
- return FALSE;
-}
-
-/******************************************************************************
** Constants & Macros
******************************************************************************/
@@ -1184,7 +1156,8 @@
switch(p_auth_cmpl->fail_reason)
{
case HCI_ERR_PAGE_TIMEOUT:
- if (blacklistPairingRetries(bd_addr.address) && pairing_cb.timeout_retries)
+ if (interop_match(INTEROP_AUTO_RETRY_PAIRING, &bd_addr)
+ && pairing_cb.timeout_retries)
{
BTIF_TRACE_WARNING("%s() - Pairing timeout; retrying (%d) ...", __FUNCTION__, pairing_cb.timeout_retries);
--pairing_cb.timeout_retries;
diff --git a/device/include/interop.h b/device/include/interop.h
index 0a2a2dd..e2ca682 100644
--- a/device/include/interop.h
+++ b/device/include/interop.h
@@ -26,7 +26,13 @@
// Disable secure connections
// This is for pre BT 4.1/2 devices that do not handle secure mode
// very well.
- INTEROP_DISABLE_LE_SECURE_CONNECTIONS
+ INTEROP_DISABLE_LE_SECURE_CONNECTIONS,
+
+ // Some devices have proven problematic during the pairing process, often
+ // requiring multiple retries to complete pairing. To avoid degrading the user
+ // experience for those devices, automatically re-try pairing if page
+ // timeouts are received during pairing.
+ INTEROP_AUTO_RETRY_PAIRING
} interop_feature_t;
// Check if a given |addr| matches a known interoperability workaround as identified
diff --git a/device/include/interop_database.h b/device/include/interop_database.h
index 64c13cf..f4bfa1f 100644
--- a/device/include/interop_database.h
+++ b/device/include/interop_database.h
@@ -29,5 +29,8 @@
static const interop_entry_t interop_database[] = {
// Nexus Remote (Spike)
// Note: May affect other Asus brand devices
- {{0x38, 0x2c, 0x4a, 0,0,0}, 3, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}
+ {{0x38, 0x2c, 0x4a, 0,0,0}, 3, INTEROP_DISABLE_LE_SECURE_CONNECTIONS},
+
+ // BMW car kits (Harman/Becker)
+ {{0x9c, 0xdf, 0x03, 0,0,0}, 3, INTEROP_AUTO_RETRY_PAIRING}
};
diff --git a/device/src/interop.c b/device/src/interop.c
index 64dc246..84decd7 100644
--- a/device/src/interop.c
+++ b/device/src/interop.c
@@ -30,6 +30,7 @@
static const char* interop_feature_string(const interop_feature_t feature) {
switch (feature) {
CASE_RETURN_STR(INTEROP_DISABLE_LE_SECURE_CONNECTIONS)
+ CASE_RETURN_STR(INTEROP_AUTO_RETRY_PAIRING)
}
return "UNKNOWN";
diff --git a/device/test/interop_test.cpp b/device/test/interop_test.cpp
index 3cf4e9e..eae23ff 100644
--- a/device/test/interop_test.cpp
+++ b/device/test/interop_test.cpp
@@ -26,11 +26,19 @@
bt_bdaddr_t test_address;
string_to_bdaddr("38:2c:4a:59:67:89", &test_address);
EXPECT_TRUE(interop_match(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, &test_address));
+ string_to_bdaddr("9c:df:03:12:34:56", &test_address);
+ EXPECT_TRUE(interop_match(INTEROP_AUTO_RETRY_PAIRING, &test_address));
}
TEST(InteropTest, test_lookup_miss) {
bt_bdaddr_t test_address;
+ string_to_bdaddr("00:00:00:00:00:00", &test_address);
+ EXPECT_FALSE(interop_match(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, &test_address));
+ string_to_bdaddr("ff:ff:ff:ff:ff:ff", &test_address);
+ EXPECT_FALSE(interop_match(INTEROP_AUTO_RETRY_PAIRING, &test_address));
string_to_bdaddr("42:08:15:ae:ae:ae", &test_address);
EXPECT_FALSE(interop_match(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, &test_address));
+ string_to_bdaddr("38:2c:4a:59:67:89", &test_address);
+ EXPECT_FALSE(interop_match(INTEROP_AUTO_RETRY_PAIRING, &test_address));
}