1#  Copyright (C) 2023 The Android Open Source Project
2#
3#  Licensed under the Apache License, Version 2.0 (the "License");
4#  you may not use this file except in compliance with the License.
5#  You may obtain a copy of the License at
6#
7#       http://www.apache.org/licenses/LICENSE-2.0
8#
9#  Unless required by applicable law or agreed to in writing, software
10#  distributed under the License is distributed on an "AS IS" BASIS,
11#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12#  See the License for the specific language governing permissions and
13#  limitations under the License.
14
15"""Test of basic calling with given digits
16 Steps include:
17        1) Precall state check on devices. (OK)
18        2) Enable the drive mode in IVI device
19        3) Make a call to any digits number using IVI device
20        4) Assert calling number on IVI device same as called
21        5) End call on IVI device
22        6) Get latest dialed number from the IVI device
23        7) Assert dialed number on the IVI device same as called ten digits number
24        8) Enable the Park Mode in IVI device
25"""
26
27import logging
28from bluetooth_test import bluetooth_base_test
29from utilities import constants
30from utilities.main_utils import common_main
31
32
33class UxRestrictionBluetoothCallFromDialerTest(bluetooth_base_test.BluetoothBaseTest):
34
35    def setup_class(self):
36        super().setup_class()
37        self.common_utils = CommonUtils(self.target, self.discoverer)
38
39    def setup_test(self):
40        # Pair the devices
41        self.bt_utils.pair_primary_to_secondary()
42        #set driving mode
43        self.call_utils.enable_driving_mode()
44
45    def test_call_from_dialer_during_drive_mode(self):
46        #Tests the calling ten digits number functionality during drive mode.
47        #Variable
48        dialer_test_phone_number = constants.DIALER_THREE_DIGIT_NUMBER;
49
50        self.call_utils.dial_a_number(dialer_test_phone_number)
51        self.call_utils.make_call()
52        self.call_utils.wait_with_log(5)
53        self.call_utils.verify_dialing_number(dialer_test_phone_number)
54        self.call_utils.end_call()
55        self.call_utils.wait_with_log(5)
56        logging.info("Call ended, open history now ")
57        self.call_utils.open_call_history()
58        self.call_utils.wait_with_log(15)
59        self.call_utils.verify_last_dialed_number(dialer_test_phone_number)
60        logging.info("Number verified")
61
62    def teardown_test(self):
63        self.call_utils.end_call_using_adb_command(self.target)
64        self.call_utils.wait_with_log(5)
65        self.call_utils.press_home()
66        # Disable driving mode
67        self.call_utils.disable_driving_mode()
68        super().teardown_test()
69
70if __name__ == '__main__':
71    common_main()