1#!/usr/bin/env python3
2#
3# Copyright (C) 2019 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"""
17Script for initializing a cmd line tool for PTS and other purposes.
18Required custom config parameters:
19'target_mac_address': '00:00:00:00:00:00'
20
21"""
22from acts.base_test import BaseTestClass
23from cmd_input import CmdInput
24from queue import Empty
25
26
27class BluetoothCmdLineTest(BaseTestClass):
28    target_device_name = ""
29
30    def setup_class(self):
31        super().setup_class()
32        dut = self.user_params.get('dut', None)
33        if dut:
34            if dut == 'fuchsia_devices':
35                self.dut = self.fuchsia_devices[0]
36                self.dut.btc_lib.initBluetoothControl()
37                self.dut.sdp_lib.init()
38            elif dut == 'android_devices':
39                self.dut = self.android_devices[0]
40            else:
41                raise ValueError('Invalid DUT specified in config. (%s)' %
42                                 self.user_params['dut'])
43        else:
44            # Default is an Fuchsia device
45            self.dut = self.fuchsia_devices[0]
46        if not "target_device_name" in self.user_params.keys():
47            self.log.warning("Missing user config \"target_device_name\"!")
48            self.target_device_name = ""
49        else:
50            self.target_device_name = self.user_params["target_device_name"]
51
52    def test_cmd_line_helper(self):
53        cmd_line = CmdInput()
54        cmd_line.setup_vars(self.dut, self.target_device_name, self.log)
55        cmd_line.cmdloop()
56        return True
57