1#!/usr/bin/env python3
2#
3#   Copyright 2018 - The Android Open Source Project
4#
5#   Licensed under the Apache License, Version 2.0 (the 'License');
6#   you may not use this file except in compliance with the License.
7#   You may obtain a copy of 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,
13#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#   See the License for the specific language governing permissions and
15#   limitations under the License.
16
17import time
18
19import acts.test_utils.tel.anritsu_utils as anritsu_utils
20import acts.controllers.anritsu_lib.md8475a as md8475a
21
22import acts.test_utils.power.cellular.cellular_power_base_test as PWCEL
23from acts.test_utils.tel.tel_test_utils import initiate_call, hangup_call, set_phone_silent_mode
24
25
26class PowerTelVoLTECallTest(PWCEL.PowerCellularLabBaseTest):
27    """ VoLTE call power test.
28
29    Inherits from PowerCellularLabBaseTest. Contains methods to initiate
30    a voice call from the IMS server and pick up on the UE.
31
32    """
33
34    # Waiting time before trying to pick up from the phone
35    CALL_INITIATING_TIME = 10
36
37    def setup_class(self):
38        """ Executed only once when initializing the class. """
39
40        super().setup_class()
41
42        # Set voice call volume to minimum
43        set_phone_silent_mode(self.log, self.dut)
44
45    def power_volte_call_test(self):
46        """ Measures power during a VoLTE call.
47
48        Measurement step in this test. Starts the voice call and
49        initiates power measurement. Pass or fail is decided with a
50        threshold value. """
51
52        # Initiate the voice call
53        self.anritsu.ims_cscf_call_action(
54            anritsu_utils.DEFAULT_IMS_VIRTUAL_NETWORK_ID,
55            md8475a.ImsCscfCall.MAKE.value)
56
57        # Wait for the call to be started
58        time.sleep(self.CALL_INITIATING_TIME)
59
60        # Pickup the call
61        self.dut.adb.shell('input keyevent KEYCODE_CALL')
62
63        # Mute the call
64        self.dut.droid.telecomCallMute()
65
66        # Turn of screen
67        self.dut.droid.goToSleepNow()
68
69        # Measure power
70        self.collect_power_data()
71
72        # End the call
73        hangup_call(self.log, self.dut)
74
75        # Check if power measurement is within the required values
76        self.pass_fail_check()
77