1#!/usr/bin/env python3
2#
3# Copyright (C) 2020 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may not
6# use this file except in compliance with the License. You may obtain a copy of
7# 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, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations under
15# the License.
16
17from acts_contrib.test_utils.bt.bt_constants import bt_attribute_values
18from acts_contrib.test_utils.bt.bt_constants import sig_uuid_constants
19
20BASE_UUID = sig_uuid_constants['BASE_UUID']
21
22# A list of pre-defined SDP definitions
23sdp_pts_record_list = [
24    {
25        'service_class_uuids': [BASE_UUID.format(sig_uuid_constants['AudioSink'])],
26        'protocol_descriptors': [
27            {
28                'protocol': int(sig_uuid_constants['L2CAP'], 16),
29                'params': [{
30                    'data': int(sig_uuid_constants['AVDTP'], 16),
31                }]
32            },
33            {
34                'protocol': int(sig_uuid_constants['AVDTP'], 16),
35                'params': [{
36                    'data': 0x103  # to indicate 1.3
37                }]
38            },
39        ],
40        'profile_descriptors': [{
41            'profile_id':
42            int(sig_uuid_constants['AdvancedAudioDistribution'], 16),
43            'major_version':
44            1,
45            'minor_version':
46            2,
47        }],
48        'additional_protocol_descriptors': [{
49            'protocol':
50            int(sig_uuid_constants['L2CAP'], 16),
51            'params': [
52                {
53                    'data': int(sig_uuid_constants['AVDTP'], 16),
54                },
55                {
56                    'data': int(sig_uuid_constants['AVCTP'], 16),
57                },
58                {
59                    'data': int(sig_uuid_constants['GenericAudio'], 16),
60                },
61            ]
62        }],
63        'information': [{
64            'language': "en",
65            'name': "A2DP",
66            'description': "Advanced Audio Distribution Profile",
67            'provider': "Fuchsia"
68        }],
69        'additional_attributes': [{
70            'id':
71            bt_attribute_values['ATTR_SERVICE_AVAILABILITY'],
72            'element': {
73                'data': 0xff  # Indicate all available
74            }
75        }]
76    },
77    {
78        'service_class_uuids': [
79            BASE_UUID.format(sig_uuid_constants['A/V_RemoteControlTarget']),
80            BASE_UUID.format(sig_uuid_constants['A/V_RemoteControl']),
81            BASE_UUID.format(sig_uuid_constants['A/V_RemoteControlController'])
82        ],
83        'protocol_descriptors': [
84            {
85                'protocol': int(sig_uuid_constants['L2CAP'], 16),
86                'params': [{
87                    'data': int(sig_uuid_constants['AVCTP'], 16),
88                }]
89            },
90            {
91                'protocol': int(sig_uuid_constants['AVCTP'], 16),
92                'params': [{
93                    'data': 0x103  # to indicate 1.3
94                }]
95            },
96        ],
97        'profile_descriptors': [{
98            'profile_id':
99            int(sig_uuid_constants['A/V_RemoteControl'], 16),
100            'major_version':
101            1,
102            'minor_version':
103            2,
104        }],
105        'additional_protocol_descriptors':
106        None,
107        'information': [{
108            'language': "en",
109            'name': "A2DP",
110            'description': "Advanced Audio Distribution Profile",
111            'provider': "Fuchsia"
112        }],
113        'additional_attributes': [{
114            'id':
115            bt_attribute_values['ATTR_A2DP_SUPPORTED_FEATURES'],
116            'element': {
117                'data': 0x0011
118            }
119        }]
120    },
121    {
122        'service_class_uuids': [BASE_UUID.format(sig_uuid_constants['PANU'])],
123        'protocol_descriptors': [
124            {
125                'protocol': int(sig_uuid_constants['L2CAP'], 16),
126                'params': [{
127                    'data': int(sig_uuid_constants['NAP'], 16),
128                }]
129            },
130            {
131                'protocol': int(sig_uuid_constants['AVCTP'], 16),
132                'params': [{
133                    'data': 0x103  # to indicate 1.3
134                }]
135            },
136        ],
137        'profile_descriptors': [{
138            'profile_id':
139            int(sig_uuid_constants['A/V_RemoteControl'], 16),
140            'major_version':
141            1,
142            'minor_version':
143            2,
144        }],
145        'additional_protocol_descriptors':
146        None,
147        'information': [{
148            'language': "en",
149            'name': "A2DP",
150            'description': "Advanced Audio Distribution Profile",
151            'provider': "Fuchsia"
152        }],
153        'additional_attributes': [{
154            'id':
155            bt_attribute_values['ATTR_A2DP_SUPPORTED_FEATURES'],
156            'element': {
157                'data': 0x0011
158            }
159        }]
160    },
161    {
162        'service_class_uuids': [BASE_UUID.format(sig_uuid_constants['SerialPort'])],
163        'protocol_descriptors': [
164            {
165                'protocol':
166                int(sig_uuid_constants['L2CAP'], 16),
167                'params': [{
168                    'data':
169                    int(sig_uuid_constants['SerialPort'], 16),
170                }]
171            },
172            {
173                'protocol': int(sig_uuid_constants['AVCTP'], 16),
174                'params': [{
175                    'data': 0x103  # to indicate 1.3
176                }]
177            },
178        ],
179        'profile_descriptors': [{
180            'profile_id':
181            int(sig_uuid_constants['A/V_RemoteControl'], 16),
182            'major_version':
183            1,
184            'minor_version':
185            2,
186        }],
187        'additional_protocol_descriptors':
188        None,
189        'information': [{
190            'language': "en",
191            'name': "A2DP",
192            'description': "Advanced Audio Distribution Profile",
193            'provider': "Fuchsia"
194        }],
195        'additional_attributes': [{
196            'id':
197            bt_attribute_values['ATTR_A2DP_SUPPORTED_FEATURES'],
198            'element': {
199                'data': 0x0011
200            }
201        }]
202    },
203    {
204        'service_class_uuids': [BASE_UUID.format(sig_uuid_constants['DialupNetworking'])],
205        'protocol_descriptors': [
206            {
207                'protocol':
208                int(sig_uuid_constants['L2CAP'], 16),
209                'params': [{
210                    'data':
211                    int(sig_uuid_constants['DialupNetworking'], 16),
212                }]
213            },
214            {
215                'protocol': int(sig_uuid_constants['AVCTP'], 16),
216                'params': [{
217                    'data': 0x103  # to indicate 1.3
218                }]
219            },
220        ],
221        'profile_descriptors': [{
222            'profile_id':
223            int(sig_uuid_constants['A/V_RemoteControl'], 16),
224            'major_version':
225            1,
226            'minor_version':
227            2,
228        }],
229        'additional_protocol_descriptors':
230        None,
231        'information': [{
232            'language': "en",
233            'name': "A2DP",
234            'description': "Advanced Audio Distribution Profile",
235            'provider': "Fuchsia"
236        }],
237        'additional_attributes': [{
238            'id':
239            bt_attribute_values['ATTR_A2DP_SUPPORTED_FEATURES'],
240            'element': {
241                'data': 0x0011
242            }
243        }]
244    },
245    {
246        'service_class_uuids': [BASE_UUID.format(sig_uuid_constants['OBEXObjectPush'])],
247        'protocol_descriptors': [
248            {
249                'protocol':
250                int(sig_uuid_constants['L2CAP'], 16),
251                'params': [{
252                    'data':
253                    int(sig_uuid_constants['OBEXObjectPush'], 16),
254                }]
255            },
256            {
257                'protocol': int(sig_uuid_constants['AVCTP'], 16),
258                'params': [{
259                    'data': 0x103  # to indicate 1.3
260                }]
261            },
262        ],
263        'profile_descriptors': [{
264            'profile_id':
265            int(sig_uuid_constants['A/V_RemoteControl'], 16),
266            'major_version':
267            1,
268            'minor_version':
269            2,
270        }],
271        'additional_protocol_descriptors':
272        None,
273        'information': [{
274            'language': "en",
275            'name': "A2DP",
276            'description': "Advanced Audio Distribution Profile",
277            'provider': "Fuchsia"
278        }],
279        'additional_attributes': [{
280            'id':
281            bt_attribute_values['ATTR_A2DP_SUPPORTED_FEATURES'],
282            'element': {
283                'data': 0x0011
284            }
285        }]
286    },
287    {
288        'service_class_uuids': [BASE_UUID.format(sig_uuid_constants['OBEXFileTransfer'])],
289        'protocol_descriptors': [
290            {
291                'protocol':
292                int(sig_uuid_constants['L2CAP'], 16),
293                'params': [{
294                    'data':
295                    int(sig_uuid_constants['OBEXFileTransfer'], 16),
296                }]
297            },
298            {
299                'protocol': int(sig_uuid_constants['AVCTP'], 16),
300                'params': [{
301                    'data': 0x103  # to indicate 1.3
302                }]
303            },
304        ],
305        'profile_descriptors': [{
306            'profile_id':
307            int(sig_uuid_constants['A/V_RemoteControl'], 16),
308            'major_version':
309            1,
310            'minor_version':
311            2,
312        }],
313        'additional_protocol_descriptors':
314        None,
315        'information': [{
316            'language': "en",
317            'name': "A2DP",
318            'description': "Advanced Audio Distribution Profile",
319            'provider': "Fuchsia"
320        }],
321        'additional_attributes': [{
322            'id':
323            bt_attribute_values['ATTR_A2DP_SUPPORTED_FEATURES'],
324            'element': {
325                'data': 0x0011
326            }
327        }]
328    },
329    {
330        'service_class_uuids': [BASE_UUID.format(sig_uuid_constants['Headset'])],
331        'protocol_descriptors': [
332            {
333                'protocol': int(sig_uuid_constants['L2CAP'], 16),
334                'params': [{
335                    'data': int(sig_uuid_constants['Headset'], 16),
336                }]
337            },
338            {
339                'protocol': int(sig_uuid_constants['AVCTP'], 16),
340                'params': [{
341                    'data': 0x103  # to indicate 1.3
342                }]
343            },
344        ],
345        'profile_descriptors': [{
346            'profile_id':
347            int(sig_uuid_constants['A/V_RemoteControl'], 16),
348            'major_version':
349            1,
350            'minor_version':
351            2,
352        }],
353        'additional_protocol_descriptors':
354        None,
355        'information': [{
356            'language': "en",
357            'name': "A2DP",
358            'description': "Advanced Audio Distribution Profile",
359            'provider': "Fuchsia"
360        }],
361        'additional_attributes': [{
362            'id':
363            bt_attribute_values['ATTR_A2DP_SUPPORTED_FEATURES'],
364            'element': {
365                'data': 0x0011
366            }
367        }]
368    },
369    {
370        'service_class_uuids': [BASE_UUID.format(sig_uuid_constants['HandsfreeAudioGateway'])],
371        'protocol_descriptors': [
372            {
373                'protocol':
374                int(sig_uuid_constants['L2CAP'], 16),
375                'params': [{
376                    'data':
377                    int(sig_uuid_constants['HandsfreeAudioGateway'], 16),
378                }]
379            },
380            {
381                'protocol': int(sig_uuid_constants['AVCTP'], 16),
382                'params': [{
383                    'data': 0x103  # to indicate 1.3
384                }]
385            },
386        ],
387        'profile_descriptors': [{
388            'profile_id':
389            int(sig_uuid_constants['A/V_RemoteControl'], 16),
390            'major_version':
391            1,
392            'minor_version':
393            2,
394        }],
395        'additional_protocol_descriptors':
396        None,
397        'information': [{
398            'language': "en",
399            'name': "A2DP",
400            'description': "Advanced Audio Distribution Profile",
401            'provider': "Fuchsia"
402        }],
403        'additional_attributes': [{
404            'id':
405            bt_attribute_values['ATTR_A2DP_SUPPORTED_FEATURES'],
406            'element': {
407                'data': 0x0011
408            }
409        }]
410    },
411    {
412        'service_class_uuids': [BASE_UUID.format(sig_uuid_constants['Handsfree'])],
413        'protocol_descriptors': [
414            {
415                'protocol': int(sig_uuid_constants['L2CAP'], 16),
416                'params': [{
417                    'data': int(sig_uuid_constants['Handsfree'], 16),
418                }]
419            },
420            {
421                'protocol': int(sig_uuid_constants['AVCTP'], 16),
422                'params': [{
423                    'data': 0x103  # to indicate 1.3
424                }]
425            },
426        ],
427        'profile_descriptors': [{
428            'profile_id':
429            int(sig_uuid_constants['A/V_RemoteControl'], 16),
430            'major_version':
431            1,
432            'minor_version':
433            2,
434        }],
435        'additional_protocol_descriptors':
436        None,
437        'information': [{
438            'language': "en",
439            'name': "A2DP",
440            'description': "Advanced Audio Distribution Profile",
441            'provider': "Fuchsia"
442        }],
443        'additional_attributes': [{
444            'id':
445            bt_attribute_values['ATTR_A2DP_SUPPORTED_FEATURES'],
446            'element': {
447                'data': 0x0011
448            }
449        }]
450    },
451    {
452        'service_class_uuids': [BASE_UUID.format(sig_uuid_constants['SIM_Access'])],
453        'protocol_descriptors': [
454            {
455                'protocol': int(sig_uuid_constants['L2CAP'], 16),
456                'params': [{
457                    'data': int(sig_uuid_constants['SIM_Access'], 16),
458                }]
459            },
460            {
461                'protocol': int(sig_uuid_constants['AVCTP'], 16),
462                'params': [{
463                    'data': 0x103  # to indicate 1.3
464                }]
465            },
466        ],
467        'profile_descriptors': [{
468            'profile_id':
469            int(sig_uuid_constants['A/V_RemoteControl'], 16),
470            'major_version':
471            1,
472            'minor_version':
473            2,
474        }],
475        'additional_protocol_descriptors':
476        None,
477        'information': [{
478            'language': "en",
479            'name': "A2DP",
480            'description': "Advanced Audio Distribution Profile",
481            'provider': "Fuchsia"
482        }],
483        'additional_attributes': [{
484            'id':
485            bt_attribute_values['ATTR_A2DP_SUPPORTED_FEATURES'],
486            'element': {
487                'data': 0x0011
488            }
489        }]
490    }
491]