• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2#
3# Copyright (C) 2016 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 thea
14# License for the specific language governing permissions and limitations under
15# the License.
16"""
17Test script to exercise Ble Advertisement Api's. This exercises all getters and
18setters. This is important since there is a builder object that is immutable
19after you set all attributes of each object. If this test suite doesn't pass,
20then other test suites utilising Ble Advertisements will also fail.
21"""
22
23import pprint
24
25from acts.controllers.sl4a_lib import rpc_client
26from acts.test_decorators import test_tracker_info
27from acts_contrib.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest
28from acts_contrib.test_utils.bt.bt_test_utils import adv_fail, adv_succ, scan_result
29from acts_contrib.test_utils.bt.bt_test_utils import generate_ble_advertise_objects
30from acts_contrib.test_utils.bt.bt_constants import ble_advertise_settings_modes
31from acts_contrib.test_utils.bt.bt_constants import ble_advertise_settings_tx_powers
32# from acts_contrib.test_utils.bt.bt_constants import ble_advertise_settings_own_address_types
33from acts_contrib.test_utils.bt.bt_constants import java_integer
34
35
36class BleAdvertiseVerificationError(Exception):
37    """Error in fetsching BleScanner Advertise result."""
38
39
40class BleAdvertiseApiTest(BluetoothBaseTest):
41    def setup_class(self):
42        super().setup_class()
43        self.ad_dut = self.android_devices[0]
44        self.sc_dut = self.android_devices[1]
45
46    @BluetoothBaseTest.bt_test_wrap
47    @test_tracker_info(uuid='d6d8d0a6-7b3e-4e4b-a5d0-bcfd6e207474')
48    def test_adv_settings_defaults(self):
49        """Tests the default advertisement settings.
50
51        This builder object should have a proper "get" expectation for each
52        attribute of the builder object once it's built.
53
54        Steps:
55        1. Build a new advertise settings object.
56        2. Get the attributes of the advertise settings object.
57        3. Compare the attributes found against the attributes exp.
58
59        Expected Result:
60        Found attributes should match expected attributes.
61
62        Returns:
63          True is pass
64          False if fail
65
66        TAGS: LE, Advertising
67        Priority: 0
68        """
69        test_result = True
70        droid = self.ad_dut.droid
71        adv_settings = droid.bleBuildAdvertiseSettings()
72        adv_mode = droid.bleGetAdvertiseSettingsMode(adv_settings)
73        tx_power_level = droid.bleGetAdvertiseSettingsTxPowerLevel(
74            adv_settings)
75        is_connectable = droid.bleGetAdvertiseSettingsIsConnectable(
76            adv_settings)
77
78        exp_adv_mode = ble_advertise_settings_modes['low_power']
79        exp_tx_power_level = ble_advertise_settings_tx_powers['medium']
80        exp_is_connectable = True
81        if adv_mode != exp_adv_mode:
82            test_result = False
83            self.log.debug("exp filtering mode: {},"
84                           " found filtering mode: {}".format(
85                               exp_adv_mode, adv_mode))
86        if tx_power_level != exp_tx_power_level:
87            test_result = False
88            self.log.debug("exp tx power level: {},"
89                           " found filtering tx power level: {}".format(
90                               exp_tx_power_level, tx_power_level))
91        if exp_is_connectable != is_connectable:
92            test_result = False
93            self.log.debug("exp is connectable: {},"
94                           " found filtering is connectable: {}".format(
95                               exp_is_connectable, is_connectable))
96        return test_result
97
98    @BluetoothBaseTest.bt_test_wrap
99    @test_tracker_info(uuid='f2a276ae-1436-43e4-aba7-1ede787200ee')
100    def test_adv_data_defaults(self):
101        """Tests the default advertisement data.
102
103        This builder object should have a proper "get" expectation for each
104        attribute of the builder object once it's built.
105
106        Steps:
107        1. Build a new AdvertiseData object.
108        2. Get the attributes of the advertise settings object.
109        3. Compare the attributes found against the attributes exp.
110
111        Expected Result:
112        Found attributes should match expected attributes.
113
114        Returns:
115          True is pass
116          False if fail
117
118        TAGS: LE, Advertising
119        Priority: 0
120        """
121        test_result = True
122        droid = self.ad_dut.droid
123        adv_data = droid.bleBuildAdvertiseData()
124        service_uuids = droid.bleGetAdvertiseDataServiceUuids(adv_data)
125        include_tx_power_level = droid.bleGetAdvertiseDataIncludeTxPowerLevel(
126            adv_data)
127        include_device_name = droid.bleGetAdvertiseDataIncludeDeviceName(
128            adv_data)
129
130        exp_service_uuids = []
131        exp_include_tx_power_level = False
132        exp_include_device_name = False
133        self.log.debug("Step 4: Verify all defaults match exp values.")
134        if service_uuids != exp_service_uuids:
135            test_result = False
136            self.log.debug("exp filtering service uuids: {},"
137                           " found filtering service uuids: {}".format(
138                               exp_service_uuids, service_uuids))
139        if include_tx_power_level != exp_include_tx_power_level:
140            test_result = False
141            self.log.debug(
142                "exp filtering include tx power level:: {},"
143                " found filtering include tx power level: {}".format(
144                    exp_include_tx_power_level, include_tx_power_level))
145        if include_device_name != exp_include_device_name:
146            test_result = False
147            self.log.debug(
148                "exp filtering include tx power level: {},"
149                " found filtering include tx power level: {}".format(
150                    exp_include_device_name, include_device_name))
151        if not test_result:
152            self.log.debug("Some values didn't match the defaults.")
153        else:
154            self.log.debug("All default values passed.")
155        return test_result
156
157    @BluetoothBaseTest.bt_test_wrap
158    @test_tracker_info(uuid='8d462e60-6b4e-49f3-9ef4-5a8b612d285d')
159    def test_adv_settings_set_adv_mode_balanced(self):
160        """Tests advertise settings balanced mode.
161
162        This advertisement settings from "set" advertisement mode should match
163        the corresponding "get" function.
164
165        Steps:
166        1. Build a new advertise settings object.
167        2. Set the advertise mode attribute to balanced.
168        3. Get the attributes of the advertise settings object.
169        4. Compare the attributes found against the attributes exp.
170
171        Expected Result:
172        Found attributes should match expected attributes.
173
174        Returns:
175          True is pass
176          False if fail
177
178        TAGS: LE, Advertising
179        Priority: 1
180        """
181        self.log.debug("Step 1: Setup environment.")
182        droid = self.ad_dut.droid
183        exp_adv_mode = ble_advertise_settings_modes['balanced']
184        self.log.debug(
185            "Step 2: Set the filtering settings object's value to {}".format(
186                exp_adv_mode))
187        return self.verify_adv_settings_adv_mode(droid, exp_adv_mode)
188
189    @BluetoothBaseTest.bt_test_wrap
190    @test_tracker_info(uuid='334fefeb-365f-4ee3-9be0-42b1fabe3178')
191    def test_adv_settings_set_adv_mode_low_power(self):
192        """Tests advertise settings low power mode.
193
194        This advertisement settings from "set" advertisement mode should match
195        the corresponding "get" function.
196
197        Steps:
198        1. Build a new advertise settings object.
199        2. Set the advertise mode attribute to low power mode.
200        3. Get the attributes of the advertise settings object.
201        4. Compare the attributes found against the attributes exp.
202
203        Expected Result:
204        Found attributes should match expected attributes.
205
206        Returns:
207          True is pass
208          False if fail
209
210        TAGS: LE, Advertising
211        Priority: 1
212        """
213        self.log.debug("Step 1: Setup environment.")
214        droid = self.ad_dut.droid
215        exp_adv_mode = ble_advertise_settings_modes['low_power']
216        self.log.debug(
217            "Step 2: Set the filtering settings object's value to {}".format(
218                exp_adv_mode))
219        return self.verify_adv_settings_adv_mode(droid, exp_adv_mode)
220
221    @BluetoothBaseTest.bt_test_wrap
222    @test_tracker_info(uuid='ce087782-1535-4694-944a-e962c22638ed')
223    def test_adv_settings_set_adv_mode_low_latency(self):
224        """Tests advertise settings low latency mode.
225
226        This advertisement settings from "set" advertisement mode should match
227        the corresponding "get" function.
228
229        Steps:
230        1. Build a new advertise settings object.
231        2. Set the advertise mode attribute to low latency mode.
232        3. Get the attributes of the advertise settings object.
233        4. Compare the attributes found against the attributes exp.
234
235        Expected Result:
236        Found attributes should match expected attributes.
237
238        Returns:
239          True is pass
240          False if fail
241
242        TAGS: LE, Advertising
243        Priority: 1
244        """
245        self.log.debug("Step 1: Setup environment.")
246        droid = self.ad_dut.droid
247        exp_adv_mode = ble_advertise_settings_modes['low_latency']
248        self.log.debug(
249            "Step 2: Set the filtering settings object's value to {}".format(
250                exp_adv_mode))
251        return self.verify_adv_settings_adv_mode(droid, exp_adv_mode)
252
253    @BluetoothBaseTest.bt_test_wrap
254    @test_tracker_info(uuid='59b52be9-d38b-4814-af08-c68aa8910a16')
255    def test_adv_settings_set_invalid_adv_mode(self):
256        """Tests advertise settings invalid advertising mode.
257
258        This advertisement settings from "set" advertisement mode should fail
259        when setting an invalid advertisement.
260
261        Steps:
262        1. Build a new advertise settings object.
263        2. Set the advertise mode attribute to -1.
264
265        Expected Result:
266        Building the advertise settings should fail.
267
268        Returns:
269          True is pass
270          False if fail
271
272        TAGS: LE, Advertising
273        Priority: 2
274        """
275        self.log.debug("Step 1: Setup environment.")
276        droid = self.ad_dut.droid
277        exp_adv_mode = -1
278        self.log.debug("Step 2: Set the filtering mode to -1")
279        return self.verify_invalid_adv_settings_adv_mode(droid, exp_adv_mode)
280
281    @BluetoothBaseTest.bt_test_wrap
282    @test_tracker_info(uuid='d8292633-831f-41c4-974a-ad267e9795e9')
283    def test_adv_settings_set_adv_tx_power_level_high(self):
284        """Tests advertise settings tx power level high.
285
286        This advertisement settings from "set" advertisement tx power level
287        should match the corresponding "get" function.
288
289        Steps:
290        1. Build a new advertise settings object.
291        2. Set the advertise mode attribute to tx power level high.
292        3. Get the attributes of the advertise settings object.
293        4. Compare the attributes found against the attributes exp.
294
295        Expected Result:
296        Found attributes should match expected attributes.
297
298        Returns:
299          True is pass
300          False if fail
301
302        TAGS: LE, Advertising
303        Priority: 1
304        """
305        self.log.debug("Step 1: Setup environment.")
306        droid = self.ad_dut.droid
307        exp_adv_tx_power = ble_advertise_settings_tx_powers['high']
308        self.log.debug(
309            "Step 2: Set the filtering settings object's value to {}".format(
310                exp_adv_tx_power))
311        return self.verify_adv_settings_tx_power_level(droid, exp_adv_tx_power)
312
313    @BluetoothBaseTest.bt_test_wrap
314    @test_tracker_info(uuid='d577de1f-4fd9-43d5-beff-c0696c5e0ea1')
315    def test_adv_settings_set_adv_tx_power_level_medium(self):
316        """Tests advertise settings tx power level medium.
317
318        This advertisement settings from "set" advertisement tx power level
319        should match the corresponding "get" function.
320
321        Steps:
322        1. Build a new advertise settings object.
323        2. Set the advertise mode attribute to tx power level medium.
324        3. Get the attributes of the advertise settings object.
325        4. Compare the attributes found against the attributes exp.
326
327        Expected Result:
328        Found attributes should match expected attributes.
329
330        Returns:
331          True is pass
332          False if fail
333
334        TAGS: LE, Advertising
335        Priority: 1
336        """
337        self.log.debug("Step 1: Setup environment.")
338        test_result = True
339        droid = self.ad_dut.droid
340        exp_adv_tx_power = ble_advertise_settings_tx_powers['medium']
341        self.log.debug(
342            "Step 2: Set the filtering settings object's value to {}".format(
343                exp_adv_tx_power))
344        return self.verify_adv_settings_tx_power_level(droid, exp_adv_tx_power)
345
346    @BluetoothBaseTest.bt_test_wrap
347    @test_tracker_info(uuid='e972f8b5-a3cf-4b3f-9223-a8a74c0fd855')
348    def test_adv_settings_set_adv_tx_power_level_low(self):
349        """Tests advertise settings tx power level low.
350
351        This advertisement settings from "set" advertisement tx power level
352        should match the corresponding "get" function.
353
354        Steps:
355        1. Build a new advertise settings object.
356        2. Set the advertise mode attribute to tx power level low.
357        3. Get the attributes of the advertise settings object.
358        4. Compare the attributes found against the attributes exp.
359
360        Expected Result:
361        Found attributes should match expected attributes.
362
363        Returns:
364          True is pass
365          False if fail
366
367        TAGS: LE, Advertising
368        Priority: 1
369        """
370        self.log.debug("Step 1: Setup environment.")
371        droid = self.ad_dut.droid
372        exp_adv_tx_power = (ble_advertise_settings_tx_powers['low'])
373        self.log.debug(
374            "Step 2: Set the filtering settings object's value to ".format(
375                exp_adv_tx_power))
376        return self.verify_adv_settings_tx_power_level(droid, exp_adv_tx_power)
377
378    @BluetoothBaseTest.bt_test_wrap
379    @test_tracker_info(uuid='e972f8b5-a3cf-4b3f-9223-a8a74c0fd855')
380    def test_adv_settings_set_adv_tx_power_level_ultra_low(self):
381        """Tests advertise settings tx power level ultra low.
382
383        This advertisement settings from "set" advertisement tx power level
384        should match the corresponding "get" function.
385
386        Steps:
387        1. Build a new advertise settings object.
388        2. Set the advertise mode attribute to tx power level ultra low.
389        3. Get the attributes of the advertise settings object.
390        4. Compare the attributes found against the attributes exp.
391
392        Expected Result:
393        Found attributes should match expected attributes.
394
395        Returns:
396          True is pass
397          False if fail
398
399        TAGS: LE, Advertising
400        Priority: 1
401        """
402        self.log.debug("Step 1: Setup environment.")
403        droid = self.ad_dut.droid
404        exp_adv_tx_power = ble_advertise_settings_tx_powers['ultra_low']
405        self.log.debug(
406            "Step 2: Set the filtering settings object's value to ".format(
407                exp_adv_tx_power))
408        return self.verify_adv_settings_tx_power_level(droid, exp_adv_tx_power)
409
410    @BluetoothBaseTest.bt_test_wrap
411    @test_tracker_info(uuid='e972f8b5-a3cf-4b3f-9223-a8a74c0fd855')
412    def test_adv_settings_set_invalid_adv_tx_power_level(self):
413        """Tests advertise settings invalid advertising tx power level.
414
415        This advertisement settings from "set" advertisement mode should fail
416        when setting an invalid advertisement.
417
418        Steps:
419        1. Build a new advertise settings object.
420        2. Set the advertise tx power level attribute to -1.
421
422        Expected Result:
423        Building the advertise settings should fail.
424
425        Returns:
426          True is pass
427          False if fail
428
429        TAGS: LE, Advertising
430        Priority: 1
431        """
432        self.log.debug("Step 1: Setup environment.")
433        droid = self.ad_dut.droid
434        exp_adv_tx_power = -1
435        self.log.debug("Step 2: Set the filtering mode to -1")
436        return self.verify_invalid_adv_settings_tx_power_level(
437            droid, exp_adv_tx_power)
438
439    @BluetoothBaseTest.bt_test_wrap
440    @test_tracker_info(uuid='1be71f77-64af-42b7-84cb-e06df0836966')
441    def test_adv_settings_set_is_connectable_true(self):
442        """Tests advertise settings is connectable true.
443
444        This advertisement settings from "set" advertisement tx power level
445        should match the corresponding "get" function.
446
447        Steps:
448        1. Build a new advertise settings object.
449        2. Set the advertise is connectable to true.
450        3. Get the attributes of the advertise settings object.
451        4. Compare the attributes found against the attributes exp.
452
453        Expected Result:
454        Found attributes should match expected attributes.
455
456        Returns:
457          True is pass
458          False if fail
459
460        TAGS: LE, Advertising
461        Priority: 1
462        """
463        self.log.debug("Step 1: Setup environment.")
464        droid = self.ad_dut.droid
465        exp_is_connectable = True
466        self.log.debug(
467            "Step 2: Set the filtering settings object's value to {}".format(
468                exp_is_connectable))
469        return self.verify_adv_settings_is_connectable(droid,
470                                                       exp_is_connectable)
471
472    @BluetoothBaseTest.bt_test_wrap
473    @test_tracker_info(uuid='f9865333-9198-4385-938d-5fc641ee9968')
474    def test_adv_settings_set_is_connectable_false(self):
475        """Tests advertise settings is connectable false.
476
477        This advertisement settings from "set" advertisement tx power level
478        should match the corresponding "get" function.
479
480        Steps:
481        1. Build a new advertise settings object.
482        2. Set the advertise is connectable to false.
483        3. Get the attributes of the advertise settings object.
484        4. Compare the attributes found against the attributes exp.
485
486        Expected Result:
487        Found attributes should match expected attributes.
488
489        Returns:
490          True is pass
491          False if fail
492
493        TAGS: LE, Advertising
494        Priority: 1
495        """
496        self.log.debug("Step 1: Setup environment.")
497        droid = self.ad_dut.droid
498        exp_is_connectable = False
499        self.log.debug("Step 2: Set the filtering settings object's value to "
500                       + str(exp_is_connectable))
501        return self.verify_adv_settings_is_connectable(droid,
502                                                       exp_is_connectable)
503
504    @BluetoothBaseTest.bt_test_wrap
505    def test_adv_settings_set_adv_own_address_type_public(self):
506        """Tests advertise settings own address type public.
507
508        This advertisement settings from "set" advertisement own address type
509        should match the corresponding "get" function.
510
511        Steps:
512        1. Build a new advertise settings object.
513        2. Set the advertise mode attribute to own address type public.
514        3. Get the attributes of the advertise settings object.
515        4. Compare the attributes found against the attributes exp.
516
517        Expected Result:
518        Found attributes should match expected attributes.
519
520        Returns:
521          True is pass
522          False if fail
523
524        TAGS: LE, Advertising
525        Priority: 1
526        """
527        self.log.debug("Step 1: Setup environment.")
528        droid = self.ad_dut.droid
529        # exp_adv_own_address_type = ble_advertise_settings_own_address_types['public']
530        exp_adv_own_address_type = 0
531        self.log.debug(
532            "Step 2: Set the filtering settings object's value to {}".format(
533                exp_adv_own_address_type))
534        return self.verify_adv_settings_own_address_type(droid, exp_adv_own_address_type)
535
536    @BluetoothBaseTest.bt_test_wrap
537    def test_adv_settings_set_adv_own_address_type_random(self):
538        """Tests advertise settings own address type random.
539
540        This advertisement settings from "set" advertisement own address type
541        should match the corresponding "get" function.
542
543        Steps:
544        1. Build a new advertise settings object.
545        2. Set the advertise mode attribute to own address type random.
546        3. Get the attributes of the advertise settings object.
547        4. Compare the attributes found against the attributes exp.
548
549        Expected Result:
550        Found attributes should match expected attributes.
551
552        Returns:
553          True is pass
554          False if fail
555
556        TAGS: LE, Advertising
557        Priority: 1
558        """
559        self.log.debug("Step 1: Setup environment.")
560        droid = self.ad_dut.droid
561        # exp_adv_own_address_type = ble_advertise_settings_own_address_types['random']
562        exp_adv_own_address_type = 1
563        self.log.debug(
564            "Step 2: Set the filtering settings object's value to {}".format(
565                exp_adv_own_address_type))
566        return self.verify_adv_settings_own_address_type(droid, exp_adv_own_address_type)
567
568    @BluetoothBaseTest.bt_test_wrap
569    def test_adv_with_multiple_own_address_types(self):
570        ad_droid = self.ad_dut.droid
571        sc_droid = self.sc_dut.droid
572        sc_ed = self.sc_dut.ed
573        adv_count = 10
574        exp_adv_own_address_types = [0, 1, 1, 0, 0, 1, 1, 1, 0, 0]
575        uuid = '01234567-89ab-cdef-0123-456789abcdef'
576        service_data = []
577
578        for i in range(3):
579            service_data.append(i)
580
581        for own_add_type in exp_adv_own_address_types:
582            result = self.verify_adv_set_address_type_start_adv(ad_droid,
583                    own_add_type, uuid, service_data)
584            if result is False:
585                return False
586
587        mac_list = []
588
589        filter_list = sc_droid.bleGenFilterList()
590        scan_settings = sc_droid.bleBuildScanSetting()
591        scan_callback = sc_droid.bleGenScanCallback()
592        sc_droid.bleStartBleScan(filter_list, scan_settings,
593                                       scan_callback)
594        event_name = scan_result.format(scan_callback)
595        self.log.info("Scan onSuccess Event")
596
597        for _ in range(1000):
598            if len(mac_list) is adv_count:
599                break
600
601            try:
602                event = sc_ed.pop_event(event_name, 10)
603                result = event['data']['Result']
604                deviceInfo = result['deviceInfo']
605                serviceUuidList = result['serviceUuidList']
606                if uuid in serviceUuidList:
607                    mac_addr = deviceInfo['address']
608                    if mac_addr not in mac_list:
609                        self.log.info("Found device. address: {}".format(mac_addr))
610                        mac_list.append(mac_addr)
611
612            except rpc_client.Sl4aApiError:
613                self.log.info("{} event was not found.".format(event_name))
614                break
615
616        return len(mac_list) is adv_count
617
618    @BluetoothBaseTest.bt_test_wrap
619    def test_adv_settings_set_invalid_adv_own_address_type(self):
620        """Tests advertise settings invalid own address type.
621
622        This advertisement settings from "set" advertisement own address type
623        should match the corresponding "get" function.
624
625        Steps:
626        1. Build a new advertise settings object.
627        2. Set the advertise mode attribute to invalid own address type.
628        3. Get the attributes of the advertise settings object.
629        4. Compare the attributes found against the attributes exp.
630
631        Expected Result:
632        Found attributes should match expected attributes.
633
634        Returns:
635          True is pass
636          False if fail
637
638        TAGS: LE, Advertising
639        Priority: 1
640        """
641        self.log.debug("Step 1: Setup environment.")
642        droid = self.ad_dut.droid
643        exp_adv_own_address_type = -100
644        self.log.debug("Step 2: Set the filtering settings own address type to -1")
645        return self.verify_invalid_adv_settings_own_address_type(droid, exp_adv_own_address_type)
646
647    @BluetoothBaseTest.bt_test_wrap
648    @test_tracker_info(uuid='a770ed7e-c6cd-4533-8876-e42e68f8b4fb')
649    def test_adv_data_set_service_uuids_empty(self):
650        """Tests advertisement data's service uuids to empty.
651
652        This advertisement data from "set" advertisement service uuid
653        should match the corresponding "get" function.
654
655        Steps:
656        1. Build a new AdvertiseData object.
657        2. Set the AdvertiseData's service uuid to empty.
658        3. Get the attributes of the AdvertiseData object.
659        4. Compare the attributes found against the attributes exp.
660
661        Expected Result:
662        Found attributes should match expected attributes.
663
664        Returns:
665          True is pass
666          False if fail
667
668        TAGS: LE, Advertising
669        Priority: 1
670        """
671        self.log.debug("Step 1: Setup environment.")
672        droid = self.ad_dut.droid
673        exp_service_uuids = []
674        self.log.debug("Step 2: Set the filtering data object's value to " +
675                       str(exp_service_uuids))
676        return self.verify_adv_data_service_uuids(droid, exp_service_uuids)
677
678    @BluetoothBaseTest.bt_test_wrap
679    @test_tracker_info(uuid='3da511db-d024-45c8-be3c-fe8e123129fa')
680    def test_adv_data_set_service_uuids_single(self):
681        """Tests advertisement data's service uuids to empty.
682
683        This advertisement data from "set" advertisement service uuid
684        should match the corresponding "get" function.
685
686        Steps:
687        1. Build a new AdvertiseData object.
688        2. Set the AdvertiseData's service uuid to empty.
689        3. Get the attributes of the AdvertiseData object.
690        4. Compare the attributes found against the attributes exp.
691
692        Expected Result:
693        Found attributes should match expected attributes.
694
695        Returns:
696          True is pass
697          False if fail
698
699        TAGS: LE, Advertising
700        Priority: 1
701        """
702        self.log.debug("Step 1: Setup environment.")
703        droid = self.ad_dut.droid
704        exp_service_uuids = ["00000000-0000-1000-8000-00805f9b34fb"]
705        self.log.debug("Step 2: Set the filtering data object's value to " +
706                       str(exp_service_uuids))
707        return self.verify_adv_data_service_uuids(droid, exp_service_uuids)
708
709    @BluetoothBaseTest.bt_test_wrap
710    @test_tracker_info(uuid='15073359-d607-4a76-b60a-00a4b34f9a85')
711    def test_adv_data_set_service_uuids_multiple(self):
712        """Tests advertisement data's service uuids to multiple uuids.
713
714        This advertisement data from "set" advertisement service uuid
715        should match the corresponding "get" function.
716
717        Steps:
718        1. Build a new AdvertiseData object.
719        2. Set the AdvertiseData's service uuid to multiple uuids.
720        3. Get the attributes of the AdvertiseData object.
721        4. Compare the attributes found against the attributes exp.
722
723        Expected Result:
724        Found attributes should match expected attributes.
725
726        Returns:
727          True is pass
728          False if fail
729
730        TAGS: LE, Advertising
731        Priority: 1
732        """
733        self.log.debug("Step 1: Setup environment.")
734        droid = self.ad_dut.droid
735        exp_service_uuids = [
736            "00000000-0000-1000-8000-00805f9b34fb",
737            "00000000-0000-1000-8000-00805f9b34fb"
738        ]
739        self.log.debug("Step 2: Set the filtering data object's value to " +
740                       str(exp_service_uuids))
741        return self.verify_adv_data_service_uuids(droid, exp_service_uuids)
742
743    @BluetoothBaseTest.bt_test_wrap
744    @test_tracker_info(uuid='af783a71-ef80-4974-a077-16a4ed8f0114')
745    def test_adv_data_set_service_uuids_invalid_uuid(self):
746        """Tests advertisement data's service uuids to an invalid uuid.
747
748        This advertisement data from "set" advertisement service uuid
749        should fail when there is an invalid service uuid.
750
751        Steps:
752        1. Build a new AdvertiseData object.
753        2. Set the AdvertiseData's service uuid to an invalid uuid.
754
755        Expected Result:
756        Building the AdvertiseData should fail.
757
758        Returns:
759          True is pass
760          False if fail
761
762        TAGS: LE, Advertising
763        Priority: 1
764        """
765        self.log.debug("Step 1: Setup environment.")
766        droid = self.ad_dut.droid
767        exp_service_uuids = ["0"]
768        self.log.debug("Step 2: Set the filtering data service uuids to " +
769                       str(exp_service_uuids))
770        return self.verify_invalid_adv_data_service_uuids(
771            droid, exp_service_uuids)
772
773    @BluetoothBaseTest.bt_test_wrap
774    @test_tracker_info(uuid='51d634e7-6271-4cc0-a57b-3c1b632a7db6')
775    def test_adv_data_set_service_data(self):
776        """Tests advertisement data's service data.
777
778        This advertisement data from "set" advertisement service data
779        should match the corresponding "get" function.
780
781        Steps:
782        1. Build a new AdvertiseData object.
783        2. Set the AdvertiseData's service data.
784        3. Get the attributes of the AdvertiseData object.
785        4. Compare the attributes found against the attributes exp.
786
787        Expected Result:
788        Found attributes should match expected attributes.
789
790        Returns:
791          True is pass
792          False if fail
793
794        TAGS: LE, Advertising
795        Priority: 1
796        """
797        self.log.debug("Step 1: Setup environment.")
798        droid = self.ad_dut.droid
799        exp_service_data_uuid = "00000000-0000-1000-8000-00805f9b34fb"
800        exp_service_data = [1, 2, 3]
801        self.log.debug(
802            "Step 2: Set the filtering data object's service data uuid to: {}, "
803            "service data: {}".format(exp_service_data_uuid, exp_service_data))
804        return self.verify_adv_data_service_data(droid, exp_service_data_uuid,
805                                                 exp_service_data)
806
807    @BluetoothBaseTest.bt_test_wrap
808    @test_tracker_info(uuid='aa18b0af-2a41-4b2a-af64-ea639961d561')
809    def test_adv_data_set_service_data_invalid_service_data(self):
810        """Tests advertisement data's invalid service data.
811
812        This advertisement data from "set" advertisement service data
813        should fail on an invalid value.
814
815        Steps:
816        1. Build a new AdvertiseData object.
817        2. Set the AdvertiseData's service data to an invalid value.
818        3. Get the attributes of the AdvertiseData object.
819        4. Compare the attributes found against the attributes exp.
820
821        Expected Result:
822        Found attributes should match expected attributes.
823
824        Returns:
825          True is pass
826          False if fail
827
828        TAGS: LE, Advertising
829        Priority: 1
830        """
831        self.log.debug("Step 1: Setup environment.")
832        droid = self.ad_dut.droid
833        exp_service_data_uuid = "00000000-0000-1000-8000-00805f9b34fb"
834        exp_service_data = "helloworld"
835        self.log.debug(
836            "Step 2: Set the filtering data object's service data uuid to: {}, "
837            "service data: {}".format(exp_service_data_uuid, exp_service_data))
838        return self.verify_invalid_adv_data_service_data(
839            droid, exp_service_data_uuid, exp_service_data)
840
841    @BluetoothBaseTest.bt_test_wrap
842    @test_tracker_info(uuid='13a75a47-eff4-429f-a436-d244bbfe4496')
843    def test_adv_data_set_service_data_invalid_service_data_uuid(self):
844        """Tests advertisement data's invalid service data and uuid.
845
846        This advertisement data from "set" advertisement service data
847        should fail on an invalid value.
848
849        Steps:
850        1. Build a new AdvertiseData object.
851        2. Set the AdvertiseData's service data and uuid to an invalid value.
852        3. Get the attributes of the AdvertiseData object.
853        4. Compare the attributes found against the attributes exp.
854
855        Expected Result:
856        Found attributes should match expected attributes.
857
858        Returns:
859          True is pass
860          False if fail
861
862        TAGS: LE, Advertising
863        Priority: 1
864        """
865        self.log.debug("Step 1: Setup environment.")
866        droid = self.ad_dut.droid
867        exp_service_data_uuid = "0"
868        exp_service_data = "1,2,3"
869        self.log.debug(
870            "Step 2: Set the filtering data object's service data uuid to: {}, "
871            "service data: {}".format(exp_service_data_uuid, exp_service_data))
872        return self.verify_invalid_adv_data_service_data(
873            droid, exp_service_data_uuid, exp_service_data)
874
875    @BluetoothBaseTest.bt_test_wrap
876    @test_tracker_info(uuid='386024e2-212e-4eed-8ef3-43d0c0239ea5')
877    def test_adv_data_set_manu_id(self):
878        """Tests advertisement data's manufacturers data and id.
879
880        This advertisement data from "set" advertisement manufacturers data
881        should match the corresponding "get" function.
882
883        Steps:
884        1. Build a new AdvertiseData object.
885        2. Set the AdvertiseData's manufacturers data and id.
886        3. Get the attributes of the AdvertiseData object.
887        4. Compare the attributes found against the attributes exp.
888
889        Expected Result:
890        Found attributes should match expected attributes.
891
892        Returns:
893          True is pass
894          False if fail
895
896        TAGS: LE, Advertising
897        Priority: 1
898        """
899        self.log.debug("Step 1: Setup environment.")
900        droid = self.ad_dut.droid
901        exp_manu_id = 0
902        exp_manu_specific_data = [1, 2, 3]
903        self.log.debug(
904            "Step 2: Set the filtering data object's service data manu id: {}"
905            ", manu specific data: {}".format(exp_manu_id,
906                                              exp_manu_specific_data))
907        return self.verify_adv_data_manu_id(droid, exp_manu_id,
908                                            exp_manu_specific_data)
909
910    @BluetoothBaseTest.bt_test_wrap
911    @test_tracker_info(uuid='650ceff2-2760-4a34-90fb-e637a2c5ebb5')
912    def test_adv_data_set_manu_id_invalid_manu_id(self):
913        """Tests advertisement data's manufacturers invalid id.
914
915        This advertisement data from "set" advertisement manufacturers data
916        should not be successful on an invalid id.
917
918        Steps:
919        1. Build a new AdvertiseData object.
920        2. Set the AdvertiseData's manufacturers id to -1.
921        3. Build the advertisement data.
922
923        Expected Result:
924        Building the advertisement data should fail.
925
926        Returns:
927          True is pass
928          False if fail
929
930        TAGS: LE, Advertising
931        Priority: 1
932        """
933        self.log.debug("Step 1: Setup environment.")
934        droid = self.ad_dut.droid
935        exp_manu_id = -1
936        exp_manu_specific_data = [1, 2, 3]
937        self.log.debug(
938            "Step 2: Set the filtering data object's service data manu id: {}"
939            ", manu specific data: {}".format(exp_manu_id,
940                                              exp_manu_specific_data))
941        return self.verify_invalid_adv_data_manu_id(droid, exp_manu_id,
942                                                    exp_manu_specific_data)
943
944    @BluetoothBaseTest.bt_test_wrap
945    @test_tracker_info(uuid='27ccd7d7-9cd2-4e95-8198-ef6ca746d1cc')
946    def test_adv_data_set_manu_id_invalid_manu_specific_data(self):
947        """Tests advertisement data's manufacturers invalid specific data.
948
949        This advertisement data from "set" advertisement manufacturers data
950        should not be successful on an invalid specific data.
951
952        Steps:
953        1. Build a new AdvertiseData object.
954        2. Set the AdvertiseData's manufacturers specific data to helloworld.
955        3. Build the advertisement data.
956
957        Expected Result:
958        Building the advertisement data should fail.
959
960        Returns:
961          True is pass
962          False if fail
963
964        TAGS: LE, Advertising
965        Priority: 1
966        """
967        self.log.debug("Step 1: Setup environment.")
968        droid = self.ad_dut.droid
969        exp_manu_id = 0
970        exp_manu_specific_data = ['helloworld']
971        self.log.debug(
972            "Step 2: Set the filtering data object's service data manu id: {}"
973            ", manu specific data: {}".format(exp_manu_id,
974                                              exp_manu_specific_data))
975        return self.verify_invalid_adv_data_manu_id(droid, exp_manu_id,
976                                                    exp_manu_specific_data)
977
978    @BluetoothBaseTest.bt_test_wrap
979    @test_tracker_info(uuid='8e78d444-cd25-4c17-9532-53972a6f0ffe')
980    def test_adv_data_set_manu_id_max(self):
981        """Tests advertisement data's manufacturers id to the max size.
982
983        This advertisement data from "set" advertisement manufacturers data
984        should match the corresponding "get" function.
985
986        Steps:
987        1. Build a new AdvertiseData object.
988        2. Set the AdvertiseData's manufacturers id to JavaInterger.MAX value.
989        3. Get the attributes of the AdvertiseData object.
990        4. Compare the attributes found against the attributes exp.
991
992        Expected Result:
993        Found attributes should match expected attributes.
994
995        Returns:
996          True is pass
997          False if fail
998
999        TAGS: LE, Advertising
1000        Priority: 3
1001        """
1002        self.log.debug("Step 1: Setup environment.")
1003        droid = self.ad_dut.droid
1004        exp_manu_id = java_integer['max']
1005        exp_manu_specific_data = [1, 2, 3]
1006        self.log.debug(
1007            "Step 2: Set the filtering data object's service data manu id: {}"
1008            ", manu specific data: {}".format(exp_manu_id,
1009                                              exp_manu_specific_data))
1010        return self.verify_adv_data_manu_id(droid, exp_manu_id,
1011                                            exp_manu_specific_data)
1012
1013    @BluetoothBaseTest.bt_test_wrap
1014    @test_tracker_info(uuid='6c4866b7-ddf5-44ef-a231-0af683c6db80')
1015    def test_adv_data_set_include_tx_power_level_true(self):
1016        """Tests advertisement data's include tx power level to True.
1017
1018        This advertisement data from "set" advertisement manufacturers data
1019        should match the corresponding "get" function.
1020
1021        Steps:
1022        1. Build a new AdvertiseData object.
1023        2. Set the AdvertiseData's include tx power level to True.
1024        3. Get the attributes of the AdvertiseData object.
1025        4. Compare the attributes found against the attributes exp.
1026
1027        Expected Result:
1028        Found attributes should match expected attributes.
1029
1030        Returns:
1031          True is pass
1032          False if fail
1033
1034        TAGS: LE, Advertising
1035        Priority: 1
1036        """
1037        self.log.debug("Step 1: Setup environment.")
1038        droid = self.ad_dut.droid
1039        exp_include_tx_power_level = True
1040        self.log.debug(
1041            "Step 2: Set the filtering data object's include tx power level: "
1042            "{}".format(exp_include_tx_power_level))
1043        return self.verify_adv_data_include_tx_power_level(
1044            droid, exp_include_tx_power_level)
1045
1046    @BluetoothBaseTest.bt_test_wrap
1047    @test_tracker_info(uuid='db06cc5f-60cf-4f04-b0fe-0c354f987541')
1048    def test_adv_data_set_include_tx_power_level_false(self):
1049        """Tests advertisement data's include tx power level to False.
1050
1051        This advertisement data from "set" advertisement manufacturers data
1052        should match the corresponding "get" function.
1053
1054        Steps:
1055        1. Build a new AdvertiseData object.
1056        2. Set the AdvertiseData's include tx power level to False.
1057        3. Get the attributes of the AdvertiseData object.
1058        4. Compare the attributes found against the attributes exp.
1059
1060        Expected Result:
1061        Found attributes should match expected attributes.
1062
1063        Returns:
1064          True is pass
1065          False if fail
1066
1067        TAGS: LE, Advertising
1068        Priority: 1
1069        """
1070        self.log.debug("Step 1: Setup environment.")
1071        droid = self.ad_dut.droid
1072        exp_include_tx_power_level = False
1073        self.log.debug(
1074            "Step 2: Set the filtering data object's include tx power level: {}"
1075            .format(exp_include_tx_power_level))
1076        return self.verify_adv_data_include_tx_power_level(
1077            droid, exp_include_tx_power_level)
1078
1079    @BluetoothBaseTest.bt_test_wrap
1080    @test_tracker_info(uuid='e99480c4-fd37-4791-a8d0-7eb8f8f72d62')
1081    def test_adv_data_set_include_device_name_true(self):
1082        """Tests advertisement data's include device name to True.
1083
1084        This advertisement data from "set" advertisement manufacturers data
1085        should match the corresponding "get" function.
1086
1087        Steps:
1088        1. Build a new AdvertiseData object.
1089        2. Set the AdvertiseData's include device name to True.
1090        3. Get the attributes of the AdvertiseData object.
1091        4. Compare the attributes found against the attributes exp.
1092
1093        Expected Result:
1094        Found attributes should match expected attributes.
1095
1096        Returns:
1097          True is pass
1098          False if fail
1099
1100        TAGS: LE, Advertising
1101        Priority: 1
1102        """
1103        self.log.debug("Step 1: Setup environment.")
1104        droid = self.ad_dut.droid
1105        exp_include_device_name = True
1106        self.log.debug(
1107            "Step 2: Set the filtering data object's include device name: {}"
1108            .format(exp_include_device_name))
1109        return self.verify_adv_data_include_device_name(
1110            droid, exp_include_device_name)
1111
1112    @BluetoothBaseTest.bt_test_wrap
1113    @test_tracker_info(uuid='b89ed642-c426-4777-8217-7bb8c2058592')
1114    def test_adv_data_set_include_device_name_false(self):
1115        """Tests advertisement data's include device name to False.
1116
1117        This advertisement data from "set" advertisement manufacturers data
1118        should match the corresponding "get" function.
1119
1120        Steps:
1121        1. Build a new AdvertiseData object.
1122        2. Set the AdvertiseData's include device name to False.
1123        3. Get the attributes of the AdvertiseData object.
1124        4. Compare the attributes found against the attributes exp.
1125
1126        Expected Result:
1127        Found attributes should match expected attributes.
1128
1129        Returns:
1130          True is pass
1131          False if fail
1132
1133        TAGS: LE, Advertising
1134        Priority: 1
1135        """
1136        self.log.debug("Step 1: Setup environment.")
1137        test_result = True
1138        droid = self.ad_dut.droid
1139        exp_include_device_name = False
1140        self.log.debug(
1141            "Step 2: Set the filtering data object's include device name: {}".
1142            format(exp_include_device_name))
1143        return self.verify_adv_data_include_device_name(
1144            droid, exp_include_device_name)
1145
1146    @BluetoothBaseTest.bt_test_wrap
1147    @test_tracker_info(uuid='5033bcf5-a841-4b8b-af35-92c7237c7b36')
1148    def test_advertisement_greater_than_31_bytes(self):
1149        """Tests advertisement data's size to be greater than 31 bytes.
1150
1151        This advertisement data from "set" advertisement manufacturers data
1152        should match the corresponding "get" function.
1153
1154        Steps:
1155        1. Build a new AdvertiseData object.
1156        2. Set the AdvertiseData's size to be greater than 31 bytes
1157        3. Build the advertisement data.
1158
1159        Expected Result:
1160        Api fails to build the AdvertiseData.
1161
1162        Returns:
1163          True is pass
1164          False if fail
1165
1166        TAGS: LE, Advertising
1167        Priority: 1
1168        """
1169        test_result = True
1170        droid = self.ad_dut.droid
1171        ed = self.android_devices[0].ed
1172        service_data = []
1173        for i in range(25):
1174            service_data.append(i)
1175        droid.bleAddAdvertiseDataServiceData(
1176            "0000110D-0000-1000-8000-00805F9B34FB", service_data)
1177        advcallback, adv_data, adv_settings = generate_ble_advertise_objects(
1178            droid)
1179        droid.bleStartBleAdvertising(advcallback, adv_data, adv_settings)
1180        try:
1181            ed.pop_event(adv_fail.format(advcallback))
1182        except rpc_client.Sl4aApiError:
1183            self.log.info("{} event was not found.".format(
1184                adv_fail.format(advcallback)))
1185            return False
1186        return test_result
1187
1188    def verify_adv_settings_adv_mode(self, droid, exp_adv_mode):
1189        try:
1190            droid.bleSetAdvertiseSettingsAdvertiseMode(exp_adv_mode)
1191        except BleAdvertiseVerificationError as error:
1192            self.log.debug(str(error))
1193            return False
1194        self.log.debug("Step 3: Get a filtering settings object's index.")
1195        settings_index = droid.bleBuildAdvertiseSettings()
1196        self.log.debug("Step 4: Get the filtering setting's filtering mode.")
1197        adv_mode = droid.bleGetAdvertiseSettingsMode(settings_index)
1198        if exp_adv_mode is not adv_mode:
1199            self.log.debug("exp value: {}, Actual value: {}".format(
1200                exp_adv_mode, adv_mode))
1201            return False
1202        self.log.debug("Advertise Setting's filtering mode {} value "
1203                       "test Passed.".format(exp_adv_mode))
1204        return True
1205
1206    def verify_adv_settings_tx_power_level(self, droid, exp_adv_tx_power):
1207        try:
1208            droid.bleSetAdvertiseSettingsTxPowerLevel(exp_adv_tx_power)
1209        except BleAdvertiseVerificationError as error:
1210            self.log.debug(str(error))
1211            return False
1212        self.log.debug("Step 3: Get a filtering settings object's index.")
1213        settings_index = droid.bleBuildAdvertiseSettings()
1214        self.log.debug("Step 4: Get the filtering setting's tx power level.")
1215        adv_tx_power_level = droid.bleGetAdvertiseSettingsTxPowerLevel(
1216            settings_index)
1217        if exp_adv_tx_power is not adv_tx_power_level:
1218            self.log.debug("exp value: {}, Actual value: {}".format(
1219                exp_adv_tx_power, adv_tx_power_level))
1220            return False
1221        self.log.debug("Advertise Setting's tx power level {}"
1222                       "  value test Passed.".format(exp_adv_tx_power))
1223        return True
1224
1225    def verify_adv_settings_is_connectable(self, droid, exp_is_connectable):
1226        try:
1227            droid.bleSetAdvertiseSettingsIsConnectable(exp_is_connectable)
1228        except BleAdvertiseVerificationError as error:
1229            self.log.debug(str(error))
1230            return False
1231        self.log.debug("Step 3: Get a filtering settings object's index.")
1232        settings_index = droid.bleBuildAdvertiseSettings()
1233        self.log.debug(
1234            "Step 4: Get the filtering setting's is connectable value.")
1235        is_connectable = droid.bleGetAdvertiseSettingsIsConnectable(
1236            settings_index)
1237        if exp_is_connectable is not is_connectable:
1238            self.log.debug("exp value: {}, Actual value: {}".format(
1239                exp_is_connectable, is_connectable))
1240            return False
1241        self.log.debug("Advertise Setting's is connectable {}"
1242                       " value test Passed.".format(exp_is_connectable))
1243        return True
1244
1245    def verify_adv_settings_own_address_type(self, droid, exp_adv_own_address_type):
1246        try:
1247            droid.bleSetAdvertiseSettingsOwnAddressType(exp_adv_own_address_type)
1248        except BleAdvertiseVerificationError as error:
1249            self.log.debug(str(error))
1250            return False
1251        self.log.debug("Step 3: Get a filtering settings object's index.")
1252        settings_index = droid.bleBuildAdvertiseSettings()
1253        self.log.debug("Step 4: Get the filtering setting's own address type.")
1254        adv_own_address_type = droid.bleGetAdvertiseSettingsOwnAddressType(
1255            settings_index)
1256        if exp_adv_own_address_type is not adv_own_address_type:
1257            self.log.debug("exp value: {}, Actual value: {}".format(
1258                exp_adv_own_address_type, adv_own_address_type))
1259            return False
1260        self.log.debug("Advertise Setting's own address type {}"
1261                       "  value test Passed.".format(exp_adv_own_address_type))
1262        return True
1263
1264    def verify_adv_set_address_type_start_adv(self, droid, own_address_type, uuid, service_data):
1265        try:
1266            droid.bleSetAdvertiseSettingsOwnAddressType(own_address_type)
1267        except BleAdvertiseVerificationError as error:
1268            self.log.debug(str(error))
1269            return False
1270
1271        droid.bleAddAdvertiseDataServiceData(
1272            uuid, service_data)
1273        advcallback, adv_data, adv_settings = generate_ble_advertise_objects(
1274            droid)
1275        droid.bleStartBleAdvertising(advcallback, adv_data, adv_settings)
1276
1277        adv_own_address_type = droid.bleGetAdvertiseSettingsOwnAddressType(
1278            adv_settings)
1279        if own_address_type is not adv_own_address_type:
1280            self.log.debug("exp value: {}, Actual value: {}".format(
1281                own_address_type, adv_own_address_type))
1282            return False
1283
1284        try:
1285            event = self.android_devices[0].ed.pop_event(adv_succ.format(advcallback), 10)
1286            self.log.info("Ble Advertise Success Event: {}".format(event))
1287        except rpc_client.Sl4aApiError:
1288            self.log.info("{} event was not found.".format(
1289                adv_succ.format(advcallback)))
1290            return False
1291
1292        return True
1293
1294    def verify_adv_data_service_uuids(self, droid, exp_service_uuids):
1295        try:
1296            droid.bleSetAdvertiseDataSetServiceUuids(exp_service_uuids)
1297        except BleAdvertiseVerificationError as error:
1298            self.log.debug(str(error))
1299            return False
1300        self.log.debug("Step 3: Get a filtering data object's index.")
1301        data_index = droid.bleBuildAdvertiseData()
1302        self.log.debug("Step 4: Get the filtering data's service uuids.")
1303        service_uuids = droid.bleGetAdvertiseDataServiceUuids(data_index)
1304        if exp_service_uuids != service_uuids:
1305            self.log.debug("exp value: {}, Actual value: {}".format(
1306                exp_service_uuids, service_uuids))
1307            return False
1308        self.log.debug(
1309            "Advertise Data's service uuids {}, value test Passed.".format(
1310                exp_service_uuids))
1311        return True
1312
1313    def verify_adv_data_service_data(self, droid, exp_service_data_uuid,
1314                                     exp_service_data):
1315        try:
1316            droid.bleAddAdvertiseDataServiceData(exp_service_data_uuid,
1317                                                 exp_service_data)
1318        except BleAdvertiseVerificationError as error:
1319            self.log.debug(str(error))
1320            return False
1321        self.log.debug("Step 3: Get a filtering data object's index.")
1322        data_index = droid.bleBuildAdvertiseData()
1323        self.log.debug("Step 4: Get the filtering data's service data.")
1324        service_data = droid.bleGetAdvertiseDataServiceData(
1325            data_index, exp_service_data_uuid)
1326        if exp_service_data != service_data:
1327            self.log.debug("exp value: {}, Actual value: {}".format(
1328                exp_service_data, service_data))
1329            return False
1330        self.log.debug("Advertise Data's service data uuid: {}, service data: "
1331                       "{}, value test Passed.".format(exp_service_data_uuid,
1332                                                       exp_service_data))
1333        return True
1334
1335    def verify_adv_data_manu_id(self, droid, exp_manu_id,
1336                                exp_manu_specific_data):
1337        try:
1338            droid.bleAddAdvertiseDataManufacturerId(exp_manu_id,
1339                                                    exp_manu_specific_data)
1340        except BleAdvertiseVerificationError as error:
1341            self.log.debug(str(error))
1342            return False
1343        self.log.debug("Step 3: Get a filtering data object's index.")
1344        data_index = droid.bleBuildAdvertiseData()
1345        self.log.debug("Step 5: Get the filtering data's manu specific data.")
1346        manu_specific_data = droid.bleGetAdvertiseDataManufacturerSpecificData(
1347            data_index, exp_manu_id)
1348        if exp_manu_specific_data != manu_specific_data:
1349            self.log.debug("exp value: " + str(exp_manu_specific_data) +
1350                           ", Actual value: " + str(manu_specific_data))
1351            return False
1352        self.log.debug("Advertise Data's manu id: " + str(exp_manu_id) +
1353                       ", manu's specific data: " +
1354                       str(exp_manu_specific_data) + "  value test Passed.")
1355        return True
1356
1357    def verify_adv_data_include_tx_power_level(self, droid,
1358                                               exp_include_tx_power_level):
1359        try:
1360            droid.bleSetAdvertiseDataIncludeTxPowerLevel(
1361                exp_include_tx_power_level)
1362        except BleAdvertiseVerificationError as error:
1363            self.log.debug(str(error))
1364            return False
1365        self.log.debug("Step 3: Get a filtering settings object's index.")
1366        data_index = droid.bleBuildAdvertiseData()
1367        self.log.debug(
1368            "Step 4: Get the filtering data's include tx power level.")
1369        include_tx_power_level = droid.bleGetAdvertiseDataIncludeTxPowerLevel(
1370            data_index)
1371        if exp_include_tx_power_level is not include_tx_power_level:
1372            self.log.debug("exp value: " + str(exp_include_tx_power_level) +
1373                           ", Actual value: " + str(include_tx_power_level))
1374            return False
1375        self.log.debug("Advertise Setting's include tx power level " + str(
1376            exp_include_tx_power_level) + "  value test Passed.")
1377        return True
1378
1379    def verify_adv_data_include_device_name(self, droid,
1380                                            exp_include_device_name):
1381        try:
1382            droid.bleSetAdvertiseDataIncludeDeviceName(exp_include_device_name)
1383        except BleAdvertiseVerificationError as error:
1384            self.log.debug(str(error))
1385            return False
1386        self.log.debug("Step 3: Get a filtering settings object's index.")
1387        data_index = droid.bleBuildAdvertiseData()
1388        self.log.debug("Step 4: Get the filtering data's include device name.")
1389        include_device_name = droid.bleGetAdvertiseDataIncludeDeviceName(
1390            data_index)
1391        if exp_include_device_name is not include_device_name:
1392            self.log.debug("exp value: {}, Actual value: {}".format(
1393                exp_include_device_name, include_device_name))
1394            return False
1395        self.log.debug("Advertise Setting's include device name {}"
1396                       " value test Passed.".format(exp_include_device_name))
1397        return True
1398
1399    def verify_invalid_adv_settings_adv_mode(self, droid, exp_adv_mode):
1400        try:
1401            droid.bleSetAdvertiseSettingsAdvertiseMode(exp_adv_mode)
1402            droid.bleBuildAdvertiseSettings()
1403            self.log.debug("Set Advertise settings invalid filtering mode "
1404                           "passed with input as {}".format(exp_adv_mode))
1405            return False
1406        except rpc_client.Sl4aApiError:
1407            self.log.debug(
1408                "Set Advertise settings invalid filtering mode "
1409                "failed successfully with input as {}".format(exp_adv_mode))
1410            return True
1411
1412    def verify_invalid_adv_settings_tx_power_level(self, droid,
1413                                                   exp_adv_tx_power):
1414        try:
1415            droid.bleSetAdvertiseSettingsTxPowerLevel(exp_adv_tx_power)
1416            droid.bleBuildAdvertiseSettings()
1417            self.log.debug("Set Advertise settings invalid tx power level " +
1418                           " with input as {}".format(exp_adv_tx_power))
1419            return False
1420        except rpc_client.Sl4aApiError:
1421            self.log.debug(
1422                "Set Advertise settings invalid tx power level "
1423                "failed successfullywith input as {}".format(exp_adv_tx_power))
1424            return True
1425
1426    def verify_invalid_adv_settings_own_address_type(self, droid,
1427                                                   exp_adv_own_address_type):
1428        try:
1429            droid.bleSetAdvertiseSettingsOwnAddressType(exp_adv_own_address_type)
1430            droid.bleBuildAdvertiseSettings()
1431            self.log.debug("Set Advertise settings invalid own address type " +
1432                           " with input as {}".format(exp_adv_own_address_type))
1433            return False
1434        except rpc_client.Sl4aApiError:
1435            self.log.debug(
1436                "Set Advertise settings invalid own address type "
1437                "failed successfully with input as {}".format(exp_adv_own_address_type))
1438            return True
1439
1440    def verify_invalid_adv_data_service_uuids(self, droid, exp_service_uuids):
1441        try:
1442            droid.bleSetAdvertiseDataSetServiceUuids(exp_service_uuids)
1443            droid.bleBuildAdvertiseData()
1444            self.log.debug("Set Advertise Data service uuids " +
1445                           " with input as {}".format(exp_service_uuids))
1446            return False
1447        except rpc_client.Sl4aApiError:
1448            self.log.debug(
1449                "Set Advertise Data invalid service uuids failed "
1450                "successfully with input as {}".format(exp_service_uuids))
1451            return True
1452
1453    def verify_invalid_adv_data_service_data(
1454            self, droid, exp_service_data_uuid, exp_service_data):
1455        try:
1456            droid.bleAddAdvertiseDataServiceData(exp_service_data_uuid,
1457                                                 exp_service_data)
1458            droid.bleBuildAdvertiseData()
1459            self.log.debug("Set Advertise Data service data uuid: {},"
1460                           ", service data: {}".format(exp_service_data_uuid,
1461                                                       exp_service_data))
1462            return False
1463        except rpc_client.Sl4aApiError:
1464            self.log.debug("Set Advertise Data service data uuid: " +
1465                           str(exp_service_data_uuid) + ", service data: " +
1466                           str(exp_service_data) + " failed successfully.")
1467            return True
1468
1469    def verify_invalid_adv_data_manu_id(self, droid, exp_manu_id,
1470                                        exp_manu_specific_data):
1471        try:
1472            droid.bleAddAdvertiseDataManufacturerId(exp_manu_id,
1473                                                    exp_manu_specific_data)
1474            droid.bleBuildAdvertiseData()
1475            self.log.debug(
1476                "Set Advertise Data manu id: " + str(exp_manu_id) +
1477                ", manu specific data: " + str(exp_manu_specific_data))
1478            return False
1479        except rpc_client.Sl4aApiError:
1480            self.log.debug("Set Advertise Data manu id: {},"
1481                           " manu specific data: {},".format(
1482                               exp_manu_id, exp_manu_specific_data))
1483            return True
1484