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 |
Nathan Harold | 05a6c27 | 2016-10-17 13:55:53 -0700 | [diff] [blame] | 30 | from acts.test_utils.tel.tel_defines import INVALID_SUB_ID |
Yang Liu | df164e3 | 2016-01-07 16:49:32 -0800 | [diff] [blame] | 31 | 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] | 32 | from acts.test_utils.tel.tel_defines import PRECISE_CALL_STATE_LISTEN_LEVEL_BACKGROUND |
| 33 | from acts.test_utils.tel.tel_defines import PRECISE_CALL_STATE_LISTEN_LEVEL_FOREGROUND |
| 34 | from acts.test_utils.tel.tel_defines import PRECISE_CALL_STATE_LISTEN_LEVEL_RINGING |
| 35 | from acts.test_utils.tel.tel_defines import WAIT_TIME_AFTER_REBOOT |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 36 | from acts.test_utils.tel.tel_lookup_tables import device_capabilities |
| 37 | from acts.test_utils.tel.tel_lookup_tables import operator_capabilities |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 38 | from acts.test_utils.tel.tel_test_utils import WifiUtils |
Yang Liu | 52cc020 | 2015-12-28 14:08:52 -0800 | [diff] [blame] | 39 | 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] | 40 | from acts.test_utils.tel.tel_test_utils import ensure_wifi_connected |
Yang Liu | 52cc020 | 2015-12-28 14:08:52 -0800 | [diff] [blame] | 41 | from acts.test_utils.tel.tel_test_utils import get_operator_name |
Yang Liu | 52cc020 | 2015-12-28 14:08:52 -0800 | [diff] [blame] | 42 | from acts.test_utils.tel.tel_test_utils import setup_droid_properties |
| 43 | from acts.test_utils.tel.tel_test_utils import set_phone_screen_on |
| 44 | from acts.test_utils.tel.tel_test_utils import set_phone_silent_mode |
| 45 | from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 46 | from acts.test_utils.tel.tel_test_utils import verify_http_connection |
Yang Liu | 52cc020 | 2015-12-28 14:08:52 -0800 | [diff] [blame] | 47 | 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] | 48 | 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] | 49 | from acts.test_utils.tel.tel_voice_utils import phone_setup_volte |
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 | |
Betty Zhou | 061ae08 | 2016-12-01 15:26:24 -0800 | [diff] [blame^] | 57 | self.wifi_network_ssid = self.user_params.get( |
| 58 | "wifi_network_ssid") or self.user_params.get( |
| 59 | "wifi_network_ssid_2g") |
| 60 | self.wifi_network_pass = self.user_params.get( |
| 61 | "wifi_network_pass") or self.user_params.get( |
| 62 | "wifi_network_pass_2g") |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 63 | |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 64 | """ Tests Begin """ |
Nathan Harold | b1487af | 2016-07-19 16:05:37 -0700 | [diff] [blame] | 65 | |
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. |
Betty Zhou | 061ae08 | 2016-12-01 15:26:24 -0800 | [diff] [blame^] | 72 | toggle_airplane_mode(self.log, ad, False, strict_checking=False) |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 73 | try: |
| 74 | if not ensure_wifi_connected(self.log, ad, self.wifi_network_ssid, |
| 75 | self.wifi_network_pass): |
Nathan Harold | 05a6c27 | 2016-10-17 13:55:53 -0700 | [diff] [blame] | 76 | self._preflight_fail("{}: WiFi connect fail.".format( |
| 77 | ad.serial)) |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 78 | if (not wait_for_wifi_data_connection(self.log, ad, True) or |
| 79 | not verify_http_connection(self.log, ad)): |
Nathan Harold | 05a6c27 | 2016-10-17 13:55:53 -0700 | [diff] [blame] | 80 | self._preflight_fail("{}: Data not available on WiFi.".format( |
| 81 | ad.serial)) |
Yang Liu | d772709 | 2016-05-24 14:38:36 -0700 | [diff] [blame] | 82 | finally: |
| 83 | WifiUtils.wifi_toggle_state(self.log, ad, False) |
| 84 | # TODO: add more environment check here. |
| 85 | return True |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 86 | |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 87 | @TelephonyBaseTest.tel_test_wrap |
| 88 | def test_pre_flight_check(self): |
Nathan Harold | b1487af | 2016-07-19 16:05:37 -0700 | [diff] [blame] | 89 | for ad in self.android_devices: |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 90 | #check for sim and service |
| 91 | subInfo = ad.droid.subscriptionGetAllSubInfoList() |
| 92 | if not subInfo or len(subInfo) < 1: |
Nathan Harold | 05a6c27 | 2016-10-17 13:55:53 -0700 | [diff] [blame] | 93 | self._preflight_fail( |
| 94 | "{}: Unable to find A valid subscription!".format( |
| 95 | ad.serial)) |
Betty Zhou | 061ae08 | 2016-12-01 15:26:24 -0800 | [diff] [blame^] | 96 | toggle_airplane_mode(self.log, ad, False, strict_checking=False) |
Nathan Harold | 05a6c27 | 2016-10-17 13:55:53 -0700 | [diff] [blame] | 97 | if ad.droid.subscriptionGetDefaultDataSubId() <= INVALID_SUB_ID: |
| 98 | self._preflight_fail("{}: No Default Data Sub ID".format( |
| 99 | ad.serial)) |
| 100 | elif ad.droid.subscriptionGetDefaultVoiceSubId() <= INVALID_SUB_ID: |
| 101 | self._preflight_fail("{}: No Valid Voice Sub ID".format( |
| 102 | ad.serial)) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 103 | sub_id = ad.droid.subscriptionGetDefaultVoiceSubId() |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 104 | if not wait_for_voice_attach_for_subscription( |
Nathan Harold | b1487af | 2016-07-19 16:05:37 -0700 | [diff] [blame] | 105 | self.log, ad, sub_id, MAX_WAIT_TIME_NW_SELECTION): |
Nathan Harold | 05a6c27 | 2016-10-17 13:55:53 -0700 | [diff] [blame] | 106 | self._preflight_fail( |
| 107 | "{}: Did Not Attach For Voice Services".format(ad.serial)) |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 108 | return True |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 109 | |
Nathan Harold | b1487af | 2016-07-19 16:05:37 -0700 | [diff] [blame] | 110 | def _preflight_fail(self, message): |
| 111 | self.log.error( |
| 112 | "Aborting all ongoing tests due to preflight check failure.") |
| 113 | abort_all(message) |
| 114 | |
Nathan Harold | 0f76cf2 | 2015-12-30 16:33:25 -0800 | [diff] [blame] | 115 | |
Ang Li | 73697b3 | 2015-12-03 00:41:53 +0000 | [diff] [blame] | 116 | """ Tests End """ |
Betty Zhou | 061ae08 | 2016-12-01 15:26:24 -0800 | [diff] [blame^] | 117 | |