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