Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1663b4e3 authored by Andre Eisenbach's avatar Andre Eisenbach
Browse files

Move pairing auto-retry workaround to new interop db

Change-Id: I7177aaa0e2d0c3b0fa79ae655c0171f0703c54f3
parent 3ef673fc
Loading
Loading
Loading
Loading
+3 −30
Original line number Original line Diff line number Diff line
@@ -49,40 +49,12 @@
#include "btif_hh.h"
#include "btif_hh.h"
#include "btif_config.h"
#include "btif_config.h"
#include "btif_sdp.h"
#include "btif_sdp.h"

#include "bta_gatt_api.h"
#include "bta_gatt_api.h"
#include "device/include/interop.h"
#include "include/stack_config.h"
#include "include/stack_config.h"

#include "osi/include/log.h"
#include "osi/include/log.h"
#include "osi/include/allocator.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
**  Constants & Macros
******************************************************************************/
******************************************************************************/
@@ -1184,7 +1156,8 @@ static void btif_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
        switch(p_auth_cmpl->fail_reason)
        switch(p_auth_cmpl->fail_reason)
        {
        {
            case HCI_ERR_PAGE_TIMEOUT:
            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);
                    BTIF_TRACE_WARNING("%s() - Pairing timeout; retrying (%d) ...", __FUNCTION__, pairing_cb.timeout_retries);
                    --pairing_cb.timeout_retries;
                    --pairing_cb.timeout_retries;
+7 −1
Original line number Original line Diff line number Diff line
@@ -26,7 +26,13 @@ typedef enum {
  // Disable secure connections
  // Disable secure connections
  // This is for pre BT 4.1/2 devices that do not handle secure mode
  // This is for pre BT 4.1/2 devices that do not handle secure mode
  // very well.
  // 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;
} interop_feature_t;


// Check if a given |addr| matches a known interoperability workaround as identified
// Check if a given |addr| matches a known interoperability workaround as identified
+4 −1
Original line number Original line Diff line number Diff line
@@ -29,5 +29,8 @@ typedef struct {
static const interop_entry_t interop_database[] = {
static const interop_entry_t interop_database[] = {
  // Nexus Remote (Spike)
  // Nexus Remote (Spike)
  // Note: May affect other Asus brand devices
  // 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}
};
};
+1 −0
Original line number Original line Diff line number Diff line
@@ -30,6 +30,7 @@
static const char* interop_feature_string(const interop_feature_t feature) {
static const char* interop_feature_string(const interop_feature_t feature) {
  switch (feature) {
  switch (feature) {
    CASE_RETURN_STR(INTEROP_DISABLE_LE_SECURE_CONNECTIONS)
    CASE_RETURN_STR(INTEROP_DISABLE_LE_SECURE_CONNECTIONS)
    CASE_RETURN_STR(INTEROP_AUTO_RETRY_PAIRING)
  }
  }


  return "UNKNOWN";
  return "UNKNOWN";
+8 −0
Original line number Original line Diff line number Diff line
@@ -26,11 +26,19 @@ TEST(InteropTest, test_lookup_hit) {
  bt_bdaddr_t test_address;
  bt_bdaddr_t test_address;
  string_to_bdaddr("38:2c:4a:59:67:89", &test_address);
  string_to_bdaddr("38:2c:4a:59:67:89", &test_address);
  EXPECT_TRUE(interop_match(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, &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) {
TEST(InteropTest, test_lookup_miss) {
  bt_bdaddr_t test_address;
  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);
  string_to_bdaddr("42:08:15:ae:ae:ae", &test_address);
  EXPECT_FALSE(interop_match(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, &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));
}
}