Home | History | Annotate | Download | only in include
      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 "btcore/include/bdaddr.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 levels
     44   // 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 re-transmissions as the
     60   // 3 Mbps packets have a lower link margin, and are more prone to interference. We can
     61   // disable 3DH packets (use only 2DH packets) for the ACL link to improve sensitivity
     62   // when streaming A2DP audio to the headset. Air sniffer logs show reduced
     63   // re-transmissions after switching to 2DH packets.
     64   //
     65   // Disable 3Mbps packets and use only 2Mbps packets for ACL links when streaming audio.
     66   INTEROP_2MBPS_LINK_ONLY
     67 } interop_feature_t;
     68 
     69 // Check if a given |addr| matches a known interoperability workaround as identified
     70 // by the |interop_feature_t| enum. This API is used for simple address based lookups
     71 // where more information is not available. No look-ups or random address resolution
     72 // are performed on |addr|.
     73 bool interop_match_addr(const interop_feature_t feature, const bt_bdaddr_t *addr);
     74 
     75 // Check if a given remote device |name| matches a known interoperability workaround.
     76 // Name comparisons are case sensitive and do not allow for partial matches. As in, if
     77 // |name| is "TEST" and a workaround exists for "TESTING", then this function will
     78 // return false. But, if |name| is "TESTING" and a workaround exists for "TEST", this
     79 // function will return true.
     80 // |name| cannot be null and must be null terminated.
     81 bool interop_match_name(const interop_feature_t feature, const char *name);
     82 
     83 // Add a dynamic interop database entry for a device matching the first |length| bytes
     84 // of |addr|, implementing the workaround identified by |feature|. |addr| may not be
     85 // null and |length| must be greater than 0 and less than sizeof(bt_bdaddr_t).
     86 // As |interop_feature_t| is not exposed in the public API, feature must be a valid
     87 // integer representing an optoin in the enum.
     88 void interop_database_add(const uint16_t feature, const bt_bdaddr_t *addr, size_t length);
     89 
     90 // Clear the dynamic portion of the interoperability workaround database.
     91 void interop_database_clear(void);
     92