• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2#
3#   Copyright 2019 - 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 acts_contrib.test_utils.power.PowerGnssBaseTest as GBT
18from acts_contrib.test_utils.gnss import dut_log_test_utils as diaglog
19from acts_contrib.test_utils.gnss import gnss_test_utils as gutil
20import time
21import os
22from acts import utils
23MDLOG_RUNNING_TIME = 1200
24DUT_ACTION_WAIT_TIME = 2
25
26class PowerGnssDpoSimTest(GBT.PowerGnssBaseTest):
27    """Power baseline tests for rockbottom state.
28    Rockbottom for GNSS on/off, screen on/off, everything else turned off
29
30    """
31
32    def measure_gnsspower_test_func(self):
33        """Test function for baseline rockbottom tests.
34
35        Decode the test config from the test name, set device to desired state.
36        Measure power and plot results.
37        """
38        result = self.collect_power_data()
39        self.pass_fail_check(result.average_current)
40
41    # Test cases
42    def test_gnss_dpoOFF_measurement(self):
43        utils.set_location_service(self.dut, True)
44        time.sleep(DUT_ACTION_WAIT_TIME)
45        self.dut.reboot()
46        gutil.write_modemconfig(self.dut, self.mdsapp,
47                                self.dpooff_nv_dict, self.modemparfile)
48        self.dut.reboot()
49        gutil.verify_modemconfig(self.dut, self.dpooff_nv_dict, self.modemparfile)
50        gutil.clear_aiding_data_by_gtw_gpstool(self.dut)
51        gutil.start_gnss_by_gtw_gpstool(self.dut, state=True, type="gnss",
52                                        bgdisplay=True)
53        time.sleep(DUT_ACTION_WAIT_TIME)
54        diaglog.start_diagmdlog_background(self.dut, maskfile=self.maskfile)
55        self.disconnect_usb(self.dut, MDLOG_RUNNING_TIME)
56        qxdm_log_path = os.path.join(self.log_path, 'QXDM')
57        diaglog.stop_background_diagmdlog(self.dut, qxdm_log_path, keep_logs=False)
58        self.measure_gnsspower_test_func()
59        gutil.start_gnss_by_gtw_gpstool(self.dut, state=False)
60        gps_log_path = os.path.join(self.log_path, 'GPS_LOGS')
61        diaglog.get_gpstool_logs(self.dut, gps_log_path, keep_logs=False)
62
63    def test_gnss_dpoON_measurement(self):
64        utils.set_location_service(self.dut, True)
65        time.sleep(DUT_ACTION_WAIT_TIME)
66        self.dut.reboot()
67        gutil.write_modemconfig(self.dut, self.mdsapp,
68                                self.dpoon_nv_dict, self.modemparfile)
69        self.dut.reboot()
70        gutil.verify_modemconfig(self.dut, self.dpoon_nv_dict, self.modemparfile)
71        gutil.clear_aiding_data_by_gtw_gpstool(self.dut)
72        gutil.start_gnss_by_gtw_gpstool(self.dut, state=True,type="gnss",
73                                        bgdisplay=True)
74        time.sleep(DUT_ACTION_WAIT_TIME)
75        diaglog.start_diagmdlog_background(self.dut, maskfile=self.maskfile)
76        self.disconnect_usb(self.dut, MDLOG_RUNNING_TIME)
77        qxdm_log_path = os.path.join(self.log_path, 'QXDM')
78        diaglog.stop_background_diagmdlog(self.dut, qxdm_log_path, keep_logs=False)
79
80        self.measure_gnsspower_test_func()
81        gutil.start_gnss_by_gtw_gpstool(self.dut, state=False)
82        gps_log_path = os.path.join(self.log_path, 'GPS_LOGS')
83        diaglog.get_gpstool_logs(self.dut, gps_log_path, keep_logs=False)
84
85    def test_gnss_rockbottom(self):
86        self.dut.send_keycode("SLEEP")
87        time.sleep(120)
88        self.measure_gnsspower_test_func()
89