1 #/usr/bin/env python3.4 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 the 14 # License for the specific language governing permissions and limitations under 15 # the License. 16 """ 17 Test script to test BluetoothAdapter's resetFactory method. 18 """ 19 from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest 20 from acts.test_utils.bt.bt_test_utils import pair_pri_to_sec 21 22 23 class BtFactoryResetTest(BluetoothBaseTest): 24 default_timeout = 10 25 grace_timeout = 4 26 27 def __init__(self, controllers): 28 BluetoothBaseTest.__init__(self, controllers) 29 self.pri_dut = self.android_devices[0] 30 self.sec_dut = self.android_devices[1] 31 32 @BluetoothBaseTest.bt_test_wrap 33 def test_factory_reset_bluetooth(self): 34 """Test that BluetoothAdapter.factoryReset removes bonded devices 35 36 After having bonded devices, call the factoryReset method 37 in BluetoothAdapter to clear all bonded devices. Verify that 38 no bonded devices exist after calling function. 39 40 Steps: 41 1. Two Android devices should bond successfully. 42 2. Factory Reset Bluetooth on dut. 43 3. Verify that there are no bonded devices on dut. 44 45 Expected Result: 46 BluetoothAdapter should not have any bonded devices. 47 48 Returns: 49 Pass if True 50 Fail if False 51 52 TAGS: Bluetooth, Factory Reset 53 Priority: 2 54 """ 55 if not pair_pri_to_sec(self.pri_dut.droid, self.sec_dut.droid): 56 self.log.error("Failed to bond devices.") 57 return False 58 if not self.pri_dut.droid.bluetoothFactoryReset(): 59 self.log.error("BluetoothAdapter failed to factory reset.") 60 self.log.info("Verifying There are no bonded devices.") 61 if len(self.pri_dut.droid.bluetoothGetBondedDevices()) > 0: 62 print(self.pri_dut.droid.bluetoothGetBondedDevices()) 63 self.log.error("Bonded devices still exist.") 64 return False 65 return True 66