Home | History | Annotate | Download | only in pts
      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 Bluetooth Config Pusher
     18 """
     19 
     20 from acts.test_utils.bt.bt_gatt_utils import disconnect_gatt_connection
     21 from acts.test_utils.bt.bt_gatt_utils import setup_gatt_connection
     22 from acts.test_utils.bt.bt_gatt_utils import setup_gatt_mtu
     23 from acts.test_utils.bt.GattEnum import GattCbStrings
     24 from acts.test_utils.bt.GattEnum import GattDescriptor
     25 from acts.test_utils.bt.GattEnum import GattTransport
     26 from acts.test_utils.bt.bt_gatt_utils import log_gatt_server_uuids
     27 
     28 import time
     29 import os
     30 
     31 
     32 class ConfigLib():
     33     bluetooth_config_path = "/system/etc/bluetooth/bt_stack.conf"
     34     conf_path = "{}/configs".format(
     35         os.path.dirname(os.path.realpath(__file__)))
     36     reset_config_path = "{}/bt_stack.conf".format(conf_path)
     37     non_bond_config_path = "{}/non_bond_bt_stack.conf".format(conf_path)
     38     disable_mitm_config_path = "{}/dis_mitm_bt_stack.conf".format(conf_path)
     39 
     40     def __init__(self, log, dut):
     41         self.dut = dut
     42         self.log = log
     43 
     44     def _reset_bluetooth(self):
     45         self.dut.droid.bluetoothToggleState(False)
     46         self.dut.droid.bluetoothToggleState(True)
     47 
     48     def reset(self):
     49         self.dut.adb.push("{} {}".format(self.reset_config_path,
     50                                          self.bluetooth_config_path))
     51         self._reset_bluetooth()
     52 
     53     def set_nonbond(self):
     54         self.dut.adb.push("{} {}".format(self.non_bond_config_path,
     55                                          self.bluetooth_config_path))
     56         self._reset_bluetooth()
     57 
     58     def set_disable_mitm(self):
     59         self.dut.adb.push("{} {}".format(self.disable_mitm_config_path,
     60                                          self.bluetooth_config_path))
     61         self._reset_bluetooth()
     62