• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "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 
35   BEGINNING_OF_INTEROP_LIST = 0,
36   // Disable secure connections
37   // This is for pre BT 4.1/2 devices that do not handle secure mode
38   // very well.
39   INTEROP_DISABLE_LE_SECURE_CONNECTIONS = BEGINNING_OF_INTEROP_LIST,
40 
41   // Some devices have proven problematic during the pairing process, often
42   // requiring multiple retries to complete pairing. To avoid degrading the user
43   // experience for those devices, automatically re-try pairing if page
44   // timeouts are received during pairing.
45   INTEROP_AUTO_RETRY_PAIRING,
46 
47   // Devices requiring this workaround do not handle Bluetooth Absolute Volume
48   // control correctly, leading to undesirable (potentially harmful) volume
49   // levels or general lack of controlability.
50   INTEROP_DISABLE_ABSOLUTE_VOLUME,
51 
52   // Disable automatic pairing with headsets/car-kits
53   // Some car kits do not react kindly to a failed pairing attempt and
54   // do not allow immediate re-pairing. Rejectlist these so that the initial
55   // pairing attempt makes it to the user instead.
56   INTEROP_DISABLE_AUTO_PAIRING,
57 
58   // Use a fixed pin for specific keyboards
59   // Keyboards should use a variable pin at all times. However, some keyboards
60   // require a fixed pin of all 0000. This workaround enables auto pairing for
61   // those keyboards.
62   INTEROP_KEYBOARD_REQUIRES_FIXED_PIN,
63 
64   // Some headsets have audio jitter issues because of increased
65   // re-transmissions as the 3 Mbps packets have a lower link margin, and are
66   // more prone to interference. We can disable 3DH packets (use only 2DH
67   // packets) for the ACL link to improve sensitivity when streaming A2DP audio
68   // to the headset. Air sniffer logs show reduced re-transmissions after
69   // switching to 2DH packets.
70 
71   // Disable 3Mbps packets and use only 2Mbps packets for ACL links when
72   // streaming audio.
73   INTEROP_2MBPS_LINK_ONLY,
74 
75   // Some HID devices have proven problematic behaviour if SDP is initiated
76   // again while HID connection is in progress or if more than 1 SDP connection
77   // is  created with those HID devices rsulting in issues of connection
78   // failure with such devices. To avoid degrading the user experience with
79   // those devices, SDP is not attempted as part of pairing process.
80   INTEROP_DISABLE_SDP_AFTER_PAIRING,
81 
82   // HID Keyboards that claim support for multitouch functionality have issue
83   // with  normal functioning of keyboard because of issues in USB HID kernel
84   // driver. To avoid degrading the user experience with those devices,
85   // digitizer record is removed from the report descriptor.
86   INTEROP_REMOVE_HID_DIG_DESCRIPTOR,
87 
88   // Some HID devices have problematic behaviour where when hid link is in Sniff
89   // and DUT is in peripheral role for SCO link (not eSCO) any solution cannot
90   // maintain the link as SCO scheduling over a short period will overlap with
91   // Sniff link due to peripheral drift. To avoid degrading the user experience
92   // with those devices, sniff is disabled from link policy when sco is active,
93   // and enabled when sco is disabled.
94   INTEROP_DISABLE_SNIFF_DURING_SCO,
95 
96   // Do not use supervision timeout value received from preferred connection
97   // parameters, use 3s instead. Use with HID only.
98   INTEROP_HID_PREF_CONN_SUP_TIMEOUT_3S,
99 
100   // Do not send service changed indications (GATT client).
101   // This should be removed after the characteristic is implmeented b/62088395.
102   INTEROP_GATTC_NO_SERVICE_CHANGED_IND,
103 
104   // Few carkits take long time to start sending AT commands
105   // Increase AG_CONN TIMEOUT so that AG connection go through
106   INTEROP_INCREASE_AG_CONN_TIMEOUT,
107 
108   // Some HOGP devices do not respond well when we switch from default LE conn
109   // parameters to preferred conn params immediately post connection. Disable
110   // automatic switching to preferred conn params for such devices and allow
111   // them to explicitly ask for it.
112   INTEROP_DISABLE_LE_CONN_PREFERRED_PARAMS,
113 
114   // certain remote A2DP sinks have issue playing back Music in AAC format.
115   // disable AAC for those headsets so that it switch to SBC
116   INTEROP_DISABLE_AAC_CODEC,
117 
118   // certain remote A2DP sinks have issue playing back Music in AAC VBR format.
119   // disable AAC for those headsets so that it switch to AAC CBR
120   INTEROP_DISABLE_AAC_VBR_CODEC,
121 
122   // Enable AAC only for allowlist of devices
123   INTEROP_ENABLE_AAC_CODEC,
124 
125   // Disable role switch for headsets/car-kits
126   // Some car kits initiate a role switch but won't initiate encryption
127   // after role switch complete
128   INTEROP_DISABLE_ROLE_SWITCH_POLICY,
129 
130   INTEROP_HFP_1_7_DENYLIST,
131 
132   INTEROP_HFP_1_8_DENYLIST,
133 
134   // Devices requiring this workaround do not handle Bluetooth PBAP 1.2 version
135   // correctly, leading them to go in bad state. So for better interoperability
136   // respond with PBAP 1.1 as supported version.
137   INTEROP_ADV_PBAP_VER_1_1,
138 
139   // Devices requiring this workaround do not handle SSR max latency values as
140   // mentioned, in their SDP HID Record properly and lead to connection timeout
141   // or lags. To prevent such scenarios, device requiring this workaorund need
142   // to use specific ssr max latency values.
143   INTEROP_UPDATE_HID_SSR_MAX_LAT,
144 
145   // Some HID pointing devices have proven problematic behaviour if pairing is
146   // initiated with them, resulting in no response for authentication request
147   // and ultimately resulting in connection failure. To avoid degrading the user
148   // experience with those devices, authentication request is not requested
149   // explicitly.
150   INTEROP_DISABLE_AUTH_FOR_HID_POINTING,
151 
152   // Do not use AVDTP RECONFIGURE when reconfiguring A2DP streams.
153   // Some A2DP Sink devices report SUCCESS to the AVDTP RECONFIGURE command,
154   // but fail to play the reconfigured audio stream.
155   INTEROP_DISABLE_AVDTP_RECONFIGURE,
156 
157   // Create dynamic rejectlist to disable role switch.
158   // Some car kits indicate that role switch is supported, but then reject
159   // role switch attempts. After rejecting several role switch attempts,
160   // such car kits will go into bad state.
161   INTEROP_DYNAMIC_ROLE_SWITCH,
162 
163   // Few carkit hfp version is hfp1.5 but it support hfp indicator, violate spec
164   // remove hfp indicator for such device
165   INTEROP_DISABLE_HF_INDICATOR,
166 
167   // Disable role switch for headsets/car-kits.
168   // Some car kits allow role switch but when the Phone initiates role switch,
169   // the Remote device will go into bad state that will lead to LMP time out.
170   INTEROP_DISABLE_ROLE_SWITCH,
171 
172   // Some remotes are very strict in receiving the call active
173   // indicator and SCO connection request order for MT call.
174   // If CIEV1,1 and SCO connection request are sent back to back
175   // to SOC, it may send SCO connection request first then CIEV1,1
176   // which may lead to remotes not rendering SCO audio.
177   INTEROP_DELAY_SCO_FOR_MT_CALL,
178 
179   // Some remotes are taking too long to respond for codec negotiation.
180   // Disable codec negotiation for such remotes and directly initiate
181   // SCO Connection.
182   INTEROP_DISABLE_CODEC_NEGOTIATION,
183 
184   // Some Carkits being AVRCP v1.3 upon receiving Play Application Setting
185   // Command Response and notification, doesn't send Passthrough commands back
186   // to DUT in Streaming State
187   INTEROP_DISABLE_PLAYER_APPLICATION_SETTING_CMDS,
188 
189   // Disable profile connection for headsets/car-kits
190   // Some car kits going bad state when DUT initiate profile connection in
191   // collision scenario Hence don't initaite profile level connections and wait
192   // for incoming connetcion
193   INTEROP_DISABLE_CONNECTION_AFTER_COLLISION,
194 
195   // Some LE devices have proven problematic behaviour if LE connection update
196   // is initiated with them, resulting in no response after initiating LE
197   // connection update and ultimately resulting in connection timeout. To avoid
198   // degrading the user experience with those devices, LE connection update is
199   // not requested explicitly for those devices.
200   INTEROP_DISABLE_LE_CONN_UPDATES,
201 
202   // Devices requiring this workaround do not handle Bluetooth PBAP 1.1 version
203   // correctly, leading them to go in bad state. So for better interoperability
204   // respond with PBAP 1.2 as supported version.
205   INTEROP_ADV_PBAP_VER_1_2,
206 
207   // Disable profile PCE SDP request for headsets/car-kits
208   // Some car kits going bad state when DUT initiate PCE SDP request during
209   // BONDING time Hence don't send PCE SDP request for to prevent this abnormal
210   // behaviour.
211   INTEROP_DISABLE_PCE_SDP_AFTER_PAIRING,
212 
213   // Few remote sends avrcp browsing request just after host sends avrcp
214   // browsing request leading collision which results in browsing channel open
215   // failure. For such devices, collision timer is used avoid collision.
216   INTEROP_AVRCP_BROWSE_OPEN_CHANNEL_COLLISION,
217 
218   // Some remote devices don't support sniff mode when the SCO is connected.
219   // For such devices, disable sniff mode after SCO is connected and make
220   // the link as active.
221   INTEROP_DISABLE_SNIFF_LINK_DURING_SCO,
222 
223   // For some remote devicea, disable sniff mode during the call
224   INTEROP_DISABLE_SNIFF_DURING_CALL,
225 
226   // Set a very low initial sniff subrating for HID devices that do not
227   // set their own sniff interval.
228   INTEROP_HID_HOST_LIMIT_SNIFF_INTERVAL,
229 
230   // Disable refresh_accept_signalling_timer
231   INTEROP_DISABLE_REFRESH_ACCEPT_SIG_TIMER,
232 
233   // list of allowlisted media players
234   INTEROP_BROWSE_PLAYER_ALLOW_LIST,
235 
236   // skip sending incoming state to denylisted devices
237   INTEROP_SKIP_INCOMING_STATE,
238 
239   // Don't update avrcp paused status to some certain remote devices when a2dp
240   // is still playing.
241   INTEROP_NOT_UPDATE_AVRCP_PAUSED_TO_REMOTE,
242 
243   // Some certain devices reject DUT initiated connection
244   // when DUT tries to connect other auto-connectable profiles 6s after
245   // peer connects the first one. To avoid such race condition, raised
246   // connect other profiles timeout to 10s to make sure there is no
247   // connection rejection from remote because of connection collision.
248   INTEROP_PHONE_POLICY_INCREASED_DELAY_CONNECT_OTHER_PROFILES,
249   // Disable remote name requst 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 laod 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   END_OF_INTEROP_LIST
331 } interop_feature_t;
332 
333 // Check if a given |addr| matches a known interoperability workaround as
334 // identified by the |interop_feature_t| enum. This API is used for simple
335 // address based lookups where more information is not available. No
336 // look-ups or random address resolution are performed on |addr|.
337 bool interop_match_addr(const interop_feature_t feature,
338                         const RawAddress* addr);
339 
340 // Check if a given remote device |name| matches a known workaround.
341 // Name comparisons are case sensitive and do not allow for partial matches.
342 // If |name| is "TEST" and a workaround exists for "TESTING", then this function
343 // will return false. But, if |name| is "TESTING" and a workaround exists for
344 // "TEST", this function will return true.
345 // |name| cannot be null and must be null terminated.
346 bool interop_match_name(const interop_feature_t feature, const char* name);
347 
348 // This api will lookup remote name with |addr| by btif_storage api internally.
349 // Then if either interop_match_addr or interop_match_name is matched, this
350 // function will return true.
351 bool interop_match_addr_or_name(const interop_feature_t feature,
352                                 const RawAddress* addr,
353                                 bt_status_t (*get_remote_device_property)(
354                                     const RawAddress*, bt_property_t*));
355 
356 // Check if a given |manufacturer| matches a known interoperability workaround
357 // as identified by the |interop_feature_t| enum. This API is used for
358 // manufacturer based lookups where more information is not available.
359 bool interop_match_manufacturer(const interop_feature_t feature,
360                                 uint16_t manufacturer);
361 
362 // Check if a given |vendor_id, |product_id| matches a known
363 // interoperability workaround as identified by the |interop_feature_t|
364 // enum. This API is used for simple name based lookups where more information
365 // is not available.
366 bool interop_match_vendor_product_ids(const interop_feature_t feature,
367                                       uint16_t vendor_id, uint16_t product_id);
368 
369 // Add a dynamic interop database entry for a device matching the first |length|
370 // bytes of |addr|, implementing the workaround identified by |feature|.
371 // |addr| may not be null.
372 // |length| must be greater than 0 and less than RawAddress::kLength.
373 // As |interop_feature_t| is not exposed in the public API, feature must be a
374 // valid integer representing an option in the enum.
375 void interop_database_add(const uint16_t feature, const RawAddress* addr,
376                           size_t length);
377 
378 // Clear the dynamic portion of the interoperability workaround database.
379 void interop_database_clear(void);
380 
381 // check if device version is matching with the interop database
382 bool interop_database_match_version(const interop_feature_t feature,
383                                     uint16_t version);
384 // Check if a given |addr| matches a known interoperability workaround as
385 // identified by the |interop_feature_t| enum. This API is used for simple
386 // address based lookups where more information is not available. No look-ups or
387 // random address resolution are performed on |addr|. If address is matched, max
388 // latency for SSR stored for particular remote device is returned.
389 bool interop_match_addr_get_max_lat(const interop_feature_t feature,
390                                     const RawAddress* addr, uint16_t* max_lat);
391 
392 // This API is used for name based lookups for allowlisted media players.
393 // If allowlisted media players list found it will assign the media players list
394 // pointer to the argument passed and  return true else return false.
395 bool interop_get_allowlisted_media_players_list(list_t* p_bl_devices);
396 
397 // Return feature's enum value according to feature'name.
398 int interop_feature_name_to_feature_id(const char* feature_name);
399