diff options
| author | Hemant Gupta <hemantg@codeaurora.org> | 2015-04-26 10:32:57 +0530 |
|---|---|---|
| committer | Linux Build Service Account <lnxbuild@localhost> | 2015-10-06 03:21:28 -0600 |
| commit | da33b4613d9e9245cdcc1c3fc89dd4013a9bc2f3 (patch) | |
| tree | 1ad0420b79c976e29bc1cb0b1e492f41353c2549 /device | |
| parent | 47e2f761f77ecf72aeb1d47fdcca9af04a569454 (diff) | |
| download | android_system_bt-da33b4613d9e9245cdcc1c3fc89dd4013a9bc2f3.tar.gz android_system_bt-da33b4613d9e9245cdcc1c3fc89dd4013a9bc2f3.tar.bz2 android_system_bt-da33b4613d9e9245cdcc1c3fc89dd4013a9bc2f3.zip | |
HID: Enhance blacklist logic for restricting SDP.
This patch enhances existing blacklist logic for restricting SDP
for hid devices, by adding BD address and name support in addition
to manufacturer id. Also blacklist logic is added for HID devices not
supporting authentication.
- Targus mouse does not support authentication, so blacklist logic
added to disable authentication for such hid devices.
- Many hid mouse gives out of resource error for incoming connections
when more than 1 sdp connection is made to them. Current implementaion
in BD stack performs SDP from 2 layers HID BTA layer to determine hid
desritors for hid device and btif layer for determining uuid's supported.
Blacklist logic is enhanced for such devices to not perform sdp from btif
layer after authentication and directly inform upper layers that sdp is
complete by adding support for BD address and name based addition to
blacklist.
Change-Id: I4fe1e016549bb55ad176cd014bf1d5da85b38353
CRs-Fixed: 465421, 568114
Diffstat (limited to 'device')
| -rw-r--r-- | device/include/interop.h | 29 | ||||
| -rw-r--r-- | device/include/interop_database.h | 53 | ||||
| -rw-r--r-- | device/src/interop.c | 49 | ||||
| -rw-r--r-- | device/test/interop_test.cpp | 12 |
4 files changed, 127 insertions, 16 deletions
diff --git a/device/include/interop.h b/device/include/interop.h index e2ca682a3..69b62d752 100644 --- a/device/include/interop.h +++ b/device/include/interop.h @@ -32,11 +32,36 @@ typedef enum { // 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_AUTO_RETRY_PAIRING, + + // Some HID devices have proven problematic behaviour if SDP is initiated more + // while HID connection is in progress or if more than 1 SDP connection is created + // with those HID devices rsulting in issues of connection failure with such devices. + // To avoid degrading the user experience with those devices, sdp is not attempted + // as part of pairing process from btif layer. + INTEROP_DISABLE_SDP_AFTER_PAIRING, + + // Some HID pointing devices have proven problematic behaviour if pairing is initiated with + // them, resulting in no response for authentication request and ultimately resulting + // in connection failure. + // To avoid degrading the user experience with those devices, authentication request + // is not requested explictly. + INTEROP_DISABLE_AUTH_FOR_HID_POINTING, } interop_feature_t; // Check if a given |addr| matches a known interoperability workaround as identified // by the |interop_feature_t| enum. This API is used for simple address based lookups // where more information is not available. No look-ups or random address resolution // is performed on |addr|. -bool interop_match(const interop_feature_t feature, const bt_bdaddr_t *addr); +bool interop_addr_match(const interop_feature_t feature, const bt_bdaddr_t *addr); + +// Check if a given |name| matches a known interoperability workaround as identified +// by the |interop_feature_t| enum. This API is used for simple name based lookups +// where more information is not available. +bool interop_name_match(const interop_feature_t feature, const char *addr); + +// Check if a given |manufacturer| matches a known interoperability workaround as identified +// by the |interop_feature_t| enum. This API is used for simple name based lookups +// where more information is not available. +bool interop_manufacturer_match(const interop_feature_t feature, uint16_t manufacturer); + diff --git a/device/include/interop_database.h b/device/include/interop_database.h index 944b92de7..38a2d1145 100644 --- a/device/include/interop_database.h +++ b/device/include/interop_database.h @@ -24,9 +24,19 @@ typedef struct { bt_bdaddr_t addr; uint8_t len; interop_feature_t feature; -} interop_entry_t; +} interop_addr_t; -static const interop_entry_t interop_database[] = { +typedef struct { + char *name;; + interop_feature_t feature; +} interop_name_t; + +typedef struct { + uint16_t manufacturer; + interop_feature_t feature; +} interop_manufacturer_t; + +static const interop_addr_t interop_addr_database[] = { // Nexus Remote (Spike) // Note: May affect other Asus brand devices {{0x08, 0x62, 0x66, 0,0,0}, 3, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, @@ -46,5 +56,42 @@ static const interop_entry_t interop_database[] = { {{0x80, 0xea, 0xCa, 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} + {{0x9c, 0xdf, 0x03, 0,0,0}, 3, INTEROP_AUTO_RETRY_PAIRING}, + + // Apple Magic Mouse + {{0x04, 0x0C, 0xCE, 0,0,0}, 3, INTEROP_DISABLE_SDP_AFTER_PAIRING}, + // Bluetooth Laser Travel Mouse + {{0x00, 0x07, 0x61, 0,0,0}, 3, INTEROP_DISABLE_SDP_AFTER_PAIRING}, + // Microsoft Bluetooth Notebook Mouse 5000 + {{0x00, 0x1d, 0xd8, 0,0,0}, 3, INTEROP_DISABLE_SDP_AFTER_PAIRING}, + // Logitech MX Revolution Mouse + {{0x00, 0x1f, 0x20, 0,0,0}, 3, INTEROP_DISABLE_SDP_AFTER_PAIRING}, + // Rapoo 6080 mouse + {{0x6c, 0x5d, 0x63, 0,0,0}, 3, INTEROP_DISABLE_SDP_AFTER_PAIRING}, + // Microsoft Sculpt Touch Mouse + {{0x28, 0x18, 0x78, 0,0,0}, 3, INTEROP_DISABLE_SDP_AFTER_PAIRING}, + + // Targus BT Laser Notebook Mouse + {{0x00, 0x12, 0xA1, 0,0,0}, 3, INTEROP_DISABLE_AUTH_FOR_HID_POINTING}, +}; + +static const interop_name_t interop_name_database[] = { + // Apple Magic Mouse + {"Apple Magic Mouse", INTEROP_DISABLE_SDP_AFTER_PAIRING}, + // Bluetooth Laser Travel Mouse + {"Bluetooth Laser Travel Mouse", INTEROP_DISABLE_SDP_AFTER_PAIRING}, + // Microsoft Bluetooth Notebook Mouse 5000 + {"Microsoft Bluetooth Notebook Mouse 5000", INTEROP_DISABLE_SDP_AFTER_PAIRING}, + // Logitech MX Revolution Mouse + {"Logitech MX Revolution Mouse", INTEROP_DISABLE_SDP_AFTER_PAIRING}, + // Microsoft Sculpt Touch Mouse + {"Microsoft Sculpt Touch Mouse", INTEROP_DISABLE_SDP_AFTER_PAIRING}, + + // Targus BT Laser Notebook Mouse + {"Targus BT Laser Notebook Mouse", INTEROP_DISABLE_AUTH_FOR_HID_POINTING}, +}; + +static const interop_manufacturer_t interop_manufctr_database[] = { + // Apple Devices + {76, INTEROP_DISABLE_SDP_AFTER_PAIRING}, }; diff --git a/device/src/interop.c b/device/src/interop.c index 84decd765..6036a1107 100644 --- a/device/src/interop.c +++ b/device/src/interop.c @@ -31,6 +31,8 @@ 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) + CASE_RETURN_STR(INTEROP_DISABLE_SDP_AFTER_PAIRING) + CASE_RETURN_STR(INTEROP_DISABLE_AUTH_FOR_HID_POINTING) } return "UNKNOWN"; @@ -38,16 +40,16 @@ static const char* interop_feature_string(const interop_feature_t feature) { // Interface functions -bool interop_match(const interop_feature_t feature, const bt_bdaddr_t *addr) { +bool interop_addr_match(const interop_feature_t feature, const bt_bdaddr_t *addr) { assert(addr); - const size_t db_size = sizeof(interop_database) / sizeof(interop_entry_t); + const size_t db_size = sizeof(interop_addr_database) / sizeof(interop_addr_t); for (size_t i = 0; i != db_size; ++i) { - if (feature == interop_database[i].feature && - memcmp(addr, &interop_database[i].addr, interop_database[i].len) == 0) { + if (feature == interop_addr_database[i].feature && + memcmp(addr, &interop_addr_database[i].addr, interop_addr_database[i].len) == 0) { char bdstr[20] = {0}; - LOG_WARN("%s() Device %s is a match for interop workaround %s", __func__, + LOG_WARN("%s() Device %s is a match for interop addr workaround %s", __func__, bdaddr_to_string(addr, bdstr, sizeof(bdstr)), interop_feature_string(feature)); return true; } @@ -55,3 +57,40 @@ bool interop_match(const interop_feature_t feature, const bt_bdaddr_t *addr) { return false; } + +bool interop_name_match(const interop_feature_t feature, const char *name) { + assert(name); + + const size_t db_size = sizeof(interop_name_database) / sizeof(interop_name_t); + + for (size_t i = 0; i != db_size; ++i) { + if (feature == interop_name_database[i].feature && + strncmp(name, interop_name_database[i].name, strlen(name)) == 0) { + char bdstr[20] = {0}; + LOG_WARN("%s() Device with name: %s is a match for interop name workaround %s", __func__, + name, interop_feature_string(feature)); + return true; + } + } + + return false; +} + +bool interop_manufacturer_match(const interop_feature_t feature, uint16_t manufacturer) { + assert(manufacturer); + + const size_t db_size = sizeof(interop_manufctr_database) / sizeof(interop_manufacturer_t); + + for (size_t i = 0; i != db_size; ++i) { + if (feature == interop_manufctr_database[i].feature && + manufacturer == interop_manufctr_database[i].manufacturer) { + char bdstr[20] = {0}; + LOG_WARN("%s() Device with manufacturer id: %d is a match for interop manufacturer" + "workaround %s", __func__, manufacturer, interop_feature_string(feature)); + return true; + } + } + + return false; +} + diff --git a/device/test/interop_test.cpp b/device/test/interop_test.cpp index eae23ffab..2be436f97 100644 --- a/device/test/interop_test.cpp +++ b/device/test/interop_test.cpp @@ -25,20 +25,20 @@ extern "C" { TEST(InteropTest, test_lookup_hit) { 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)); + EXPECT_TRUE(interop_addr_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)); + EXPECT_TRUE(interop_addr_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)); + EXPECT_FALSE(interop_addr_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)); + EXPECT_FALSE(interop_addr_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)); + EXPECT_FALSE(interop_addr_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)); + EXPECT_FALSE(interop_addr_match(INTEROP_AUTO_RETRY_PAIRING, &test_address)); } |
