1 /****************************************************************************** 2 * 3 * Copyright (C) 2015 Google, Inc. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 #pragma once 20 21 #include <stdbool.h> 22 23 #include "raw_address.h" 24 25 static const char INTEROP_MODULE[] = "interop_module"; 26 27 // NOTE: 28 // Only add values at the end of this enum and do NOT delete values 29 // as they may be used in dynamic device configuration. 30 typedef enum { 31 // Disable secure connections 32 // This is for pre BT 4.1/2 devices that do not handle secure mode 33 // very well. 34 INTEROP_DISABLE_LE_SECURE_CONNECTIONS = 0, 35 36 // Some devices have proven problematic during the pairing process, often 37 // requiring multiple retries to complete pairing. To avoid degrading the user 38 // experience for those devices, automatically re-try pairing if page 39 // timeouts are received during pairing. 40 INTEROP_AUTO_RETRY_PAIRING, 41 42 // Devices requiring this workaround do not handle Bluetooth Absolute Volume 43 // control correctly, leading to undesirable (potentially harmful) volume 44 // levels or general lack of controlability. 45 INTEROP_DISABLE_ABSOLUTE_VOLUME, 46 47 // Disable automatic pairing with headsets/car-kits 48 // Some car kits do not react kindly to a failed pairing attempt and 49 // do not allow immediate re-pairing. Blacklist these so that the initial 50 // pairing attempt makes it to the user instead. 51 INTEROP_DISABLE_AUTO_PAIRING, 52 53 // Use a fixed pin for specific keyboards 54 // Keyboards should use a variable pin at all times. However, some keyboards 55 // require a fixed pin of all 0000. This workaround enables auto pairing for 56 // those keyboards. 57 INTEROP_KEYBOARD_REQUIRES_FIXED_PIN, 58 59 // Some headsets have audio jitter issues because of increased 60 // re-transmissions as the 3 Mbps packets have a lower link margin, and are 61 // more prone to interference. We can disable 3DH packets (use only 2DH 62 // packets) for the ACL link to improve sensitivity when streaming A2DP audio 63 // to the headset. Air sniffer logs show reduced re-transmissions after 64 // switching to 2DH packets. 65 66 // Disable 3Mbps packets and use only 2Mbps packets for ACL links when 67 // streaming audio. 68 INTEROP_2MBPS_LINK_ONLY, 69 70 // Do not use supervision timeout value received from preferred connection 71 // parameters, use 3s instead. Use with HID only. 72 INTEROP_HID_PREF_CONN_SUP_TIMEOUT_3S, 73 74 // Do not send service changed indications (GATT client). 75 // This should be removed after the characteristic is implmeented b/62088395. 76 INTEROP_GATTC_NO_SERVICE_CHANGED_IND, 77 78 // Do not use AVDTP RECONFIGURE when reconfiguring A2DP streams. 79 // Some A2DP Sink devices report SUCCESS to the AVDTP RECONFIGURE command, 80 // but fail to play the reconfigured audio stream. 81 INTEROP_DISABLE_AVDTP_RECONFIGURE, 82 83 // Create dynamic blacklist to disable role switch. 84 // Some car kits indicate that role switch is supported, but then reject 85 // role switch attempts. After rejecting several role switch attempts, 86 // such car kits will go into bad state. 87 INTEROP_DYNAMIC_ROLE_SWITCH, 88 89 // Disable role switch for headsets/car-kits. 90 // Some car kits allow role switch but when the Phone initiates role switch, 91 // the Remote device will go into bad state that will lead to LMP time out. 92 INTEROP_DISABLE_ROLE_SWITCH 93 } interop_feature_t; 94 95 // Check if a given |addr| matches a known interoperability workaround as 96 // identified by the |interop_feature_t| enum. This API is used for simple 97 // address based lookups where more information is not available. No 98 // look-ups or random address resolution are performed on |addr|. 99 bool interop_match_addr(const interop_feature_t feature, 100 const RawAddress* addr); 101 102 // Check if a given remote device |name| matches a known workaround. 103 // Name comparisons are case sensitive and do not allow for partial matches. 104 // If |name| is "TEST" and a workaround exists for "TESTING", then this function 105 // will return false. But, if |name| is "TESTING" and a workaround exists for 106 // "TEST", this function will return true. 107 // |name| cannot be null and must be null terminated. 108 bool interop_match_name(const interop_feature_t feature, const char* name); 109 110 // Add a dynamic interop database entry for a device matching the first |length| 111 // bytes of |addr|, implementing the workaround identified by |feature|. 112 // |addr| may not be null. 113 // |length| must be greater than 0 and less than RawAddress::kLength. 114 // As |interop_feature_t| is not exposed in the public API, feature must be a 115 // valid integer representing an option in the enum. 116 void interop_database_add(const uint16_t feature, const RawAddress* addr, 117 size_t length); 118 119 // Clear the dynamic portion of the interoperability workaround database. 120 void interop_database_clear(void); 121