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 the
14# License for the specific language governing permissions and limitations under
15# the License.
16"""
17Bluetooth Config Pusher
18"""
19
20from acts.test_utils.bt.bt_gatt_utils import disconnect_gatt_connection
21from acts.test_utils.bt.bt_gatt_utils import setup_gatt_connection
22from acts.test_utils.bt.bt_gatt_utils import setup_gatt_mtu
23from acts.test_utils.bt.bt_gatt_utils import log_gatt_server_uuids
24
25import time
26import os
27
28
29class ConfigLib():
30    bluetooth_config_path = "/system/etc/bluetooth/bt_stack.conf"
31    conf_path = "{}/configs".format(
32        os.path.dirname(os.path.realpath(__file__)))
33    reset_config_path = "{}/bt_stack.conf".format(conf_path)
34    non_bond_config_path = "{}/non_bond_bt_stack.conf".format(conf_path)
35    disable_mitm_config_path = "{}/dis_mitm_bt_stack.conf".format(conf_path)
36
37    def __init__(self, log, dut):
38        self.dut = dut
39        self.log = log
40
41    def _reset_bluetooth(self):
42        self.dut.droid.bluetoothToggleState(False)
43        self.dut.droid.bluetoothToggleState(True)
44
45    def reset(self):
46        self.dut.adb.push("{} {}".format(self.reset_config_path,
47                                         self.bluetooth_config_path))
48        self._reset_bluetooth()
49
50    def set_nonbond(self):
51        self.dut.adb.push("{} {}".format(self.non_bond_config_path,
52                                         self.bluetooth_config_path))
53        self._reset_bluetooth()
54
55    def set_disable_mitm(self):
56        self.dut.adb.push("{} {}".format(self.disable_mitm_config_path,
57                                         self.bluetooth_config_path))
58        self._reset_bluetooth()
59