tturney | 1bdf77d | 2015-12-28 17:46:13 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python3.4 |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 2 | # |
tturney | 1bdf77d | 2015-12-28 17:46:13 -0800 | [diff] [blame] | 3 | # Copyright 2016 - Google |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 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 | """ |
| 17 | Test Script for Telephony Pre Flight check. |
| 18 | """ |
| 19 | |
| 20 | import time |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 21 | from queue import Empty |
Yang Liu | 52cc020 | 2015-12-28 14:08:52 -0800 | [diff] [blame] | 22 | from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 23 | from acts.test_utils.tel.tel_defines import AOSP_PREFIX |
| 24 | from acts.test_utils.tel.tel_defines import CAPABILITY_PHONE |
| 25 | from acts.test_utils.tel.tel_defines import CAPABILITY_VOLTE |
| 26 | from acts.test_utils.tel.tel_defines import CAPABILITY_VT |
| 27 | from acts.test_utils.tel.tel_defines import CAPABILITY_WFC |
| 28 | from acts.test_utils.tel.tel_defines import CAPABILITY_MSIM |
| 29 | from acts.test_utils.tel.tel_defines import CAPABILITY_OMADM |
Yang Liu | df164e3 | 2016-01-07 16:49:32 -0800 | [diff] [blame] | 30 | from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_NW_SELECTION |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 31 | from acts.test_utils.tel.tel_defines import PRECISE_CALL_STATE_LISTEN_LEVEL_BACKGROUND |
| 32 | from acts.test_utils.tel.tel_defines import PRECISE_CALL_STATE_LISTEN_LEVEL_FOREGROUND |
| 33 | from acts.test_utils.tel.tel_defines import PRECISE_CALL_STATE_LISTEN_LEVEL_RINGING |
| 34 | from acts.test_utils.tel.tel_defines import WAIT_TIME_AFTER_REBOOT |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 35 | from acts.test_utils.tel.tel_lookup_tables import device_capabilities |
| 36 | from acts.test_utils.tel.tel_lookup_tables import operator_capabilities |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame^] | 37 | from acts.test_utils.tel.tel_test_utils import WifiUtils |
Yang Liu | 52cc020 | 2015-12-28 14:08:52 -0800 | [diff] [blame] | 38 | from acts.test_utils.tel.tel_test_utils import ensure_phones_default_state |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame^] | 39 | from acts.test_utils.tel.tel_test_utils import ensure_wifi_connected |
Yang Liu | 52cc020 | 2015-12-28 14:08:52 -0800 | [diff] [blame] | 40 | from acts.test_utils.tel.tel_test_utils import get_operator_name |
Yang Liu | 52cc020 | 2015-12-28 14:08:52 -0800 | [diff] [blame] | 41 | from acts.test_utils.tel.tel_test_utils import setup_droid_properties |
| 42 | from acts.test_utils.tel.tel_test_utils import set_phone_screen_on |
| 43 | from acts.test_utils.tel.tel_test_utils import set_phone_silent_mode |
| 44 | from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame^] | 45 | from acts.test_utils.tel.tel_test_utils import verify_http_connection |
Yang Liu | 52cc020 | 2015-12-28 14:08:52 -0800 | [diff] [blame] | 46 | from acts.test_utils.tel.tel_test_utils import wait_for_voice_attach_for_subscription |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame^] | 47 | from acts.test_utils.tel.tel_test_utils import wait_for_wifi_data_connection |
Yang Liu | 52cc020 | 2015-12-28 14:08:52 -0800 | [diff] [blame] | 48 | from acts.test_utils.tel.tel_voice_utils import phone_setup_volte |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 49 | from acts.utils import load_config |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame^] | 50 | from acts.asserts import abort_all |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 51 | |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 52 | |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 53 | class TelLivePreflightTest(TelephonyBaseTest): |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 54 | def __init__(self, controllers): |
| 55 | TelephonyBaseTest.__init__(self, controllers) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 56 | |
| 57 | self.simconf = load_config(self.user_params["sim_conf_file"]) |
| 58 | |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame^] | 59 | self.wifi_network_ssid = self.user_params["wifi_network_ssid"] |
| 60 | try: |
| 61 | self.wifi_network_pass = self.user_params["wifi_network_pass"] |
| 62 | except KeyError: |
| 63 | self.wifi_network_pass = None |
| 64 | |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 65 | """ Tests Begin """ |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame^] | 66 | @TelephonyBaseTest.tel_test_wrap |
| 67 | def test_check_environment(self): |
| 68 | ad = self.android_devices[0] |
| 69 | # Check WiFi environment. |
| 70 | # 1. Connect to WiFi. |
| 71 | # 2. Check WiFi have Internet access. |
| 72 | toggle_airplane_mode(self.log, ad, True) |
| 73 | try: |
| 74 | if not ensure_wifi_connected(self.log, ad, self.wifi_network_ssid, |
| 75 | self.wifi_network_pass): |
| 76 | abort_all("WiFi connect fail.") |
| 77 | if (not wait_for_wifi_data_connection(self.log, ad, True) or |
| 78 | not verify_http_connection(self.log, ad)): |
| 79 | abort_all("Data not available on WiFi.") |
| 80 | finally: |
| 81 | WifiUtils.wifi_toggle_state(self.log, ad, False) |
| 82 | # TODO: add more environment check here. |
| 83 | return True |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 84 | |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 85 | @TelephonyBaseTest.tel_test_wrap |
| 86 | def test_pre_flight_check(self): |
| 87 | def droid_has_phone(log, ad): |
| 88 | #check for sim and service |
| 89 | subInfo = ad.droid.subscriptionGetAllSubInfoList() |
| 90 | if not subInfo or len(subInfo) < 1: |
| 91 | return False |
| 92 | toggle_airplane_mode(log, ad, False) |
| 93 | sub_id = ad.droid.subscriptionGetDefaultVoiceSubId() |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 94 | if not wait_for_voice_attach_for_subscription( |
Yang Liu | df164e3 | 2016-01-07 16:49:32 -0800 | [diff] [blame] | 95 | log, ad, sub_id, MAX_WAIT_TIME_NW_SELECTION): |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 96 | log.error("{} didn't find a cell network".format(ad.serial)) |
| 97 | return False |
| 98 | return True |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 99 | |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 100 | def droid_has_provisioning(log, ad): |
| 101 | if not ad.droid.imsIsVolteProvisionedOnDevice(): |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 102 | log.error("{}: VoLTE Not Provisioned on the Platform".format( |
| 103 | ad.serial)) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 104 | return False |
| 105 | else: |
| 106 | log.info("{} VoLTE Provisioned".format(ad.serial)) |
| 107 | return True |
| 108 | |
| 109 | def droid_has_volte(log, ad): |
| 110 | if not ad.droid.imsIsEnhanced4gLteModeSettingEnabledByPlatform(): |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 111 | log.error("{}: VoLTE Not Enabled on the Platform".format( |
| 112 | ad.serial)) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 113 | return False |
| 114 | else: |
| 115 | log.info("{} VoLTE Enabled by platform".format(ad.serial)) |
| 116 | return True |
| 117 | |
| 118 | def droid_has_wifi_calling(log, ad): |
| 119 | if not ad.droid.imsIsWfcEnabledByPlatform(): |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 120 | log.error("{}: WFC Not Enabled on the Platform".format( |
| 121 | ad.serial)) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 122 | return False |
| 123 | else: |
| 124 | log.info("{} WFC Enabled by platform".format(ad.serial)) |
| 125 | return True |
| 126 | |
| 127 | def droid_has_vt(log, ad): |
| 128 | if not ad.droid.imsIsVtEnabledByPlatform(): |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 129 | log.error("{}: VT Not Enabled on the Platform".format( |
| 130 | ad.serial)) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 131 | return False |
| 132 | else: |
| 133 | log.info("{} VT Enabled by platform".format(ad.serial)) |
| 134 | return True |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 135 | try: |
| 136 | for ad in self.android_devices: |
| 137 | model = ad.model |
| 138 | # Remove aosp prefix |
| 139 | if model.startswith(AOSP_PREFIX): |
| 140 | model = model[len(AOSP_PREFIX):] |
| 141 | |
| 142 | # Special capability phone, needed to get SIM Operator |
| 143 | if not CAPABILITY_PHONE in device_capabilities[model]: |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 144 | self.log.info("Skipping {}:{}: not a phone".format( |
| 145 | ad.serial, model)) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 146 | return True |
| 147 | |
| 148 | operator = get_operator_name(self.log, ad) |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 149 | self.log.info( |
| 150 | "Pre-flight check for <{}>, <{}:{}>, build<{}>".format( |
| 151 | operator, model, ad.serial, ad.droid.getBuildID())) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 152 | |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 153 | if ("force_provisioning" in self.user_params and |
| 154 | CAPABILITY_OMADM in device_capabilities[model] and |
| 155 | CAPABILITY_OMADM in operator_capabilities[operator] and |
| 156 | not droid_has_provisioning(self.log, ad)): |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 157 | self.log.info("{} not IMS Provisioned!!".format(ad.serial)) |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 158 | self.log.info("{} Forcing IMS Provisioning!".format( |
| 159 | ad.serial)) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 160 | ad.droid.imsSetVolteProvisioning(True) |
| 161 | self.log.info("{} reboot!".format(ad.serial)) |
| 162 | ad.reboot() |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 163 | self.log.info("{} wait {}s for radio up.".format( |
| 164 | ad.serial, WAIT_TIME_AFTER_REBOOT)) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 165 | # This sleep WAIT_TIME_AFTER_REBOOT seconds is waiting for |
| 166 | # radio to initiate after phone reboot. |
| 167 | time.sleep(WAIT_TIME_AFTER_REBOOT) |
| 168 | |
| 169 | active_capabilities = [CAPABILITY_PHONE, CAPABILITY_OMADM, |
| 170 | CAPABILITY_VOLTE, CAPABILITY_WFC] |
| 171 | for capability in active_capabilities: |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 172 | if (capability in device_capabilities[model] and |
| 173 | capability in operator_capabilities[operator]): |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 174 | if not { |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 175 | # TODO: b/26337715 make the check table global |
| 176 | CAPABILITY_PHONE: droid_has_phone, |
| 177 | CAPABILITY_OMADM: droid_has_provisioning, |
| 178 | CAPABILITY_VOLTE: droid_has_volte, |
| 179 | CAPABILITY_WFC: droid_has_wifi_calling, |
| 180 | CAPABILITY_VT: droid_has_vt |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 181 | }[capability](self.log, ad): |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame^] | 182 | abort_all( |
Yang Liu | 08a580b | 2016-01-27 10:45:31 -0800 | [diff] [blame] | 183 | "Pre-flight check FAILED for <{}>, <{}:{}>." |
| 184 | " Failed Check: <{}>".format( |
| 185 | operator, model, ad.serial, capability)) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 186 | except Exception as e: |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame^] | 187 | abort_all("Pre-flight check exception: {}".format(e)) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 188 | return True |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 189 | |
| 190 | |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 191 | """ Tests End """ |