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
15import logging
16import re
17import time
18
19from mobly.controllers import android_device
20from utilities import constants
21
22class PhoneDeviceUtils:
23    """Utility for controlling individual mobile device
24
25    This class provides functions that execute generic call sequences.
26
27    """
28    def __init__(self, phone_device):
29        self.phone_device = phone_device
30
31    def call_number_from_home_screen(self, number):
32        """Assumes the phone is on its home screen.
33        Opens the phone app, then dial pad, enters the given number, and starts a call"""
34        self.phone_device.mbs.pressPhoneIcon()
35        self.phone_device.mbs.pressDialpadIcon()
36        logging.info("Calling %s from phone device" % number)
37        self.phone_device.mbs.enterNumberOnDialpad(number)
38        self.phone_device.mbs.pressCallButton()