1 /****************************************************************************** 2 * 3 * Copyright 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 <hardware/bluetooth.h> 22 #include <stdbool.h> 23 24 #include "include/hardware/bluetooth.h" 25 #include "osi/include/list.h" 26 #include "types/raw_address.h" 27 28 static const char INTEROP_MODULE[] = "interop_module"; 29 30 // NOTE: 31 // Only add values at the end of this enum and before END_OF_INTEROP_LIST 32 // do NOT delete values as they may be used in dynamic device configuration. 33 typedef enum { 34 BEGINNING_OF_INTEROP_LIST = 0, 35 // Disable secure connections 36 // This is for pre BT 4.1/2 devices that do not handle secure mode 37 // very well. 38 INTEROP_DISABLE_LE_SECURE_CONNECTIONS = BEGINNING_OF_INTEROP_LIST, 39 40 // Some devices have proven problematic during the pairing process, often 41 // requiring multiple retries to complete pairing. To avoid degrading the user 42 // experience for those devices, automatically re-try pairing if page 43 // timeouts are received during pairing. 44 INTEROP_AUTO_RETRY_PAIRING, 45 46 // Devices requiring this workaround do not handle Bluetooth Absolute Volume 47 // control correctly, leading to undesirable (potentially harmful) volume 48 // levels or general lack of controlability. 49 INTEROP_DISABLE_ABSOLUTE_VOLUME, 50 51 // Devices requiring this read characteristics via GATT_READ_CHAR_VALUE 52 INTEROP_DISABLE_SIRK_READ_BY_TYPE, 53 54 // Disable automatic pairing with headsets/car-kits 55 // Some car kits do not react kindly to a failed pairing attempt and 56 // do not allow immediate re-pairing. Rejectlist these so that the initial 57 // pairing attempt makes it to the user instead. 58 INTEROP_DISABLE_AUTO_PAIRING, 59 60 // Use a fixed pin for specific keyboards 61 // Keyboards should use a variable pin at all times. However, some keyboards 62 // require a fixed pin of all 0000. This workaround enables auto pairing for 63 // those keyboards. 64 INTEROP_KEYBOARD_REQUIRES_FIXED_PIN, 65 66 // Some headsets have audio jitter issues because of increased 67 // re-transmissions as the 3 Mbps packets have a lower link margin, and are 68 // more prone to interference. We can disable 3DH packets (use only 2DH 69 // packets) for the ACL link to improve sensitivity when streaming A2DP audio 70 // to the headset. Air sniffer logs show reduced re-transmissions after 71 // switching to 2DH packets. 72 73 // Disable 3Mbps packets and use only 2Mbps packets for ACL links when 74 // streaming audio. 75 INTEROP_2MBPS_LINK_ONLY, 76 77 // Some HID devices have proven problematic behaviour if SDP is initiated 78 // again while HID connection is in progress or if more than 1 SDP connection 79 // is created with those HID devices rsulting in issues of connection 80 // failure with such devices. To avoid degrading the user experience with 81 // those devices, SDP is not attempted as part of pairing process. 82 INTEROP_DISABLE_SDP_AFTER_PAIRING, 83 84 // HID Keyboards that claim support for multitouch functionality have issue 85 // with normal functioning of keyboard because of issues in USB HID kernel 86 // driver. To avoid degrading the user experience with those devices, 87 // digitizer record is removed from the report descriptor. 88 INTEROP_REMOVE_HID_DIG_DESCRIPTOR, 89 90 // Some HID devices have problematic behaviour where when hid link is in Sniff 91 // and DUT is in peripheral role for SCO link (not eSCO) any solution cannot 92 // maintain the link as SCO scheduling over a short period will overlap with 93 // Sniff link due to peripheral drift. To avoid degrading the user experience 94 // with those devices, sniff is disabled from link policy when sco is active, 95 // and enabled when sco is disabled. 96 INTEROP_DISABLE_SNIFF_DURING_SCO, 97 98 // Do not use supervision timeout value received from preferred connection 99 // parameters, use 3s instead. Use with HID only. 100 INTEROP_HID_PREF_CONN_SUP_TIMEOUT_3S, 101 102 // Do not send service changed indications (GATT client). 103 // This should be removed after the characteristic is implmeented b/62088395. 104 INTEROP_GATTC_NO_SERVICE_CHANGED_IND, 105 106 // Few carkits take long time to start sending AT commands 107 // Increase AG_CONN TIMEOUT so that AG connection go through 108 INTEROP_INCREASE_AG_CONN_TIMEOUT, 109 110 // Some HOGP devices do not respond well when we switch from default LE conn 111 // parameters to preferred conn params immediately post connection. Disable 112 // automatic switching to preferred conn params for such devices and allow 113 // them to explicitly ask for it. 114 INTEROP_DISABLE_LE_CONN_PREFERRED_PARAMS, 115 116 // certain remote A2DP sinks have issue playing back Music in AAC format. 117 // disable AAC for those headsets so that it switch to SBC 118 INTEROP_DISABLE_AAC_CODEC, 119 120 // certain remote A2DP sinks have issue playing back Music in AAC VBR format. 121 // disable AAC for those headsets so that it switch to AAC CBR 122 INTEROP_DISABLE_AAC_VBR_CODEC, 123 124 // Enable AAC only for allowlist of devices 125 INTEROP_ENABLE_AAC_CODEC, 126 127 // Disable role switch for headsets/car-kits 128 // Some car kits initiate a role switch but won't initiate encryption 129 // after role switch complete 130 INTEROP_DISABLE_ROLE_SWITCH_POLICY, 131 132 INTEROP_HFP_1_7_DENYLIST, 133 134 INTEROP_HFP_1_8_DENYLIST, 135 136 // Devices requiring this workaround do not handle Bluetooth PBAP 1.2 version 137 // correctly, leading them to go in bad state. So for better interoperability 138 // respond with PBAP 1.1 as supported version. 139 INTEROP_ADV_PBAP_VER_1_1, 140 141 // Devices requiring this workaround do not handle SSR max latency values as 142 // mentioned, in their SDP HID Record properly and lead to connection timeout 143 // or lags. To prevent such scenarios, device requiring this workaorund need 144 // to use specific ssr max latency values. 145 INTEROP_UPDATE_HID_SSR_MAX_LAT, 146 147 // Some HID pointing devices have proven problematic behaviour if pairing is 148 // initiated with them, resulting in no response for authentication request 149 // and ultimately resulting in connection failure. To avoid degrading the user 150 // experience with those devices, authentication request is not requested 151 // explicitly. 152 INTEROP_DISABLE_AUTH_FOR_HID_POINTING, 153 154 // Do not use AVDTP RECONFIGURE when reconfiguring A2DP streams. 155 // Some A2DP Sink devices report SUCCESS to the AVDTP RECONFIGURE command, 156 // but fail to play the reconfigured audio stream. 157 INTEROP_DISABLE_AVDTP_RECONFIGURE, 158 159 // Create dynamic rejectlist to disable role switch. 160 // Some car kits indicate that role switch is supported, but then reject 161 // role switch attempts. After rejecting several role switch attempts, 162 // such car kits will go into bad state. 163 INTEROP_DYNAMIC_ROLE_SWITCH, 164 165 // Few carkit hfp version is hfp1.5 but it support hfp indicator, violate spec 166 // remove hfp indicator for such device 167 INTEROP_DISABLE_HF_INDICATOR, 168 169 // Disable role switch for headsets/car-kits. 170 // Some car kits allow role switch but when the Phone initiates role switch, 171 // the Remote device will go into bad state that will lead to LMP time out. 172 INTEROP_DISABLE_ROLE_SWITCH, 173 174 // Some remotes are very strict in receiving the call active 175 // indicator and SCO connection request order for MT call. 176 // If CIEV1,1 and SCO connection request are sent back to back 177 // to SOC, it may send SCO connection request first then CIEV1,1 178 // which may lead to remotes not rendering SCO audio. 179 INTEROP_DELAY_SCO_FOR_MT_CALL, 180 181 // Some remotes are taking too long to respond for codec negotiation. 182 // Disable codec negotiation for such remotes and directly initiate 183 // SCO Connection. 184 INTEROP_DISABLE_CODEC_NEGOTIATION, 185 186 // Some Carkits being AVRCP v1.3 upon receiving Play Application Setting 187 // Command Response and notification, doesn't send Passthrough commands back 188 // to DUT in Streaming State 189 INTEROP_DISABLE_PLAYER_APPLICATION_SETTING_CMDS, 190 191 // Disable profile connection for headsets/car-kits 192 // Some car kits going bad state when DUT initiate profile connection in 193 // collision scenario Hence don't initaite profile level connections and wait 194 // for incoming connetcion 195 INTEROP_DISABLE_CONNECTION_AFTER_COLLISION, 196 197 // Some LE devices have proven problematic behaviour if LE connection update 198 // is initiated with them, resulting in no response after initiating LE 199 // connection update and ultimately resulting in connection timeout. To avoid 200 // degrading the user experience with those devices, LE connection update is 201 // not requested explicitly for those devices. 202 INTEROP_DISABLE_LE_CONN_UPDATES, 203 204 // Devices requiring this workaround do not handle Bluetooth PBAP 1.1 version 205 // correctly, leading them to go in bad state. So for better interoperability 206 // respond with PBAP 1.2 as supported version. 207 INTEROP_ADV_PBAP_VER_1_2, 208 209 // Disable profile PCE SDP request for headsets/car-kits 210 // Some car kits going bad state when DUT initiate PCE SDP request during 211 // BONDING time Hence don't send PCE SDP request for to prevent this abnormal 212 // behaviour. 213 INTEROP_DISABLE_PCE_SDP_AFTER_PAIRING, 214 215 // Few remote sends avrcp browsing request just after host sends avrcp 216 // browsing request leading collision which results in browsing channel open 217 // failure. For such devices, collision timer is used avoid collision. 218 INTEROP_AVRCP_BROWSE_OPEN_CHANNEL_COLLISION, 219 220 // Some remote devices don't support sniff mode when the SCO is connected. 221 // For such devices, disable sniff mode after SCO is connected and make 222 // the link as active. 223 INTEROP_DISABLE_SNIFF_LINK_DURING_SCO, 224 225 // For some remote devicea, disable sniff mode during the call 226 INTEROP_DISABLE_SNIFF_DURING_CALL, 227 228 // Set a very low initial sniff subrating for HID devices that do not 229 // set their own sniff interval. 230 INTEROP_HID_HOST_LIMIT_SNIFF_INTERVAL, 231 232 // Disable refresh_accept_signalling_timer 233 INTEROP_DISABLE_REFRESH_ACCEPT_SIG_TIMER, 234 235 // skip sending incoming state to denylisted devices 236 INTEROP_SKIP_INCOMING_STATE, 237 238 // Don't update avrcp paused status to some certain remote devices when a2dp 239 // is still playing. 240 INTEROP_NOT_UPDATE_AVRCP_PAUSED_TO_REMOTE, 241 242 // Some certain devices reject DUT initiated connection 243 // when DUT tries to connect other auto-connectable profiles 6s after 244 // peer connects the first one. To avoid such race condition, raised 245 // connect other profiles timeout to 10s to make sure there is no 246 // connection rejection from remote because of connection collision. 247 INTEROP_PHONE_POLICY_INCREASED_DELAY_CONNECT_OTHER_PROFILES, 248 249 // Disable remote name request for some devices. 250 // The public address of these devices are same as the Random address in ADV. 251 // Then will get name by LE_Create_connection, actually fails, 252 // but will block pairing. 253 INTEROP_DISABLE_NAME_REQUEST, 254 255 // Respond AVRCP profile version only 1.4 for some device. 256 INTEROP_AVRCP_1_4_ONLY, 257 258 // Disable sniff mode for headsets/car-kits 259 // Some car kits supports sniff mode but when DUT initiates sniff req 260 // Remote will go to bad state and its leads to LMP time out. 261 INTEROP_DISABLE_SNIFF, 262 263 // Do not send AVDTP SUSPEND while the playback is paused. 264 // Some older A2DP Sink devices might not support to pause the streaming. 265 INTEROP_DISABLE_AVDTP_SUSPEND, 266 267 // Some car kits do not send the AT+BIND command while establishing the SLC 268 // which causes an HFP profile connection failure 269 INTEROP_SLC_SKIP_BIND_COMMAND, 270 271 // Few remote devices do not understand AVRCP version greater than 1.3. For 272 // these devices, we would like to denylist them and advertise AVRCP version 273 // as 1.3 274 INTEROP_AVRCP_1_3_ONLY, 275 276 // As per the implementation for the incoming connection scenario if one 277 // profile got connected and other profile didn't get connected, DUT starts 278 // connect other profiles after 6sec timeout. For some certain device, 279 // this timeout has been reduced to 2sec for triggering auto connect to 280 // otherprofiles from DUT. So that Audio will get routed to BT device with 281 // reduced delay. 282 INTEROP_PHONE_POLICY_REDUCED_DELAY_CONNECT_OTHER_PROFILES, 283 284 // Some remote devices are misbehaving when there is an active 285 // call and MT call is in progress. We send call indicators for 286 // active call and MT Call in progess. When active call is 287 // terminated, we send call end indicator only to remote. This 288 // is confusing remote and remotes are going into bad state. 289 // Denylist remote devices to disconnect SCO when active call is 290 // ended, fake MT call indicator again with some delay. 291 INTEROP_HFP_FAKE_INCOMING_CALL_INDICATOR, 292 293 // Some certain devices not rendering VOIP call audio if call indicators 294 // are sent with a delay. Denylist the devices to send call 295 // indicators back to back. 296 INTEROP_HFP_SEND_CALL_INDICATORS_BACK_TO_BACK, 297 298 // Some remotes need SCO immediately after SLC if there is an ongoing 299 // call on the phone 300 INTEROP_SETUP_SCO_WITH_NO_DELAY_AFTER_SLC_DURING_CALL, 301 302 // Some LE mouses want to use preferred connection parameters 303 INTEROP_ENABLE_PREFERRED_CONN_PARAMETER, 304 305 // Some remotes drop SCO connection immediately after accept it, 306 // Retry setup SCO once for those remote devices. 307 INTEROP_RETRY_SCO_AFTER_REMOTE_REJECT_SCO, 308 309 // some remoted need a delay after outgoing call indicators 310 // are sent before sco is opened 311 INTEROP_DELAY_SCO_FOR_MO_CALL, 312 313 // Some remote hid devices cannot work properly as they load special hid usb 314 // driver in kernel, so modify their vid/pid so that generic hid driver are 315 // loaded. 316 INTEROP_CHANGE_HID_VID_PID, 317 318 // Some remote always set DUT in peripheral role during connection which 319 // restricts setting supervision timeout to required value. This interop will 320 // allow local device to be only central as role switch would be restricted 321 // during connection. 322 INTEROP_DISABLE_ROLE_SWITCH_DURING_CONNECTION, 323 324 // Some remote devices have LMP version in[5.0, 5.2] but do not support robust 325 // caching or correctly response with an error. We disable the database hash 326 // lookup for such devices. 327 INTEROP_DISABLE_ROBUST_CACHING, 328 329 INTEROP_HFP_1_7_ALLOWLIST, 330 331 INTEROP_HFP_1_9_ALLOWLIST, 332 333 // Some device may have problem in reconnect flow, 334 // need we initiate connection after signalling timeout 335 INTEROP_IGNORE_DISC_BEFORE_SIGNALLING_TIMEOUT, 336 337 // Certain devices have issue where they cannot handle ATT traffic during SMP 338 // key exchange. For those devices, queued ATT writes are delayed until after 339 // both encryption complete and SMP key exchange completed. 340 INTEROP_SUSPEND_ATT_TRAFFIC_DURING_PAIRING, 341 342 // This triggers a +CIEV command to set the call status for HFP devices. 343 // It is required for some devices to provide sound. 344 INTEROP_INSERT_CALL_WHEN_SCO_START, 345 346 // Some device need the host to delay authentication process to avoid 347 // collision. 348 INTEROP_DELAY_AUTH, 349 350 // Some LE HID devices contain more than one HOGP service. 351 INTEROP_MULTIPLE_HOGP_SERVICE_CHOOSE_THIRD, 352 353 // Som A2DP sink devices don't respond SDP request during A2DP reconnection 354 INTEROP_A2DP_SKIP_SDP_DURING_RECONNECTION, 355 356 // Some devices response slowly after setting non zero latency. 357 // To avoid slowing down profile connection set latency to 0. 358 // Peer can request proper latency based on its power state later. 359 INTEROP_HID_PREF_CONN_ZERO_LATENCY, 360 361 // Some HOGP devices have the report map longer than the maximum GATT 362 // attribute value length (512 bytes). 363 INTEROP_HOGP_LONG_REPORT, 364 365 // Some HOGP devices requires MTU exchange be part of the initial setup to 366 // function. 367 INTEROP_HOGP_FORCE_MTU_EXCHANGE, 368 369 // Some devices claim to support HFP in EIR but does not actually support it. 370 INTEROP_DISABLE_HF_PROFILE, 371 372 // Some devices don't respond to LE appearance read request. 373 INTEROP_DISABLE_READ_LE_APPEARANCE, 374 375 END_OF_INTEROP_LIST 376 } interop_feature_t; 377 378 // Check if a given |addr| matches a known interoperability workaround as 379 // identified by the |interop_feature_t| enum. This API is used for simple 380 // address based lookups where more information is not available. No 381 // look-ups or random address resolution are performed on |addr|. 382 bool interop_match_addr(const interop_feature_t feature, const RawAddress* addr); 383 384 // Check if a given remote device |name| matches a known workaround. 385 // Name comparisons are case sensitive and do not allow for partial matches. 386 // If |name| is "TEST" and a workaround exists for "TESTING", then this function 387 // will return false. But, if |name| is "TESTING" and a workaround exists for 388 // "TEST", this function will return true. 389 // |name| cannot be null and must be null terminated. 390 bool interop_match_name(const interop_feature_t feature, const char* name); 391 392 // This api will lookup remote name with |addr| by btif_storage api internally. 393 // Then if either interop_match_addr or interop_match_name is matched, this 394 // function will return true. 395 bool interop_match_addr_or_name(const interop_feature_t feature, const RawAddress* addr, 396 bt_status_t (*get_remote_device_property)(const RawAddress*, 397 bt_property_t*)); 398 399 // Check if a given |manufacturer| matches a known interoperability workaround 400 // as identified by the |interop_feature_t| enum. This API is used for 401 // manufacturer based lookups where more information is not available. 402 bool interop_match_manufacturer(const interop_feature_t feature, uint16_t manufacturer); 403 404 // Check if a given |vendor_id, |product_id| matches a known 405 // interoperability workaround as identified by the |interop_feature_t| 406 // enum. This API is used for simple name based lookups where more information 407 // is not available. 408 bool interop_match_vendor_product_ids(const interop_feature_t feature, uint16_t vendor_id, 409 uint16_t product_id); 410 411 // Add a dynamic interop database entry for a device matching the first |length| 412 // bytes of |addr|, implementing the workaround identified by |feature|. 413 // |addr| may not be null. 414 // |length| must be greater than 0 and less than RawAddress::kLength. 415 // As |interop_feature_t| is not exposed in the public API, feature must be a 416 // valid integer representing an option in the enum. 417 void interop_database_add(const uint16_t feature, const RawAddress* addr, size_t length); 418 419 // Clear the dynamic portion of the interoperability workaround database. 420 void interop_database_clear(void); 421 422 // check if device version is matching with the interop database 423 bool interop_database_match_version(const interop_feature_t feature, uint16_t version); 424 // Check if a given |addr| matches a known interoperability workaround as 425 // identified by the |interop_feature_t| enum. This API is used for simple 426 // address based lookups where more information is not available. No look-ups or 427 // random address resolution are performed on |addr|. If address is matched, max 428 // latency for SSR stored for particular remote device is returned. 429 bool interop_match_addr_get_max_lat(const interop_feature_t feature, const RawAddress* addr, 430 uint16_t* max_lat); 431 432 // Return feature's enum value according to feature'name. 433 int interop_feature_name_to_feature_id(const char* feature_name); 434