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 #include "device/include/interop.h"
20 
21 #include <gtest/gtest.h>
22 
23 #include "btcore/include/module.h"
24 #include "device/include/interop_config.h"
25 #include "types/raw_address.h"
26 
27 #ifndef __ANDROID__
28 #include <base/files/file_util.h>
29 #include <unistd.h>
30 
31 #include <filesystem>
32 #include <system_error>
33 
34 static const std::filesystem::path kStaticConfigFileConfigFile =
35     std::filesystem::temp_directory_path() / "interop_database.conf";
36 
37 static const char* INTEROP_STATIC_FILE_PATH =
38     kStaticConfigFileConfigFile.c_str();
39 static const char INTEROP_STATIC_FILE_CONTENT[] =
40     "                                                                                        \n\
41 #Disable secure connections                                                                  \n\
42 #This is for pre BT 4.1/2 devices that do not handle secure mode very well.                  \n\
43 [INTEROP_DISABLE_LE_SECURE_CONNECTIONS]                                                      \n\
44 08:62:66 = Address_Based                                                                     \n\
45 38:2C:4A:E6 = Address_Based                                                                  \n\
46                                                                                              \n\
47 # Disable automatic pairing with headsets/car-kits                                           \n\
48 # Some car kits do not react kindly to a failed pairing attempt and                          \n\
49 # do not allow immediate re-pairing. Denylist these so that the initial                      \n\
50 # pairing attempt makes it to the user instead                                               \n\
51 [INTEROP_DISABLE_AUTO_PAIRING]                                                               \n\
52 34:C7:31 = Address_Based                                                                     \n\
53 Audi = Name_Based                                                                            \n\
54 BMW = Name_Based                                                                             \n\
55                                                                                              \n\
56 # Devices requiring this workaround do not handle Bluetooth Absolute Volume                  \n\
57 # control correctly, leading to undesirable (potentially harmful) volume levels              \n\
58 # or general lack of controlability.                                                         \n\
59 [INTEROP_DISABLE_ABSOLUTE_VOLUME]                                                            \n\
60 A0:E9:DB = Address_Based                                                                     \n\
61 00:0f:59:50:00:00-00:0f:59:6f:ff:ff = Address_Range_Based                                    \n\
62                                                                                              \n\
63 # HID Keyboards that claim support for multitouch functionality have issue with              \n\
64 # normal functioning of keyboard because of issues in USB HID kernel driver.                 \n\
65 # To avoid degrading the user experience with those devices, digitizer record                \n\
66 # is removed from the report descriptor.                                                     \n\
67 [INTEROP_REMOVE_HID_DIG_DESCRIPTOR]                                                          \n\
68 Motorola Keyboard KZ500 = Name_Based                                                         \n\
69 0x22b8-0x093D = Vndr_Prdt_Based                                                              \n\
70                                                                                              \n\
71 # some remote hid devices cannot work properly as they laod special hid usb driver in kernel,\n\
72 # so modify their vid/pid so that generic hid driver are loaded.                             \n\
73 [INTEROP_CHANGE_HID_VID_PID]                                                                 \n\
74 CK87BT = Name_Based                                                                          \n\
75 0x05ac-0x0255 = Vndr_Prdt_Based                                                              \n\
76                                                                                              \n\
77 # Some HID devices have problematic behaviour where when hid link is in Sniff                \n\
78 # and DUT is in Peripheral role for SCO link ( not eSCO) any solution cannot maintain        \n\
79 # the link as  SCO scheduling over a short period will overlap with Sniff link due to        \n\
80 # peripheral drift.                                                                          \n\
81 # To avoid degrading the user experience with those devices, sniff is disabled from          \n\
82 # link policy when sco is active, and enabled when sco is disabled.                          \n\
83 [INTEROP_DISABLE_SNIFF_DURING_SCO]                                                           \n\
84 20:4C:10 = Address_Based                                                                     \n\
85 0x004C = Manufacturer_Based                                                                  \n\
86                                                                                              \n\
87 # Devices requiring this workaround do not handle SSR max latency values as mentioned,       \n\
88 # in their SDP HID Record properly and lead to connection timeout or lags. To prevent        \n\
89 # such scenarios, device requiring this workaorund need to use specific ssr max latency      \n\
90 # values.                                                                                    \n\
91 [INTEROP_UPDATE_HID_SSR_MAX_LAT]                                                             \n\
92 00:1B:DC-0x0012 = SSR_Max_Lat_Based                                                          \n\
93 DC:2C:26-0x0000 = SSR_Max_Lat_Based                                                          \n\
94 ";
95 #endif
96 
97 extern const module_t interop_module;
98 
99 class InteropTest : public ::testing::Test {
100  protected:
SetUp()101   virtual void SetUp() override {
102 #ifndef __ANDROID__
103     FILE* fp = fopen(INTEROP_STATIC_FILE_PATH, "wte");
104     ASSERT_NE(fp, nullptr);
105     ASSERT_EQ(fwrite(INTEROP_STATIC_FILE_CONTENT, 1,
106                      sizeof(INTEROP_STATIC_FILE_CONTENT), fp),
107               sizeof(INTEROP_STATIC_FILE_CONTENT));
108     // Force data to be flushed on disk and not only in user-space
109     ASSERT_EQ(fsync(fileno(fp)), 0)
110         << "Associated ERRNO error is: " << strerror(errno);
111     ASSERT_EQ(fclose(fp), 0);
112 #endif
113   }
TearDown()114   virtual void TearDown() override {
115 #ifndef __ANDROID__
116     std::error_code ec;
117     EXPECT_TRUE(std::filesystem::remove(kStaticConfigFileConfigFile, ec))
118         << "Associated error is: " << ec;
119 #endif
120   }
121 };
122 
TEST_F(InteropTest,test_lookup_hit)123 TEST_F(InteropTest, test_lookup_hit) {
124   module_init(&interop_module);
125 
126   RawAddress test_address;
127 
128   RawAddress::FromString("38:2c:4a:e6:67:89", test_address);
129   EXPECT_TRUE(
130       interop_match_addr(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, &test_address));
131 
132   RawAddress::FromString("34:c7:31:12:34:56", test_address);
133   EXPECT_TRUE(interop_match_addr(INTEROP_DISABLE_AUTO_PAIRING, &test_address));
134 
135 #ifdef __ANDROID__
136   RawAddress::FromString("9c:df:03:12:34:56", test_address);
137   EXPECT_TRUE(interop_match_addr(INTEROP_AUTO_RETRY_PAIRING, &test_address));
138 
139   RawAddress::FromString("a0:e9:db:e6:67:89", test_address);
140   EXPECT_TRUE(
141       interop_match_addr(INTEROP_DISABLE_ABSOLUTE_VOLUME, &test_address));
142 
143   RawAddress::FromString("00:0f:f6:e6:67:89", test_address);
144   EXPECT_TRUE(
145       interop_match_addr(INTEROP_KEYBOARD_REQUIRES_FIXED_PIN, &test_address));
146 
147   RawAddress::FromString("00:18:91:12:34:56", test_address);
148   EXPECT_TRUE(interop_match_addr(INTEROP_2MBPS_LINK_ONLY, &test_address));
149 
150   RawAddress::FromString("00:12:a1:e6:67:89", test_address);
151   EXPECT_TRUE(
152       interop_match_addr(INTEROP_DISABLE_AUTH_FOR_HID_POINTING, &test_address));
153 
154   RawAddress::FromString("20:4c:10:12:34:56", test_address);
155   EXPECT_TRUE(
156       interop_match_addr(INTEROP_DISABLE_SNIFF_DURING_SCO, &test_address));
157 
158   RawAddress::FromString("00:14:09:e6:67:89", test_address);
159   EXPECT_TRUE(
160       interop_match_addr(INTEROP_INCREASE_AG_CONN_TIMEOUT, &test_address));
161 
162   RawAddress::FromString("fc:c2:de:12:34:56", test_address);
163   EXPECT_TRUE(interop_match_addr(INTEROP_DISABLE_ROLE_SWITCH, &test_address));
164 
165   RawAddress::FromString("28:a1:83:9c:20:a8", test_address);
166   EXPECT_TRUE(interop_match_addr(INTEROP_DISABLE_AAC_CODEC, &test_address));
167 
168   RawAddress::FromString("28:83:35:7a:5f:23", test_address);
169   EXPECT_TRUE(interop_match_addr(INTEROP_DISABLE_AAC_VBR_CODEC, &test_address));
170 
171   RawAddress::FromString("b8:ad:3e:12:34:56", test_address);
172   EXPECT_TRUE(interop_match_addr(INTEROP_ENABLE_AAC_CODEC, &test_address));
173 
174   RawAddress::FromString("ac:fd:ce:e6:67:89", test_address);
175   EXPECT_TRUE(
176       interop_match_addr(INTEROP_DISABLE_PCE_SDP_AFTER_PAIRING, &test_address));
177 
178   RawAddress::FromString("98:7b:f3:12:34:56", test_address);
179   EXPECT_TRUE(interop_match_addr(INTEROP_DISABLE_HF_INDICATOR, &test_address));
180 
181   RawAddress::FromString("04:52:c7:e6:67:89", test_address);
182   EXPECT_TRUE(interop_match_addr(INTEROP_DELAY_SCO_FOR_MT_CALL, &test_address));
183 
184   RawAddress::FromString("04:52:c7:12:34:56", test_address);
185   EXPECT_TRUE(interop_match_addr(INTEROP_DELAY_SCO_FOR_MT_CALL, &test_address));
186 
187   RawAddress::FromString("00:08:8a:f0:1d:8a", test_address);
188   EXPECT_TRUE(
189       interop_match_addr(INTEROP_DISABLE_CODEC_NEGOTIATION, &test_address));
190 
191   RawAddress::FromString("a0:56:b2:4f:86:a8", test_address);
192   EXPECT_TRUE(interop_match_addr(
193       INTEROP_DISABLE_PLAYER_APPLICATION_SETTING_CMDS, &test_address));
194 
195   RawAddress::FromString("a0:14:3d:e6:67:89", test_address);
196   EXPECT_TRUE(interop_match_addr(INTEROP_DISABLE_CONNECTION_AFTER_COLLISION,
197                                  &test_address));
198 
199   RawAddress::FromString("38:2c:4a:c9:34:56", test_address);
200   EXPECT_TRUE(
201       interop_match_addr(INTEROP_HID_PREF_CONN_SUP_TIMEOUT_3S, &test_address));
202 
203   RawAddress::FromString("00:1d:86:e6:67:89", test_address);
204   EXPECT_TRUE(
205       interop_match_addr(INTEROP_DISABLE_AVDTP_RECONFIGURE, &test_address));
206 
207   RawAddress::FromString("2c:dc:ad:08:91:89", test_address);
208   EXPECT_TRUE(interop_match_addr(INTEROP_AVRCP_BROWSE_OPEN_CHANNEL_COLLISION,
209                                  &test_address));
210 
211   RawAddress::FromString("10:b7:f6:03:38:b0", test_address);
212   EXPECT_TRUE(
213       interop_match_addr(INTEROP_DISABLE_SNIFF_DURING_CALL, &test_address));
214 
215   RawAddress::FromString("00:0e:9f:12:34:56", test_address);
216   EXPECT_TRUE(interop_match_addr(INTEROP_SKIP_INCOMING_STATE, &test_address));
217 
218   RawAddress::FromString("98:b6:e9:e6:67:89", test_address);
219   EXPECT_TRUE(
220       interop_match_addr(INTEROP_HID_HOST_LIMIT_SNIFF_INTERVAL, &test_address));
221 
222   RawAddress::FromString("04:4e:af:a8:a0:01", test_address);
223   EXPECT_TRUE(interop_match_addr(INTEROP_DISABLE_REFRESH_ACCEPT_SIG_TIMER,
224                                  &test_address));
225 
226   RawAddress::FromString("bc:30:7e:5e:f6:27", test_address);
227   EXPECT_TRUE(interop_match_addr(INTEROP_NOT_UPDATE_AVRCP_PAUSED_TO_REMOTE,
228                                  &test_address));
229 
230   RawAddress::FromString("10:4f:a8:08:91:89", test_address);
231   EXPECT_TRUE(interop_match_addr(
232       INTEROP_PHONE_POLICY_REDUCED_DELAY_CONNECT_OTHER_PROFILES,
233       &test_address));
234 
235   RawAddress::FromString("00:15:83:03:38:b0", test_address);
236   EXPECT_TRUE(interop_match_addr(INTEROP_HFP_FAKE_INCOMING_CALL_INDICATOR,
237                                  &test_address));
238 
239   RawAddress::FromString("00:09:93:a6:c5:4d", test_address);
240   EXPECT_TRUE(interop_match_addr(INTEROP_DELAY_SCO_FOR_MO_CALL, &test_address));
241 
242   RawAddress::FromString("48:eb:62:e6:67:89", test_address);
243   EXPECT_TRUE(interop_match_addr(INTEROP_DISABLE_ROLE_SWITCH_DURING_CONNECTION,
244                                  &test_address));
245 
246   RawAddress::FromString("9c:df:03:a8:a0:01", test_address);
247   EXPECT_TRUE(interop_match_addr(INTEROP_AUTO_RETRY_PAIRING, &test_address));
248 
249   RawAddress::FromString("d4:7a:e2:5e:f6:27", test_address);
250   EXPECT_TRUE(interop_match_addr(INTEROP_DISABLE_NAME_REQUEST, &test_address));
251 
252   RawAddress::FromString("48:f0:7b:08:91:89", test_address);
253   EXPECT_TRUE(interop_match_addr(INTEROP_AVRCP_1_4_ONLY, &test_address));
254 
255   RawAddress::FromString("00:0a:08:03:38:b0", test_address);
256   EXPECT_TRUE(interop_match_addr(INTEROP_AVRCP_1_3_ONLY, &test_address));
257 
258   RawAddress::FromString("44:ea:d8:a6:c5:4d", test_address);
259   EXPECT_TRUE(interop_match_addr(INTEROP_DISABLE_SNIFF, &test_address));
260 
261   RawAddress::FromString("94:b2:cc:30:c5:4d", test_address);
262   EXPECT_TRUE(interop_match_addr(INTEROP_SLC_SKIP_BIND_COMMAND, &test_address));
263 #endif
264 
265   module_clean_up(&interop_module);
266 }
267 
TEST_F(InteropTest,test_lookup_miss)268 TEST_F(InteropTest, test_lookup_miss) {
269   module_init(&interop_module);
270 
271   RawAddress test_address;
272 
273   RawAddress::FromString("00:00:00:00:00:00", test_address);
274   EXPECT_FALSE(
275       interop_match_addr(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, &test_address));
276 
277   RawAddress::FromString("ff:ff:ff:ff:ff:ff", test_address);
278   EXPECT_FALSE(interop_match_addr(INTEROP_AUTO_RETRY_PAIRING, &test_address));
279 
280   RawAddress::FromString("42:08:15:ae:ae:ae", test_address);
281   EXPECT_FALSE(
282       interop_match_addr(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, &test_address));
283 
284   RawAddress::FromString("38:2c:4a:59:67:89", test_address);
285   EXPECT_FALSE(interop_match_addr(INTEROP_AUTO_RETRY_PAIRING, &test_address));
286 
287   RawAddress::FromString("ff:ff:ff:ff:ff:ff", test_address);
288   EXPECT_FALSE(
289       interop_match_addr(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, &test_address));
290   EXPECT_FALSE(interop_match_addr(INTEROP_AUTO_RETRY_PAIRING, &test_address));
291   EXPECT_FALSE(
292       interop_match_addr(INTEROP_DISABLE_ABSOLUTE_VOLUME, &test_address));
293   EXPECT_FALSE(interop_match_addr(INTEROP_DISABLE_AUTO_PAIRING, &test_address));
294   EXPECT_FALSE(
295       interop_match_addr(INTEROP_KEYBOARD_REQUIRES_FIXED_PIN, &test_address));
296   EXPECT_FALSE(interop_match_addr(INTEROP_2MBPS_LINK_ONLY, &test_address));
297   EXPECT_FALSE(
298       interop_match_addr(INTEROP_HID_PREF_CONN_SUP_TIMEOUT_3S, &test_address));
299   EXPECT_FALSE(
300       interop_match_addr(INTEROP_GATTC_NO_SERVICE_CHANGED_IND, &test_address));
301   EXPECT_FALSE(
302       interop_match_addr(INTEROP_DISABLE_SDP_AFTER_PAIRING, &test_address));
303   EXPECT_FALSE(
304       interop_match_addr(INTEROP_DISABLE_AUTH_FOR_HID_POINTING, &test_address));
305   EXPECT_FALSE(
306       interop_match_addr(INTEROP_REMOVE_HID_DIG_DESCRIPTOR, &test_address));
307   EXPECT_FALSE(
308       interop_match_addr(INTEROP_DISABLE_SNIFF_DURING_SCO, &test_address));
309   EXPECT_FALSE(
310       interop_match_addr(INTEROP_INCREASE_AG_CONN_TIMEOUT, &test_address));
311   EXPECT_FALSE(interop_match_addr(INTEROP_DISABLE_LE_CONN_PREFERRED_PARAMS,
312                                   &test_address));
313   EXPECT_FALSE(interop_match_addr(INTEROP_DISABLE_AAC_CODEC, &test_address));
314   EXPECT_FALSE(
315       interop_match_addr(INTEROP_DISABLE_AAC_VBR_CODEC, &test_address));
316   EXPECT_FALSE(interop_match_addr(INTEROP_DYNAMIC_ROLE_SWITCH, &test_address));
317   EXPECT_FALSE(interop_match_addr(INTEROP_DISABLE_ROLE_SWITCH, &test_address));
318   EXPECT_FALSE(
319       interop_match_addr(INTEROP_DISABLE_ROLE_SWITCH_POLICY, &test_address));
320   EXPECT_FALSE(interop_match_addr(INTEROP_HFP_1_7_DENYLIST, &test_address));
321   EXPECT_FALSE(interop_match_addr(INTEROP_ADV_PBAP_VER_1_1, &test_address));
322   EXPECT_FALSE(
323       interop_match_addr(INTEROP_UPDATE_HID_SSR_MAX_LAT, &test_address));
324   EXPECT_FALSE(
325       interop_match_addr(INTEROP_DISABLE_AVDTP_RECONFIGURE, &test_address));
326   EXPECT_FALSE(interop_match_addr(INTEROP_DISABLE_HF_INDICATOR, &test_address));
327   EXPECT_FALSE(
328       interop_match_addr(INTEROP_DISABLE_LE_CONN_UPDATES, &test_address));
329   EXPECT_FALSE(
330       interop_match_addr(INTEROP_DELAY_SCO_FOR_MT_CALL, &test_address));
331   EXPECT_FALSE(
332       interop_match_addr(INTEROP_DISABLE_CODEC_NEGOTIATION, &test_address));
333   EXPECT_FALSE(interop_match_addr(
334       INTEROP_DISABLE_PLAYER_APPLICATION_SETTING_CMDS, &test_address));
335   EXPECT_FALSE(interop_match_addr(INTEROP_ENABLE_AAC_CODEC, &test_address));
336   EXPECT_FALSE(interop_match_addr(INTEROP_DISABLE_CONNECTION_AFTER_COLLISION,
337                                   &test_address));
338   EXPECT_FALSE(interop_match_addr(INTEROP_AVRCP_BROWSE_OPEN_CHANNEL_COLLISION,
339                                   &test_address));
340   EXPECT_FALSE(interop_match_addr(INTEROP_ADV_PBAP_VER_1_2, &test_address));
341   EXPECT_FALSE(
342       interop_match_addr(INTEROP_DISABLE_PCE_SDP_AFTER_PAIRING, &test_address));
343   EXPECT_FALSE(
344       interop_match_addr(INTEROP_DISABLE_SNIFF_LINK_DURING_SCO, &test_address));
345   EXPECT_FALSE(
346       interop_match_addr(INTEROP_DISABLE_SNIFF_DURING_CALL, &test_address));
347   EXPECT_FALSE(
348       interop_match_addr(INTEROP_HID_HOST_LIMIT_SNIFF_INTERVAL, &test_address));
349   EXPECT_FALSE(interop_match_addr(INTEROP_DISABLE_REFRESH_ACCEPT_SIG_TIMER,
350                                   &test_address));
351   EXPECT_FALSE(interop_match_addr(INTEROP_SKIP_INCOMING_STATE, &test_address));
352   EXPECT_FALSE(interop_match_addr(INTEROP_NOT_UPDATE_AVRCP_PAUSED_TO_REMOTE,
353                                   &test_address));
354   EXPECT_FALSE(interop_match_addr(
355       INTEROP_PHONE_POLICY_INCREASED_DELAY_CONNECT_OTHER_PROFILES,
356       &test_address));
357   EXPECT_FALSE(interop_match_addr(
358       INTEROP_PHONE_POLICY_REDUCED_DELAY_CONNECT_OTHER_PROFILES,
359       &test_address));
360   EXPECT_FALSE(interop_match_addr(INTEROP_HFP_FAKE_INCOMING_CALL_INDICATOR,
361                                   &test_address));
362   EXPECT_FALSE(interop_match_addr(INTEROP_HFP_SEND_CALL_INDICATORS_BACK_TO_BACK,
363                                   &test_address));
364   EXPECT_FALSE(interop_match_addr(
365       INTEROP_SETUP_SCO_WITH_NO_DELAY_AFTER_SLC_DURING_CALL, &test_address));
366   EXPECT_FALSE(interop_match_addr(INTEROP_ENABLE_PREFERRED_CONN_PARAMETER,
367                                   &test_address));
368   EXPECT_FALSE(interop_match_addr(INTEROP_RETRY_SCO_AFTER_REMOTE_REJECT_SCO,
369                                   &test_address));
370   EXPECT_FALSE(
371       interop_match_addr(INTEROP_DELAY_SCO_FOR_MO_CALL, &test_address));
372   EXPECT_FALSE(interop_match_addr(INTEROP_CHANGE_HID_VID_PID, &test_address));
373   EXPECT_FALSE(interop_match_addr(END_OF_INTEROP_LIST, &test_address));
374   EXPECT_FALSE(interop_match_addr(INTEROP_HFP_1_8_DENYLIST, &test_address));
375   EXPECT_FALSE(interop_match_addr(INTEROP_DISABLE_ROLE_SWITCH_DURING_CONNECTION,
376                                   &test_address));
377   EXPECT_FALSE(interop_match_addr(INTEROP_DISABLE_NAME_REQUEST, &test_address));
378   EXPECT_FALSE(interop_match_addr(INTEROP_AVRCP_1_4_ONLY, &test_address));
379   EXPECT_FALSE(interop_match_addr(INTEROP_DISABLE_SNIFF, &test_address));
380   EXPECT_FALSE(
381       interop_match_addr(INTEROP_DISABLE_AVDTP_SUSPEND, &test_address));
382   EXPECT_FALSE(
383       interop_match_addr(INTEROP_SLC_SKIP_BIND_COMMAND, &test_address));
384   EXPECT_FALSE(interop_match_addr(INTEROP_AVRCP_1_3_ONLY, &test_address));
385 
386   module_clean_up(&interop_module);
387 }
388 
TEST_F(InteropTest,test_dynamic_db_clear)389 TEST_F(InteropTest, test_dynamic_db_clear) {
390   module_init(&interop_module);
391 
392   RawAddress test_address;
393 
394   RawAddress::FromString("11:22:33:44:55:66", test_address);
395   EXPECT_FALSE(
396       interop_match_addr(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, &test_address));
397 
398   interop_database_add(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, &test_address, 3);
399   EXPECT_TRUE(
400       interop_match_addr(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, &test_address));
401   EXPECT_FALSE(interop_match_addr(INTEROP_AUTO_RETRY_PAIRING, &test_address));
402 
403   RawAddress::FromString("66:55:44:33:22:11", test_address);
404   EXPECT_FALSE(interop_match_addr(INTEROP_AUTO_RETRY_PAIRING, &test_address));
405 
406   interop_database_add(INTEROP_AUTO_RETRY_PAIRING, &test_address, 3);
407   EXPECT_TRUE(interop_match_addr(INTEROP_AUTO_RETRY_PAIRING, &test_address));
408   EXPECT_FALSE(
409       interop_match_addr(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, &test_address));
410 
411   interop_database_clear();
412 
413   EXPECT_FALSE(interop_match_addr(INTEROP_AUTO_RETRY_PAIRING, &test_address));
414 
415   module_clean_up(&interop_module);
416 }
417 
TEST_F(InteropTest,test_name_hit)418 TEST_F(InteropTest, test_name_hit) {
419   module_init(&interop_module);
420 
421   EXPECT_TRUE(interop_match_name(INTEROP_DISABLE_AUTO_PAIRING, "BMW M3"));
422   EXPECT_TRUE(interop_match_name(INTEROP_DISABLE_AUTO_PAIRING, "Audi"));
423 
424 #ifdef __ANDROID__
425   EXPECT_TRUE(interop_match_name(INTEROP_DISABLE_AUTO_PAIRING,
426                                  "Caramel"));  // Starts with "Car" ;)
427 
428   EXPECT_TRUE(
429       interop_match_name(INTEROP_GATTC_NO_SERVICE_CHANGED_IND, "MiMouse"));
430   EXPECT_TRUE(interop_match_name(INTEROP_DISABLE_AUTH_FOR_HID_POINTING,
431                                  "Targus BT Laser Notebook Mouse"));
432   EXPECT_TRUE(interop_match_name(INTEROP_REMOVE_HID_DIG_DESCRIPTOR,
433                                  "Motorola Keyboard KZ500"));
434   EXPECT_TRUE(interop_match_name(INTEROP_DISABLE_LE_CONN_PREFERRED_PARAMS,
435                                  "BSMBB09DS"));
436   EXPECT_TRUE(interop_match_name(INTEROP_DISABLE_AAC_CODEC, "abramtek M1"));
437   EXPECT_TRUE(
438       interop_match_name(INTEROP_DISABLE_AAC_VBR_CODEC, "Audi_MMI_2781"));
439   EXPECT_TRUE(
440       interop_match_name(INTEROP_DISABLE_AVDTP_RECONFIGURE, "KMM-BT51*HD"));
441   EXPECT_TRUE(interop_match_name(INTEROP_DISABLE_LE_CONN_UPDATES, "ITAG"));
442   EXPECT_TRUE(interop_match_name(INTEROP_DELAY_SCO_FOR_MT_CALL, "AirPods Pro"));
443   EXPECT_TRUE(
444       interop_match_name(INTEROP_DISABLE_CODEC_NEGOTIATION, "JABRA EASYGO"));
445   EXPECT_TRUE(interop_match_name(INTEROP_ENABLE_AAC_CODEC, "MDR-1RBT"));
446   EXPECT_TRUE(
447       interop_match_name(INTEROP_DISABLE_SNIFF_LINK_DURING_SCO, "AirPods"));
448   EXPECT_TRUE(interop_match_name(INTEROP_DISABLE_SNIFF_DURING_CALL, "AirPods"));
449   EXPECT_TRUE(
450       interop_match_name(INTEROP_HID_HOST_LIMIT_SNIFF_INTERVAL, "Joy-Con"));
451   EXPECT_TRUE(
452       interop_match_name(INTEROP_DISABLE_REFRESH_ACCEPT_SIG_TIMER, "HB20"));
453   EXPECT_TRUE(
454       interop_match_name(INTEROP_NOT_UPDATE_AVRCP_PAUSED_TO_REMOTE, "Audi"));
455   EXPECT_TRUE(interop_match_name(
456       INTEROP_SETUP_SCO_WITH_NO_DELAY_AFTER_SLC_DURING_CALL, "Geely_BT"));
457   EXPECT_TRUE(interop_match_name(INTEROP_ENABLE_PREFERRED_CONN_PARAMETER,
458                                  "Microsoft Bluetooth Mouse"));
459   EXPECT_TRUE(interop_match_name(INTEROP_RETRY_SCO_AFTER_REMOTE_REJECT_SCO,
460                                  "HAVAL M6"));
461   EXPECT_TRUE(interop_match_name(INTEROP_CHANGE_HID_VID_PID, "CK87BT"));
462 #endif
463 
464   module_clean_up(&interop_module);
465 }
466 
TEST_F(InteropTest,test_name_miss)467 TEST_F(InteropTest, test_name_miss) {
468   module_init(&interop_module);
469 
470   EXPECT_FALSE(interop_match_name(INTEROP_DISABLE_AUTO_PAIRING, "__GOOGLE__"));
471   EXPECT_FALSE(interop_match_name(INTEROP_DISABLE_AUTO_PAIRING, "BM"));
472   EXPECT_FALSE(interop_match_name(INTEROP_AUTO_RETRY_PAIRING, "BMW M3"));
473   EXPECT_FALSE(
474       interop_match_name(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, "TEST"));
475   EXPECT_FALSE(interop_match_name(INTEROP_AUTO_RETRY_PAIRING, "TEST"));
476   EXPECT_FALSE(interop_match_name(INTEROP_DISABLE_ABSOLUTE_VOLUME, "TEST"));
477   EXPECT_FALSE(interop_match_name(INTEROP_DISABLE_AUTO_PAIRING, "TEST"));
478   EXPECT_FALSE(interop_match_name(INTEROP_KEYBOARD_REQUIRES_FIXED_PIN, "TEST"));
479   EXPECT_FALSE(interop_match_name(INTEROP_2MBPS_LINK_ONLY, "TEST"));
480   EXPECT_FALSE(
481       interop_match_name(INTEROP_HID_PREF_CONN_SUP_TIMEOUT_3S, "TEST"));
482   EXPECT_FALSE(
483       interop_match_name(INTEROP_GATTC_NO_SERVICE_CHANGED_IND, "TEST"));
484   EXPECT_FALSE(interop_match_name(INTEROP_DISABLE_SDP_AFTER_PAIRING, "TEST"));
485   EXPECT_FALSE(
486       interop_match_name(INTEROP_DISABLE_AUTH_FOR_HID_POINTING, "TEST"));
487   EXPECT_FALSE(interop_match_name(INTEROP_REMOVE_HID_DIG_DESCRIPTOR, "TEST"));
488   EXPECT_FALSE(interop_match_name(INTEROP_DISABLE_SNIFF_DURING_SCO, "TEST"));
489   EXPECT_FALSE(interop_match_name(INTEROP_INCREASE_AG_CONN_TIMEOUT, "TEST"));
490   EXPECT_FALSE(
491       interop_match_name(INTEROP_DISABLE_LE_CONN_PREFERRED_PARAMS, "TEST"));
492   EXPECT_FALSE(interop_match_name(INTEROP_DISABLE_AAC_CODEC, "TEST"));
493   EXPECT_FALSE(interop_match_name(INTEROP_DISABLE_AAC_VBR_CODEC, "TEST"));
494   EXPECT_FALSE(interop_match_name(INTEROP_DYNAMIC_ROLE_SWITCH, "TEST"));
495   EXPECT_FALSE(interop_match_name(INTEROP_DISABLE_ROLE_SWITCH, "TEST"));
496   EXPECT_FALSE(interop_match_name(INTEROP_DISABLE_ROLE_SWITCH_POLICY, "TEST"));
497   EXPECT_FALSE(interop_match_name(INTEROP_HFP_1_7_DENYLIST, "TEST"));
498   EXPECT_FALSE(interop_match_name(INTEROP_ADV_PBAP_VER_1_1, "TEST"));
499   EXPECT_FALSE(interop_match_name(INTEROP_UPDATE_HID_SSR_MAX_LAT, "TEST"));
500   EXPECT_FALSE(interop_match_name(INTEROP_DISABLE_AVDTP_RECONFIGURE, "TEST"));
501   EXPECT_FALSE(interop_match_name(INTEROP_DISABLE_HF_INDICATOR, "TEST"));
502   EXPECT_FALSE(interop_match_name(INTEROP_DISABLE_LE_CONN_UPDATES, "TEST"));
503   EXPECT_FALSE(interop_match_name(INTEROP_DELAY_SCO_FOR_MT_CALL, "TEST"));
504   EXPECT_FALSE(interop_match_name(INTEROP_DISABLE_CODEC_NEGOTIATION, "TEST"));
505   EXPECT_FALSE(interop_match_name(
506       INTEROP_DISABLE_PLAYER_APPLICATION_SETTING_CMDS, "TEST"));
507   EXPECT_FALSE(interop_match_name(INTEROP_ENABLE_AAC_CODEC, "TEST"));
508   EXPECT_FALSE(
509       interop_match_name(INTEROP_DISABLE_CONNECTION_AFTER_COLLISION, "TEST"));
510   EXPECT_FALSE(
511       interop_match_name(INTEROP_AVRCP_BROWSE_OPEN_CHANNEL_COLLISION, "TEST"));
512   EXPECT_FALSE(interop_match_name(INTEROP_ADV_PBAP_VER_1_2, "TEST"));
513   EXPECT_FALSE(
514       interop_match_name(INTEROP_DISABLE_PCE_SDP_AFTER_PAIRING, "TEST"));
515   EXPECT_FALSE(
516       interop_match_name(INTEROP_DISABLE_SNIFF_LINK_DURING_SCO, "TEST"));
517   EXPECT_FALSE(interop_match_name(INTEROP_DISABLE_SNIFF_DURING_CALL, "TEST"));
518   EXPECT_FALSE(
519       interop_match_name(INTEROP_HID_HOST_LIMIT_SNIFF_INTERVAL, "TEST"));
520   EXPECT_FALSE(
521       interop_match_name(INTEROP_DISABLE_REFRESH_ACCEPT_SIG_TIMER, "TEST"));
522   EXPECT_FALSE(interop_match_name(INTEROP_SKIP_INCOMING_STATE, "TEST"));
523   EXPECT_FALSE(
524       interop_match_name(INTEROP_NOT_UPDATE_AVRCP_PAUSED_TO_REMOTE, "TEST"));
525   EXPECT_FALSE(interop_match_name(
526       INTEROP_PHONE_POLICY_INCREASED_DELAY_CONNECT_OTHER_PROFILES, "TEST"));
527   EXPECT_FALSE(interop_match_name(
528       INTEROP_PHONE_POLICY_REDUCED_DELAY_CONNECT_OTHER_PROFILES, "TEST"));
529   EXPECT_FALSE(
530       interop_match_name(INTEROP_HFP_FAKE_INCOMING_CALL_INDICATOR, "TEST"));
531   EXPECT_FALSE(interop_match_name(INTEROP_HFP_SEND_CALL_INDICATORS_BACK_TO_BACK,
532                                   "TEST"));
533   EXPECT_FALSE(interop_match_name(
534       INTEROP_SETUP_SCO_WITH_NO_DELAY_AFTER_SLC_DURING_CALL, "TEST"));
535   EXPECT_FALSE(
536       interop_match_name(INTEROP_ENABLE_PREFERRED_CONN_PARAMETER, "TEST"));
537   EXPECT_FALSE(
538       interop_match_name(INTEROP_RETRY_SCO_AFTER_REMOTE_REJECT_SCO, "TEST"));
539   EXPECT_FALSE(interop_match_name(INTEROP_DELAY_SCO_FOR_MO_CALL, "TEST"));
540   EXPECT_FALSE(interop_match_name(INTEROP_CHANGE_HID_VID_PID, "TEST"));
541   EXPECT_FALSE(interop_match_name(INTEROP_HFP_1_8_DENYLIST, "TEST"));
542   EXPECT_FALSE(interop_match_name(INTEROP_DISABLE_ROLE_SWITCH_DURING_CONNECTION,
543                                   "TEST"));
544   EXPECT_FALSE(interop_match_name(INTEROP_DISABLE_NAME_REQUEST, "TEST"));
545   EXPECT_FALSE(interop_match_name(INTEROP_AVRCP_1_4_ONLY, "TEST"));
546   EXPECT_FALSE(interop_match_name(INTEROP_DISABLE_SNIFF, "TEST"));
547   EXPECT_FALSE(interop_match_name(INTEROP_DISABLE_AVDTP_SUSPEND, "TEST"));
548   EXPECT_FALSE(interop_match_name(INTEROP_SLC_SKIP_BIND_COMMAND, "TEST"));
549   EXPECT_FALSE(interop_match_name(INTEROP_AVRCP_1_3_ONLY, "TEST"));
550 
551   module_clean_up(&interop_module);
552 }
553 
TEST_F(InteropTest,test_range_hit)554 TEST_F(InteropTest, test_range_hit) {
555   module_init(&interop_module);
556 
557   RawAddress test_address;
558   RawAddress::FromString("00:0f:59:50:00:00", test_address);
559   EXPECT_TRUE(
560       interop_match_addr(INTEROP_DISABLE_ABSOLUTE_VOLUME, &test_address));
561   RawAddress::FromString("00:0f:59:59:12:34", test_address);
562   EXPECT_TRUE(
563       interop_match_addr(INTEROP_DISABLE_ABSOLUTE_VOLUME, &test_address));
564   RawAddress::FromString("00:0f:59:6f:ff:ff", test_address);
565   EXPECT_TRUE(
566       interop_match_addr(INTEROP_DISABLE_ABSOLUTE_VOLUME, &test_address));
567 
568   module_clean_up(&interop_module);
569 }
570 
TEST_F(InteropTest,test_range_miss)571 TEST_F(InteropTest, test_range_miss) {
572   module_init(&interop_module);
573 
574   RawAddress test_address;
575   RawAddress::FromString("00:0f:59:49:12:34", test_address);
576   EXPECT_FALSE(
577       interop_match_addr(INTEROP_DISABLE_ABSOLUTE_VOLUME, &test_address));
578   RawAddress::FromString("00:0f:59:70:12:34", test_address);
579   EXPECT_FALSE(
580       interop_match_addr(INTEROP_DISABLE_ABSOLUTE_VOLUME, &test_address));
581 
582   module_clean_up(&interop_module);
583 }
584 
TEST_F(InteropTest,test_vndr_prdt_hit)585 TEST_F(InteropTest, test_vndr_prdt_hit) {
586   module_init(&interop_module);
587 
588   uint16_t vendor_id = 0x22b8;
589   uint16_t product_id = 0x093D;
590 
591   EXPECT_TRUE(interop_database_match_vndr_prdt(
592       INTEROP_REMOVE_HID_DIG_DESCRIPTOR, vendor_id, product_id));
593 
594   vendor_id = 0x05ac;
595   product_id = 0x0255;
596 
597   EXPECT_TRUE(interop_database_match_vndr_prdt(INTEROP_CHANGE_HID_VID_PID,
598                                                vendor_id, product_id));
599 
600   module_clean_up(&interop_module);
601 }
602 
TEST_F(InteropTest,test_vndr_prdt_miss)603 TEST_F(InteropTest, test_vndr_prdt_miss) {
604   module_init(&interop_module);
605 
606   uint16_t vendor_id = 0x22b9;
607   uint16_t product_id = 0x093D;
608 
609   EXPECT_FALSE(interop_database_match_vndr_prdt(
610       INTEROP_REMOVE_HID_DIG_DESCRIPTOR, vendor_id, product_id));
611 
612   module_clean_up(&interop_module);
613 }
614 
TEST_F(InteropTest,test_manufacturer_hit)615 TEST_F(InteropTest, test_manufacturer_hit) {
616   module_init(&interop_module);
617 
618   uint16_t manufacturer = 0x004C;
619 
620   EXPECT_TRUE(interop_database_match_manufacturer(
621       INTEROP_DISABLE_SNIFF_DURING_SCO, manufacturer));
622 
623   module_clean_up(&interop_module);
624 }
625 
TEST_F(InteropTest,test_manufacturer_miss)626 TEST_F(InteropTest, test_manufacturer_miss) {
627   module_init(&interop_module);
628 
629   uint16_t manufacturer = 0x004D;
630 
631   EXPECT_FALSE(interop_database_match_manufacturer(
632       INTEROP_DISABLE_SNIFF_DURING_SCO, manufacturer));
633 
634   module_clean_up(&interop_module);
635 }
636 
TEST_F(InteropTest,test_ssr_max_latency_hit)637 TEST_F(InteropTest, test_ssr_max_latency_hit) {
638   module_init(&interop_module);
639 
640   RawAddress test_address;
641   RawAddress::FromString("00:1b:dc:70:12:34", test_address);
642   uint16_t max_lat = 0;
643 
644   EXPECT_TRUE(interop_database_match_addr_get_max_lat(
645       INTEROP_UPDATE_HID_SSR_MAX_LAT, &test_address, &max_lat));
646   EXPECT_TRUE(max_lat == 0x0012);
647 
648   module_clean_up(&interop_module);
649 }
650 
TEST_F(InteropTest,test_ssr_max_latency_miss)651 TEST_F(InteropTest, test_ssr_max_latency_miss) {
652   module_init(&interop_module);
653 
654   RawAddress test_address;
655   RawAddress::FromString("00:1b:db:70:12:34", test_address);
656   uint16_t max_lat = 0;
657 
658   EXPECT_FALSE(interop_database_match_addr_get_max_lat(
659       INTEROP_UPDATE_HID_SSR_MAX_LAT, &test_address, &max_lat));
660 
661   module_clean_up(&interop_module);
662 }
663 
TEST_F(InteropTest,test_dynamic_addr)664 TEST_F(InteropTest, test_dynamic_addr) {
665   module_init(&interop_module);
666 
667   RawAddress test_address;
668 
669   RawAddress::FromString("11:22:33:44:55:66", test_address);
670   EXPECT_FALSE(
671       interop_match_addr(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, &test_address));
672 
673   interop_database_add_addr(INTEROP_DISABLE_LE_SECURE_CONNECTIONS,
674                             &test_address, 3);
675   EXPECT_TRUE(
676       interop_match_addr(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, &test_address));
677 
678   interop_database_remove_addr(INTEROP_DISABLE_LE_SECURE_CONNECTIONS,
679                                &test_address);
680   EXPECT_FALSE(
681       interop_match_addr(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, &test_address));
682 
683   module_clean_up(&interop_module);
684 }
685 
TEST_F(InteropTest,test_dynamic_name)686 TEST_F(InteropTest, test_dynamic_name) {
687   module_init(&interop_module);
688 
689   EXPECT_FALSE(
690       interop_match_name(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, "TEST"));
691 
692   interop_database_add_name(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, "TEST");
693   EXPECT_TRUE(
694       interop_match_name(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, "TEST"));
695 
696   interop_database_remove_name(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, "TEST");
697   EXPECT_FALSE(
698       interop_match_name(INTEROP_DISABLE_LE_SECURE_CONNECTIONS, "TEST"));
699 
700   module_clean_up(&interop_module);
701 }
702 
TEST_F(InteropTest,test_dynamic_vndr_prdt)703 TEST_F(InteropTest, test_dynamic_vndr_prdt) {
704   module_init(&interop_module);
705 
706   uint16_t vendor_id = 0x11b8;
707   uint16_t product_id = 0x193D;
708 
709   EXPECT_FALSE(interop_database_match_vndr_prdt(
710       INTEROP_REMOVE_HID_DIG_DESCRIPTOR, vendor_id, product_id));
711 
712   interop_database_add_vndr_prdt(INTEROP_REMOVE_HID_DIG_DESCRIPTOR, vendor_id,
713                                  product_id);
714   EXPECT_TRUE(interop_database_match_vndr_prdt(
715       INTEROP_REMOVE_HID_DIG_DESCRIPTOR, vendor_id, product_id));
716 
717   interop_database_remove_vndr_prdt(INTEROP_REMOVE_HID_DIG_DESCRIPTOR,
718                                     vendor_id, product_id);
719 
720   EXPECT_FALSE(interop_database_match_vndr_prdt(INTEROP_CHANGE_HID_VID_PID,
721                                                 vendor_id, product_id));
722 
723   module_clean_up(&interop_module);
724 }
725 
TEST_F(InteropTest,test_dynamic_addr_get_ssr_max_lat)726 TEST_F(InteropTest, test_dynamic_addr_get_ssr_max_lat) {
727   module_init(&interop_module);
728 
729   RawAddress test_address;
730   RawAddress::FromString("11:22:33:44:55:66", test_address);
731   uint16_t max_lat = 0;
732 
733   EXPECT_FALSE(interop_database_match_addr_get_max_lat(
734       INTEROP_UPDATE_HID_SSR_MAX_LAT, &test_address, &max_lat));
735   interop_database_add_addr_max_lat(INTEROP_UPDATE_HID_SSR_MAX_LAT,
736                                     &test_address, 0x0012);
737 
738   interop_database_match_addr_get_max_lat(INTEROP_UPDATE_HID_SSR_MAX_LAT,
739                                           &test_address, &max_lat);
740   EXPECT_TRUE(max_lat == 0x0012);
741 
742   interop_database_remove_addr_max_lat(INTEROP_UPDATE_HID_SSR_MAX_LAT,
743                                        &test_address, 0x0012);
744 
745   max_lat = 0;
746   EXPECT_FALSE(interop_database_match_addr_get_max_lat(
747       INTEROP_UPDATE_HID_SSR_MAX_LAT, &test_address, &max_lat));
748 
749   EXPECT_FALSE(max_lat == 0x0012);
750 
751   module_clean_up(&interop_module);
752 }
753 
TEST_F(InteropTest,test_dynamic_manufacturer)754 TEST_F(InteropTest, test_dynamic_manufacturer) {
755   module_init(&interop_module);
756 
757   uint16_t manufacturer = 0xFFFF;
758 
759   EXPECT_FALSE(interop_database_match_manufacturer(
760       INTEROP_DISABLE_SNIFF_DURING_SCO, manufacturer));
761 
762   interop_database_add_manufacturer(INTEROP_DISABLE_SNIFF_DURING_SCO,
763                                     manufacturer);
764 
765   EXPECT_TRUE(interop_database_match_manufacturer(
766       INTEROP_DISABLE_SNIFF_DURING_SCO, manufacturer));
767 
768   interop_database_remove_manufacturer(INTEROP_DISABLE_SNIFF_DURING_SCO,
769                                        manufacturer);
770 
771   EXPECT_FALSE(interop_database_match_manufacturer(
772       INTEROP_DISABLE_SNIFF_DURING_SCO, manufacturer));
773 
774   module_clean_up(&interop_module);
775 }
776 
TEST_F(InteropTest,test_dynamic_addr_get_lmp_version)777 TEST_F(InteropTest, test_dynamic_addr_get_lmp_version) {
778   module_init(&interop_module);
779 
780   RawAddress test_address;
781   RawAddress::FromString("11:22:33:44:55:66", test_address);
782   uint8_t lmp_version = 0;
783   uint16_t lmp_sub_version = 0;
784 
785   EXPECT_FALSE(interop_database_match_addr_get_lmp_ver(
786       INTEROP_DISABLE_SNIFF_DURING_SCO, &test_address, &lmp_version,
787       &lmp_sub_version));
788   interop_database_add_addr_lmp_version(INTEROP_DISABLE_SNIFF_DURING_SCO,
789                                         &test_address, 0xFF, 0xFFFF);
790 
791   EXPECT_TRUE(interop_database_match_addr_get_lmp_ver(
792       INTEROP_DISABLE_SNIFF_DURING_SCO, &test_address, &lmp_version,
793       &lmp_sub_version));
794 
795   EXPECT_TRUE(lmp_version == 0xFF && lmp_sub_version == 0xFFFF);
796 
797   interop_database_remove_addr_lmp_version(INTEROP_DISABLE_SNIFF_DURING_SCO,
798                                            &test_address, 0xFF, 0xFFFF);
799 
800   lmp_version = 0;
801   lmp_sub_version = 0;
802 
803   EXPECT_FALSE(interop_database_match_addr_get_lmp_ver(
804       INTEROP_DISABLE_SNIFF_DURING_SCO, &test_address, &lmp_version,
805       &lmp_sub_version));
806 
807   EXPECT_FALSE(lmp_version == 0xFF && lmp_sub_version == 0xFFFF);
808 
809   module_clean_up(&interop_module);
810 }
811 
TEST_F(InteropTest,test_dynamic_did_version)812 TEST_F(InteropTest, test_dynamic_did_version) {
813   module_init(&interop_module);
814 
815   RawAddress test_address;
816   RawAddress::FromString("11:22:33:44:55:66", test_address);
817   uint16_t did_version = 0xABCD;
818 
819   EXPECT_FALSE(interop_database_match_version(INTEROP_DISABLE_SNIFF_DURING_SCO,
820                                               did_version));
821   interop_database_add_version(INTEROP_DISABLE_SNIFF_DURING_SCO, did_version);
822 
823   EXPECT_TRUE(interop_database_match_version(INTEROP_DISABLE_SNIFF_DURING_SCO,
824                                              did_version));
825 
826   interop_database_remove_version(INTEROP_DISABLE_SNIFF_DURING_SCO,
827                                   did_version);
828 
829   EXPECT_FALSE(interop_database_match_version(INTEROP_DISABLE_SNIFF_DURING_SCO,
830                                               did_version));
831 
832   module_clean_up(&interop_module);
833 }
834