Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # Copyright 2021 - Google |
| 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 | import re |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 18 | import time |
Markus Liu | ccd9534 | 2021-07-05 01:55:05 +0800 | [diff] [blame] | 19 | from datetime import datetime, timedelta |
Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 20 | |
Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 21 | from acts import signals |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 22 | from acts.utils import rand_ascii_str |
Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 23 | from acts_contrib.test_utils.tel.loggers.protos.telephony_metric_pb2 import TelephonyVoiceTestResult |
| 24 | from acts_contrib.test_utils.tel.loggers.telephony_metric_logger import TelephonyMetricLogger |
| 25 | from acts_contrib.test_utils.tel.tel_defines import INVALID_SUB_ID |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 26 | from acts_contrib.test_utils.tel.tel_defines import MAX_WAIT_TIME_SMS_RECEIVE |
| 27 | from acts_contrib.test_utils.tel.tel_defines import WAIT_TIME_ANDROID_STATE_SETTLING |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 28 | from acts_contrib.test_utils.tel.tel_defines import WFC_MODE_CELLULAR_PREFERRED |
Richard Chang | 8d40b88 | 2021-06-28 23:58:51 +0800 | [diff] [blame] | 29 | from acts_contrib.test_utils.tel.tel_defines import YOUTUBE_PACKAGE_NAME |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 30 | from acts_contrib.test_utils.tel.tel_subscription_utils import get_default_data_sub_id |
Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 31 | from acts_contrib.test_utils.tel.tel_subscription_utils import get_incoming_voice_sub_id |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 32 | from acts_contrib.test_utils.tel.tel_subscription_utils import get_outgoing_message_sub_id |
Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 33 | from acts_contrib.test_utils.tel.tel_subscription_utils import get_outgoing_voice_sub_id |
| 34 | from acts_contrib.test_utils.tel.tel_subscription_utils import get_subid_from_slot_index |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 35 | from acts_contrib.test_utils.tel.tel_subscription_utils import get_subid_on_same_network_of_host_ad |
| 36 | from acts_contrib.test_utils.tel.tel_subscription_utils import set_dds_on_slot |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 37 | from acts_contrib.test_utils.tel.tel_subscription_utils import set_message_subid |
| 38 | from acts_contrib.test_utils.tel.tel_subscription_utils import set_subid_for_data |
| 39 | from acts_contrib.test_utils.tel.tel_subscription_utils import set_voice_sub_id |
Markus Liu | ccd9534 | 2021-07-05 01:55:05 +0800 | [diff] [blame] | 40 | from acts_contrib.test_utils.tel.tel_test_utils import active_file_download_test |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 41 | from acts_contrib.test_utils.tel.tel_test_utils import call_setup_teardown |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 42 | from acts_contrib.test_utils.tel.tel_test_utils import ensure_wifi_connected |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 43 | from acts_contrib.test_utils.tel.tel_test_utils import erase_call_forwarding_by_mmi |
| 44 | from acts_contrib.test_utils.tel.tel_test_utils import get_operator_name |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 45 | from acts_contrib.test_utils.tel.tel_test_utils import get_slot_index_from_subid |
| 46 | from acts_contrib.test_utils.tel.tel_test_utils import hangup_call |
| 47 | from acts_contrib.test_utils.tel.tel_test_utils import initiate_call |
| 48 | from acts_contrib.test_utils.tel.tel_test_utils import log_messaging_screen_shot |
| 49 | from acts_contrib.test_utils.tel.tel_test_utils import multithread_func |
| 50 | from acts_contrib.test_utils.tel.tel_test_utils import mms_send_receive_verify |
| 51 | from acts_contrib.test_utils.tel.tel_test_utils import num_active_calls |
Markus Liu | ccd9534 | 2021-07-05 01:55:05 +0800 | [diff] [blame] | 52 | from acts_contrib.test_utils.tel.tel_test_utils import power_off_sim |
| 53 | from acts_contrib.test_utils.tel.tel_test_utils import power_on_sim |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 54 | from acts_contrib.test_utils.tel.tel_test_utils import set_call_forwarding_by_mmi |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 55 | from acts_contrib.test_utils.tel.tel_test_utils import set_call_waiting |
| 56 | from acts_contrib.test_utils.tel.tel_test_utils import set_wfc_mode_for_subscription |
| 57 | from acts_contrib.test_utils.tel.tel_test_utils import sms_send_receive_verify_for_subscription |
Richard Chang | 8d40b88 | 2021-06-28 23:58:51 +0800 | [diff] [blame] | 58 | from acts_contrib.test_utils.tel.tel_test_utils import start_youtube_video |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 59 | from acts_contrib.test_utils.tel.tel_test_utils import toggle_airplane_mode |
| 60 | from acts_contrib.test_utils.tel.tel_test_utils import toggle_wfc_for_subscription |
| 61 | from acts_contrib.test_utils.tel.tel_test_utils import verify_incall_state |
| 62 | from acts_contrib.test_utils.tel.tel_test_utils import verify_http_connection |
| 63 | from acts_contrib.test_utils.tel.tel_test_utils import wait_and_reject_call_for_subscription |
Markus Liu | 528ac98 | 2021-07-19 01:30:37 +0800 | [diff] [blame^] | 64 | from acts_contrib.test_utils.tel.tel_test_utils import wifi_toggle_state |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 65 | from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_on_rat |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 66 | from acts_contrib.test_utils.tel.tel_voice_utils import phone_setup_voice_general |
Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 67 | from acts_contrib.test_utils.tel.tel_voice_utils import phone_setup_on_rat |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 68 | from acts_contrib.test_utils.tel.tel_voice_utils import swap_calls |
| 69 | from acts_contrib.test_utils.tel.tel_voice_utils import three_phone_call_forwarding_short_seq |
| 70 | from acts_contrib.test_utils.tel.tel_voice_utils import three_phone_call_waiting_short_seq |
Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 71 | from acts_contrib.test_utils.tel.tel_voice_utils import two_phone_call_msim_for_slot |
Markus Liu | ccd9534 | 2021-07-05 01:55:05 +0800 | [diff] [blame] | 72 | from acts_contrib.test_utils.tel.tel_voice_utils import wait_for_network_idle |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 73 | from acts_contrib.test_utils.tel.tel_voice_conf_utils import _test_ims_conference_merge_drop_second_call_from_participant |
| 74 | from acts_contrib.test_utils.tel.tel_voice_conf_utils import _test_wcdma_conference_merge_drop |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 75 | from acts_contrib.test_utils.tel.tel_voice_conf_utils import _three_phone_call_mo_add_mt |
Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 76 | |
| 77 | CallResult = TelephonyVoiceTestResult.CallResult.Value |
| 78 | tel_logger = TelephonyMetricLogger.for_test_case() |
| 79 | |
| 80 | def dsds_voice_call_test( |
| 81 | log, |
| 82 | ads, |
| 83 | mo_slot, |
| 84 | mt_slot, |
| 85 | dds, |
| 86 | mo_rat=["", ""], |
| 87 | mt_rat=["", ""], |
Markus Liu | 528ac98 | 2021-07-19 01:30:37 +0800 | [diff] [blame^] | 88 | call_direction="mo", |
| 89 | is_airplane_mode=False, |
| 90 | wfc_mode=[ |
| 91 | WFC_MODE_CELLULAR_PREFERRED, |
| 92 | WFC_MODE_CELLULAR_PREFERRED], |
| 93 | wifi_network_ssid=None, |
| 94 | wifi_network_pass=None, |
| 95 | turn_off_wifi_in_the_end=False, |
| 96 | turn_off_airplane_mode_in_the_end=False): |
Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 97 | """Make MO/MT voice call at specific slot in specific RAT with DDS at |
| 98 | specific slot. |
| 99 | |
| 100 | Test step: |
| 101 | 1. Get sub IDs of specific slots of both MO and MT devices. |
| 102 | 2. Switch DDS to specific slot. |
| 103 | 3. Check HTTP connection after DDS switch. |
| 104 | 4. Set up phones in desired RAT. |
| 105 | 5. Make voice call. |
Markus Liu | 528ac98 | 2021-07-19 01:30:37 +0800 | [diff] [blame^] | 106 | 6. Turn off airplane mode if necessary. |
| 107 | 7. Turn off Wi-Fi if necessary. |
| 108 | 8. Verify RAT and HTTP connection. |
Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 109 | |
| 110 | Args: |
| 111 | log: logger object |
| 112 | ads: list of android devices |
| 113 | mo_slot: Slot making MO call (0 or 1) |
| 114 | mt_slot: Slot receiving MT call (0 or 1) |
| 115 | dds: Preferred data slot |
| 116 | mo_rat: RAT for both slots of MO device |
| 117 | mt_rat: RAT for both slots of MT device |
| 118 | call_direction: "mo" or "mt" |
Markus Liu | 528ac98 | 2021-07-19 01:30:37 +0800 | [diff] [blame^] | 119 | is_airplane_mode: True or False for WFC setup |
| 120 | wfc_mode: Cellular preferred or Wi-Fi preferred. |
| 121 | wifi_network_ssid: SSID of Wi-Fi AP |
| 122 | wifi_network_pass: Password of Wi-Fi AP SSID |
| 123 | turn_off_wifi_in_the_end: True to turn off Wi-Fi and False not to turn |
| 124 | off Wi-Fi in the end of the function. |
| 125 | turn_off_airplane_mode_in_the_end: True to turn off airplane mode and |
| 126 | False not to turn off airplane mode in the end of the function. |
Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 127 | |
| 128 | Returns: |
| 129 | TestFailure if failed. |
| 130 | """ |
Markus Liu | 528ac98 | 2021-07-19 01:30:37 +0800 | [diff] [blame^] | 131 | if not toggle_airplane_mode(log, ads[0], False): |
| 132 | ads[0].log.error("Failed to disable airplane mode.") |
| 133 | return False |
| 134 | |
Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 135 | if call_direction == "mo": |
| 136 | ad_mo = ads[0] |
| 137 | ad_mt = ads[1] |
| 138 | else: |
| 139 | ad_mo = ads[1] |
| 140 | ad_mt = ads[0] |
| 141 | |
| 142 | if mo_slot is not None: |
| 143 | mo_sub_id = get_subid_from_slot_index(log, ad_mo, mo_slot) |
| 144 | if mo_sub_id == INVALID_SUB_ID: |
| 145 | ad_mo.log.warning("Failed to get sub ID ar slot %s.", mo_slot) |
| 146 | return False |
| 147 | mo_other_sub_id = get_subid_from_slot_index( |
| 148 | log, ad_mo, 1-mo_slot) |
| 149 | set_voice_sub_id(ad_mo, mo_sub_id) |
| 150 | else: |
| 151 | _, mo_sub_id, _ = get_subid_on_same_network_of_host_ad(ads) |
| 152 | if mo_sub_id == INVALID_SUB_ID: |
| 153 | ad_mo.log.warning("Failed to get sub ID ar slot %s.", mo_slot) |
| 154 | return False |
| 155 | mo_slot = "auto" |
| 156 | set_voice_sub_id(ad_mo, mo_sub_id) |
| 157 | ad_mo.log.info("Sub ID for outgoing call at slot %s: %s", |
| 158 | mo_slot, get_outgoing_voice_sub_id(ad_mo)) |
| 159 | |
| 160 | if mt_slot is not None: |
| 161 | mt_sub_id = get_subid_from_slot_index(log, ad_mt, mt_slot) |
| 162 | if mt_sub_id == INVALID_SUB_ID: |
| 163 | ad_mt.log.warning("Failed to get sub ID at slot %s.", mt_slot) |
| 164 | return False |
| 165 | mt_other_sub_id = get_subid_from_slot_index( |
| 166 | log, ad_mt, 1-mt_slot) |
| 167 | set_voice_sub_id(ad_mt, mt_sub_id) |
| 168 | else: |
| 169 | _, mt_sub_id, _ = get_subid_on_same_network_of_host_ad(ads) |
| 170 | if mt_sub_id == INVALID_SUB_ID: |
| 171 | ad_mt.log.warning("Failed to get sub ID at slot %s.", mt_slot) |
| 172 | return False |
| 173 | mt_slot = "auto" |
| 174 | set_voice_sub_id(ad_mt, mt_sub_id) |
| 175 | ad_mt.log.info("Sub ID for incoming call at slot %s: %s", mt_slot, |
| 176 | get_incoming_voice_sub_id(ad_mt)) |
| 177 | |
| 178 | log.info("Step 1: Switch DDS.") |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 179 | if not set_dds_on_slot(ads[0], dds): |
| 180 | log.error( |
| 181 | "Failed to set DDS at slot %s on %s",(dds, ads[0].serial)) |
| 182 | return False |
Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 183 | |
| 184 | log.info("Step 2: Check HTTP connection after DDS switch.") |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 185 | if not verify_http_connection(log, ads[0]): |
Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 186 | log.error("Failed to verify http connection.") |
| 187 | return False |
| 188 | else: |
| 189 | log.info("Verify http connection successfully.") |
| 190 | |
Markus Liu | 528ac98 | 2021-07-19 01:30:37 +0800 | [diff] [blame^] | 191 | log.info("Step 3: Set up phones in desired RAT.") |
Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 192 | if mo_slot == 0 or mo_slot == 1: |
Markus Liu | 528ac98 | 2021-07-19 01:30:37 +0800 | [diff] [blame^] | 193 | phone_setup_on_rat( |
| 194 | log, |
| 195 | ad_mo, |
| 196 | mo_rat[1-mo_slot], |
| 197 | mo_other_sub_id, |
| 198 | is_airplane_mode, |
| 199 | wfc_mode[1-mo_slot], |
| 200 | wifi_network_ssid, |
| 201 | wifi_network_pass) |
| 202 | |
| 203 | mo_phone_setup_func_argv = ( |
| 204 | log, |
| 205 | ad_mo, |
| 206 | mo_rat[mo_slot], |
| 207 | mo_sub_id, |
| 208 | is_airplane_mode, |
| 209 | wfc_mode[mo_slot], |
| 210 | wifi_network_ssid, |
| 211 | wifi_network_pass) |
| 212 | |
Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 213 | is_mo_in_call = is_phone_in_call_on_rat( |
| 214 | log, ad_mo, mo_rat[mo_slot], only_return_fn=True) |
| 215 | else: |
| 216 | mo_phone_setup_func_argv = (log, ad_mo, 'general') |
| 217 | is_mo_in_call = is_phone_in_call_on_rat( |
| 218 | log, ad_mo, 'general', only_return_fn=True) |
| 219 | |
| 220 | if mt_slot == 0 or mt_slot == 1: |
Markus Liu | 528ac98 | 2021-07-19 01:30:37 +0800 | [diff] [blame^] | 221 | phone_setup_on_rat( |
| 222 | log, |
| 223 | ad_mt, |
| 224 | mt_rat[1-mt_slot], |
| 225 | mt_other_sub_id, |
| 226 | is_airplane_mode, |
| 227 | wfc_mode[1-mt_slot], |
| 228 | wifi_network_ssid, |
| 229 | wifi_network_pass) |
| 230 | |
| 231 | mt_phone_setup_func_argv = ( |
| 232 | log, |
| 233 | ad_mt, |
| 234 | mt_rat[mt_slot], |
| 235 | mt_sub_id, |
| 236 | is_airplane_mode, |
| 237 | wfc_mode[mt_slot], |
| 238 | wifi_network_ssid, |
| 239 | wifi_network_pass) |
| 240 | |
Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 241 | is_mt_in_call = is_phone_in_call_on_rat( |
| 242 | log, ad_mt, mt_rat[mt_slot], only_return_fn=True) |
| 243 | else: |
| 244 | mt_phone_setup_func_argv = (log, ad_mt, 'general') |
| 245 | is_mt_in_call = is_phone_in_call_on_rat( |
| 246 | log, ad_mt, 'general', only_return_fn=True) |
| 247 | |
Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 248 | tasks = [(phone_setup_on_rat, mo_phone_setup_func_argv), |
| 249 | (phone_setup_on_rat, mt_phone_setup_func_argv)] |
| 250 | if not multithread_func(log, tasks): |
| 251 | log.error("Phone Failed to Set Up Properly.") |
| 252 | tel_logger.set_result(CallResult("CALL_SETUP_FAILURE")) |
| 253 | raise signals.TestFailure("Failed", |
| 254 | extras={"fail_reason": "Phone Failed to Set Up Properly."}) |
| 255 | |
| 256 | log.info("Step 4: Make voice call.") |
| 257 | result = two_phone_call_msim_for_slot( |
| 258 | log, |
| 259 | ad_mo, |
| 260 | get_slot_index_from_subid(log, ad_mo, mo_sub_id), |
| 261 | None, |
| 262 | is_mo_in_call, |
| 263 | ad_mt, |
| 264 | get_slot_index_from_subid(log, ad_mt, mt_sub_id), |
| 265 | None, |
| 266 | is_mt_in_call) |
| 267 | |
| 268 | tel_logger.set_result(result.result_value) |
| 269 | |
| 270 | if not result: |
| 271 | log.error( |
| 272 | "Failed to make MO call from %s slot %s to %s slot %s", |
| 273 | ad_mo.serial, mo_slot, ad_mt.serial, mt_slot) |
| 274 | raise signals.TestFailure("Failed", |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 275 | extras={"fail_reason": str(result.result_value)}) |
| 276 | |
Markus Liu | 528ac98 | 2021-07-19 01:30:37 +0800 | [diff] [blame^] | 277 | log.info("Step 5: Verify RAT and HTTP connection.") |
| 278 | if call_direction == "mo": |
| 279 | rat_list = [mo_rat[mo_slot], mo_rat[1-mo_slot]] |
| 280 | sub_id_list = [mo_sub_id, mo_other_sub_id] |
| 281 | else: |
| 282 | rat_list = [mt_rat[mt_slot], mt_rat[1-mt_slot]] |
| 283 | sub_id_list = [mt_sub_id, mt_other_sub_id] |
| 284 | |
| 285 | # For the tese cases related to WFC in which airplane mode will be turned |
| 286 | # off in the end. |
| 287 | if turn_off_airplane_mode_in_the_end: |
| 288 | log.info("Step 5-1: Turning off airplane mode......") |
| 289 | if not toggle_airplane_mode(log, ads[0], False): |
| 290 | ads[0].log.error('Failed to toggle off airplane mode.') |
| 291 | |
| 292 | # For the tese cases related to WFC in which Wi-Fi will be turned off in the |
| 293 | # end. |
| 294 | if turn_off_wifi_in_the_end: |
| 295 | log.info("Step 5-2: Turning off Wi-Fi......") |
| 296 | if not wifi_toggle_state(log, ads[0], False): |
| 297 | ads[0].log.error('Failed to toggle off Wi-Fi.') |
| 298 | return False |
| 299 | |
| 300 | for index, value in enumerate(rat_list): |
| 301 | if value == '5g_wfc': |
| 302 | rat_list[index] = '5g' |
| 303 | elif value == 'wfc': |
| 304 | rat_list[index] = '4g' |
| 305 | |
| 306 | for rat, sub_id in zip(rat_list, sub_id_list): |
| 307 | if not wait_for_network_idle(log, ads[0], rat, sub_id): |
| 308 | raise signals.TestFailure( |
| 309 | "Failed", |
| 310 | extras={ |
| 311 | "fail_reason": "Idle state of sub ID %s does not match the " |
| 312 | "given RAT %s." % (sub_id, rat)}) |
| 313 | |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 314 | def dsds_message_test( |
| 315 | log, |
| 316 | ads, |
| 317 | mo_slot, |
| 318 | mt_slot, |
| 319 | dds_slot, |
| 320 | msg="SMS", |
| 321 | mo_rat=["", ""], |
| 322 | mt_rat=["", ""], |
| 323 | direction="mo", |
Richard Chang | 8d40b88 | 2021-06-28 23:58:51 +0800 | [diff] [blame] | 324 | streaming=False, |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 325 | expected_result=True): |
| 326 | """Make MO/MT SMS/MMS at specific slot in specific RAT with DDS at |
| 327 | specific slot. |
| 328 | |
| 329 | Test step: |
| 330 | 1. Get sub IDs of specific slots of both MO and MT devices. |
| 331 | 2. Switch DDS to specific slot. |
| 332 | 3. Check HTTP connection after DDS switch. |
| 333 | 4. Set up phones in desired RAT. |
| 334 | 5. Send SMS/MMS. |
| 335 | |
| 336 | Args: |
| 337 | mo_slot: Slot sending MO SMS (0 or 1) |
| 338 | mt_slot: Slot receiving MT SMS (0 or 1) |
| 339 | dds_slot: Preferred data slot |
| 340 | mo_rat: RAT for both slots of MO device |
| 341 | mt_rat: RAT for both slots of MT device |
| 342 | direction: "mo" or "mt" |
Richard Chang | 8d40b88 | 2021-06-28 23:58:51 +0800 | [diff] [blame] | 343 | streaming: True for playing Youtube before send/receive SMS/MMS and |
| 344 | False on the contrary. |
| 345 | expected_result: True or False |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 346 | |
| 347 | Returns: |
| 348 | TestFailure if failed. |
| 349 | """ |
| 350 | if direction == "mo": |
| 351 | ad_mo = ads[0] |
| 352 | ad_mt = ads[1] |
| 353 | else: |
| 354 | ad_mo = ads[1] |
| 355 | ad_mt = ads[0] |
| 356 | |
| 357 | if mo_slot is not None: |
| 358 | mo_sub_id = get_subid_from_slot_index(log, ad_mo, mo_slot) |
| 359 | if mo_sub_id == INVALID_SUB_ID: |
| 360 | ad_mo.log.warning("Failed to get sub ID at slot %s.", mo_slot) |
| 361 | return False |
| 362 | mo_other_sub_id = get_subid_from_slot_index( |
| 363 | log, ad_mo, 1-mo_slot) |
| 364 | set_message_subid(ad_mo, mo_sub_id) |
| 365 | else: |
| 366 | _, mo_sub_id, _ = get_subid_on_same_network_of_host_ad( |
| 367 | ads, type="sms") |
| 368 | if mo_sub_id == INVALID_SUB_ID: |
| 369 | ad_mo.log.warning("Failed to get sub ID at slot %s.", mo_slot) |
| 370 | return False |
| 371 | mo_slot = "auto" |
| 372 | set_message_subid(ad_mo, mo_sub_id) |
| 373 | if msg == "MMS": |
| 374 | set_subid_for_data(ad_mo, mo_sub_id) |
| 375 | ad_mo.droid.telephonyToggleDataConnection(True) |
| 376 | ad_mo.log.info("Sub ID for outgoing %s at slot %s: %s", msg, mo_slot, |
| 377 | get_outgoing_message_sub_id(ad_mo)) |
| 378 | |
| 379 | if mt_slot is not None: |
| 380 | mt_sub_id = get_subid_from_slot_index(log, ad_mt, mt_slot) |
| 381 | if mt_sub_id == INVALID_SUB_ID: |
| 382 | ad_mt.log.warning("Failed to get sub ID at slot %s.", mt_slot) |
| 383 | return False |
| 384 | mt_other_sub_id = get_subid_from_slot_index(log, ad_mt, 1-mt_slot) |
| 385 | set_message_subid(ad_mt, mt_sub_id) |
| 386 | else: |
| 387 | _, mt_sub_id, _ = get_subid_on_same_network_of_host_ad( |
| 388 | ads, type="sms") |
| 389 | if mt_sub_id == INVALID_SUB_ID: |
| 390 | ad_mt.log.warning("Failed to get sub ID at slot %s.", mt_slot) |
| 391 | return False |
| 392 | mt_slot = "auto" |
| 393 | set_message_subid(ad_mt, mt_sub_id) |
| 394 | if msg == "MMS": |
| 395 | set_subid_for_data(ad_mt, mt_sub_id) |
| 396 | ad_mt.droid.telephonyToggleDataConnection(True) |
| 397 | ad_mt.log.info("Sub ID for incoming %s at slot %s: %s", msg, mt_slot, |
| 398 | get_outgoing_message_sub_id(ad_mt)) |
| 399 | |
| 400 | log.info("Step 1: Switch DDS.") |
| 401 | if not set_dds_on_slot(ads[0], dds_slot): |
| 402 | log.error( |
| 403 | "Failed to set DDS at slot %s on %s",(dds_slot, ads[0].serial)) |
| 404 | return False |
| 405 | |
| 406 | log.info("Step 2: Check HTTP connection after DDS switch.") |
| 407 | if not verify_http_connection(log, ads[0]): |
| 408 | log.error("Failed to verify http connection.") |
| 409 | return False |
| 410 | else: |
| 411 | log.info("Verify http connection successfully.") |
| 412 | |
| 413 | if mo_slot == 0 or mo_slot == 1: |
| 414 | phone_setup_on_rat(log, ad_mo, mo_rat[1-mo_slot], mo_other_sub_id) |
| 415 | mo_phone_setup_func_argv = (log, ad_mo, mo_rat[mo_slot], mo_sub_id) |
| 416 | else: |
| 417 | mo_phone_setup_func_argv = (log, ad_mo, 'general', mo_sub_id) |
| 418 | |
| 419 | if mt_slot == 0 or mt_slot == 1: |
| 420 | phone_setup_on_rat(log, ad_mt, mt_rat[1-mt_slot], mt_other_sub_id) |
| 421 | mt_phone_setup_func_argv = (log, ad_mt, mt_rat[mt_slot], mt_sub_id) |
| 422 | else: |
| 423 | mt_phone_setup_func_argv = (log, ad_mt, 'general', mt_sub_id) |
| 424 | |
| 425 | log.info("Step 3: Set up phones in desired RAT.") |
| 426 | tasks = [(phone_setup_on_rat, mo_phone_setup_func_argv), |
| 427 | (phone_setup_on_rat, mt_phone_setup_func_argv)] |
| 428 | if not multithread_func(log, tasks): |
| 429 | log.error("Phone Failed to Set Up Properly.") |
| 430 | return False |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 431 | time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING) |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 432 | |
Richard Chang | 8d40b88 | 2021-06-28 23:58:51 +0800 | [diff] [blame] | 433 | if streaming: |
| 434 | log.info("Step 4: Start Youtube streaming.") |
| 435 | if not start_youtube_video(ads[0]): |
| 436 | log.warning("Fail to bring up youtube video") |
| 437 | time.sleep(10) |
| 438 | else: |
| 439 | log.info("Step 4: Skip Youtube streaming.") |
| 440 | |
| 441 | log.info("Step 5: Send %s.", msg) |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 442 | if msg == "MMS": |
| 443 | for ad, current_data_sub_id, current_msg_sub_id in [ |
| 444 | [ ads[0], |
| 445 | get_default_data_sub_id(ads[0]), |
| 446 | get_outgoing_message_sub_id(ads[0]) ], |
| 447 | [ ads[1], |
| 448 | get_default_data_sub_id(ads[1]), |
| 449 | get_outgoing_message_sub_id(ads[1]) ]]: |
| 450 | if current_data_sub_id != current_msg_sub_id: |
| 451 | ad.log.warning( |
| 452 | "Current data sub ID (%s) does not match message" |
| 453 | " sub ID (%s). MMS should NOT be sent.", |
| 454 | current_data_sub_id, |
| 455 | current_msg_sub_id) |
| 456 | expected_result = False |
| 457 | |
| 458 | result = msim_message_test(log, ad_mo, ad_mt, mo_sub_id, mt_sub_id, |
| 459 | msg=msg, expected_result=expected_result) |
| 460 | |
| 461 | if not result: |
| 462 | log_messaging_screen_shot(ad_mo, test_name="%s_tx" % msg) |
| 463 | log_messaging_screen_shot(ad_mt, test_name="%s_rx" % msg) |
| 464 | |
Richard Chang | 8d40b88 | 2021-06-28 23:58:51 +0800 | [diff] [blame] | 465 | if streaming: |
| 466 | ads[0].force_stop_apk(YOUTUBE_PACKAGE_NAME) |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 467 | return result |
| 468 | |
Markus Liu | ccd9534 | 2021-07-05 01:55:05 +0800 | [diff] [blame] | 469 | def enable_slot_after_voice_call_test( |
| 470 | log, |
| 471 | ads, |
| 472 | mo_slot, |
| 473 | mt_slot, |
| 474 | disabled_slot, |
| 475 | mo_rat=["", ""], |
| 476 | mt_rat=["", ""], |
| 477 | call_direction="mo"): |
| 478 | """Disable/enable pSIM or eSIM with voice call |
| 479 | |
| 480 | Test step: |
| 481 | 1. Get sub IDs of specific slots of both MO and MT devices. |
| 482 | 2. Set up phones in desired RAT. |
| 483 | 3. Disable assigned slot. |
| 484 | 4. Switch DDS to the other slot. |
| 485 | 5. Verify RAT and HTTP connection after DDS switch. |
| 486 | 6. Make voice call. |
| 487 | 7. Enable assigned slot. |
| 488 | 8. Switch DDS to the assigned slot. |
| 489 | 9. Verify RAT and HTTP connection after DDS switch. |
| 490 | |
| 491 | Args: |
| 492 | log: logger object |
| 493 | ads: list of android devices |
| 494 | mo_slot: Slot making MO call (0 or 1) |
| 495 | mt_slot: Slot receiving MT call (0 or 1) |
| 496 | disabled_slot: slot to be disabled/enabled |
| 497 | mo_rat: RAT for both slots of MO device |
| 498 | mt_rat: RAT for both slots of MT device |
| 499 | call_direction: "mo" or "mt" |
| 500 | |
| 501 | Returns: |
| 502 | TestFailure if failed. |
| 503 | """ |
| 504 | if call_direction == "mo": |
| 505 | ad_mo = ads[0] |
| 506 | ad_mt = ads[1] |
| 507 | else: |
| 508 | ad_mo = ads[1] |
| 509 | ad_mt = ads[0] |
| 510 | |
| 511 | if mo_slot is not None: |
| 512 | mo_sub_id = get_subid_from_slot_index(log, ad_mo, mo_slot) |
| 513 | if mo_sub_id == INVALID_SUB_ID: |
| 514 | ad_mo.log.warning("Failed to get sub ID at slot %s.", mo_slot) |
| 515 | raise signals.TestFailure( |
| 516 | "Failed", |
| 517 | extras={ |
| 518 | "fail_reason": "Failed to get sub ID at slot %s." % mo_slot}) |
| 519 | mo_other_sub_id = get_subid_from_slot_index( |
| 520 | log, ad_mo, 1-mo_slot) |
| 521 | set_voice_sub_id(ad_mo, mo_sub_id) |
| 522 | else: |
| 523 | _, mo_sub_id, _ = get_subid_on_same_network_of_host_ad(ads) |
| 524 | if mo_sub_id == INVALID_SUB_ID: |
| 525 | ad_mo.log.warning("Failed to get sub ID at slot %s.", mo_slot) |
| 526 | raise signals.TestFailure( |
| 527 | "Failed", |
| 528 | extras={ |
| 529 | "fail_reason": "Failed to get sub ID at slot %s." % mo_slot}) |
| 530 | mo_slot = "auto" |
| 531 | set_voice_sub_id(ad_mo, mo_sub_id) |
| 532 | ad_mo.log.info("Sub ID for outgoing call at slot %s: %s", |
| 533 | mo_slot, get_outgoing_voice_sub_id(ad_mo)) |
| 534 | |
| 535 | if mt_slot is not None: |
| 536 | mt_sub_id = get_subid_from_slot_index(log, ad_mt, mt_slot) |
| 537 | if mt_sub_id == INVALID_SUB_ID: |
| 538 | ad_mt.log.warning("Failed to get sub ID at slot %s.", mt_slot) |
| 539 | raise signals.TestFailure( |
| 540 | "Failed", |
| 541 | extras={ |
| 542 | "fail_reason": "Failed to get sub ID at slot %s." % mt_slot}) |
| 543 | mt_other_sub_id = get_subid_from_slot_index( |
| 544 | log, ad_mt, 1-mt_slot) |
| 545 | set_voice_sub_id(ad_mt, mt_sub_id) |
| 546 | else: |
| 547 | _, mt_sub_id, _ = get_subid_on_same_network_of_host_ad(ads) |
| 548 | if mt_sub_id == INVALID_SUB_ID: |
| 549 | ad_mt.log.warning("Failed to get sub ID at slot %s.", mt_slot) |
| 550 | raise signals.TestFailure( |
| 551 | "Failed", |
| 552 | extras={ |
| 553 | "fail_reason": "Failed to get sub ID at slot %s." % mt_slot}) |
| 554 | mt_slot = "auto" |
| 555 | set_voice_sub_id(ad_mt, mt_sub_id) |
| 556 | ad_mt.log.info("Sub ID for incoming call at slot %s: %s", mt_slot, |
| 557 | get_incoming_voice_sub_id(ad_mt)) |
| 558 | |
| 559 | if mo_slot == 0 or mo_slot == 1: |
| 560 | phone_setup_on_rat(log, ad_mo, mo_rat[1-mo_slot], mo_other_sub_id) |
| 561 | mo_phone_setup_func_argv = (log, ad_mo, mo_rat[mo_slot], mo_sub_id) |
| 562 | is_mo_in_call = is_phone_in_call_on_rat( |
| 563 | log, ad_mo, mo_rat[mo_slot], only_return_fn=True) |
| 564 | else: |
| 565 | mo_phone_setup_func_argv = (log, ad_mo, 'general') |
| 566 | is_mo_in_call = is_phone_in_call_on_rat( |
| 567 | log, ad_mo, 'general', only_return_fn=True) |
| 568 | |
| 569 | if mt_slot == 0 or mt_slot == 1: |
| 570 | phone_setup_on_rat(log, ad_mt, mt_rat[1-mt_slot], mt_other_sub_id) |
| 571 | mt_phone_setup_func_argv = (log, ad_mt, mt_rat[mt_slot], mt_sub_id) |
| 572 | is_mt_in_call = is_phone_in_call_on_rat( |
| 573 | log, ad_mt, mt_rat[mt_slot], only_return_fn=True) |
| 574 | else: |
| 575 | mt_phone_setup_func_argv = (log, ad_mt, 'general') |
| 576 | is_mt_in_call = is_phone_in_call_on_rat( |
| 577 | log, ad_mt, 'general', only_return_fn=True) |
| 578 | |
| 579 | log.info("Step 1: Set up phones in desired RAT.") |
| 580 | tasks = [(phone_setup_on_rat, mo_phone_setup_func_argv), |
| 581 | (phone_setup_on_rat, mt_phone_setup_func_argv)] |
| 582 | if not multithread_func(log, tasks): |
| 583 | log.error("Phone Failed to Set Up Properly.") |
| 584 | tel_logger.set_result(CallResult("CALL_SETUP_FAILURE")) |
| 585 | raise signals.TestFailure( |
| 586 | "Failed", |
| 587 | extras={"fail_reason": "Phone Failed to Set Up Properly."}) |
| 588 | |
| 589 | log.info("Step 2: Disable slot %s.", disabled_slot) |
| 590 | if not power_off_sim(ads[0], disabled_slot): |
| 591 | raise signals.TestFailure( |
| 592 | "Failed", |
| 593 | extras={ |
| 594 | "fail_reason": "Failed to disable slot %s." % disabled_slot}) |
| 595 | |
| 596 | log.info("Step 3: Switch DDS.") |
| 597 | if not set_dds_on_slot(ads[0], 1-disabled_slot): |
| 598 | log.error( |
| 599 | "Failed to set DDS at slot %s on %s.", |
| 600 | (1-disabled_slot, ads[0].serial)) |
| 601 | raise signals.TestFailure( |
| 602 | "Failed", |
| 603 | extras={"fail_reason": "Failed to set DDS at slot %s on %s." % ( |
| 604 | 1-disabled_slot, ads[0].serial)}) |
| 605 | |
| 606 | log.info("Step 4: Verify RAT and HTTP connection after DDS switch.") |
| 607 | if mo_slot == 0 or mo_slot == 1: |
| 608 | if not wait_for_network_idle( |
| 609 | log, ad_mo, mo_rat[1-disabled_slot], mo_sub_id): |
| 610 | raise signals.TestFailure( |
| 611 | "Failed", |
| 612 | extras={ |
| 613 | "fail_reason": "Idle state does not match the given " |
| 614 | "RAT %s." % mo_rat[1-disabled_slot]}) |
| 615 | |
| 616 | if mt_slot == 0 or mt_slot == 1: |
| 617 | if not wait_for_network_idle( |
| 618 | log, ad_mt, mt_rat[1-disabled_slot], mt_sub_id): |
| 619 | raise signals.TestFailure( |
| 620 | "Failed", |
| 621 | extras={ |
| 622 | "fail_reason": "Idle state does not match the given " |
| 623 | "RAT %s." % mt_rat[1-disabled_slot]}) |
| 624 | |
| 625 | if not verify_http_connection(log, ads[0]): |
| 626 | log.error("Failed to verify http connection.") |
| 627 | raise signals.TestFailure( |
| 628 | "Failed", |
| 629 | extras={"fail_reason": "Failed to verify http connection."}) |
| 630 | else: |
| 631 | log.info("Verify http connection successfully.") |
| 632 | |
| 633 | log.info("Step 5: Make voice call.") |
| 634 | result = two_phone_call_msim_for_slot( |
| 635 | log, |
| 636 | ad_mo, |
| 637 | get_slot_index_from_subid(log, ad_mo, mo_sub_id), |
| 638 | None, |
| 639 | is_mo_in_call, |
| 640 | ad_mt, |
| 641 | get_slot_index_from_subid(log, ad_mt, mt_sub_id), |
| 642 | None, |
| 643 | is_mt_in_call) |
| 644 | |
| 645 | tel_logger.set_result(result.result_value) |
| 646 | |
| 647 | if not result: |
| 648 | log.error( |
| 649 | "Failed to make MO call from %s slot %s to %s slot %s", |
| 650 | ad_mo.serial, mo_slot, ad_mt.serial, mt_slot) |
| 651 | raise signals.TestFailure("Failed", |
| 652 | extras={"fail_reason": str(result.result_value)}) |
| 653 | |
| 654 | log.info("Step 6: Enable slot %s.", disabled_slot) |
| 655 | if not power_on_sim(ads[0], disabled_slot): |
| 656 | raise signals.TestFailure( |
| 657 | "Failed", |
| 658 | extras={"fail_reason": "Failed to enable slot %s." % disabled_slot}) |
| 659 | |
| 660 | log.info("Step 7: Switch DDS to slot %s.", disabled_slot) |
| 661 | if not set_dds_on_slot(ads[0], disabled_slot): |
| 662 | log.error( |
| 663 | "Failed to set DDS at slot %s on %s.",(disabled_slot, ads[0].serial)) |
| 664 | raise signals.TestFailure( |
| 665 | "Failed", |
| 666 | extras={"fail_reason": "Failed to set DDS at slot %s on %s." % ( |
| 667 | disabled_slot, ads[0].serial)}) |
| 668 | |
| 669 | log.info("Step 8: Verify RAT and HTTP connection after DDS switch.") |
| 670 | if mo_slot == 0 or mo_slot == 1: |
| 671 | if not wait_for_network_idle( |
| 672 | log, ad_mo, mo_rat[disabled_slot], mo_other_sub_id): |
| 673 | raise signals.TestFailure( |
| 674 | "Failed", |
| 675 | extras={ |
| 676 | "fail_reason": "Idle state does not match the given " |
| 677 | "RAT %s." % mo_rat[mo_slot]}) |
| 678 | |
| 679 | if mt_slot == 0 or mt_slot == 1: |
| 680 | if not wait_for_network_idle( |
| 681 | log, ad_mt, mt_rat[disabled_slot], mt_other_sub_id): |
| 682 | raise signals.TestFailure( |
| 683 | "Failed", |
| 684 | extras={"fail_reason": "Idle state does not match the given " |
| 685 | "RAT %s." % mt_rat[mt_slot]}) |
| 686 | |
| 687 | if not verify_http_connection(log, ads[0]): |
| 688 | log.error("Failed to verify http connection.") |
| 689 | raise signals.TestFailure( |
| 690 | "Failed", |
| 691 | extras={"fail_reason": "Failed to verify http connection."}) |
| 692 | else: |
| 693 | log.info("Verify http connection successfully.") |
| 694 | |
| 695 | def enable_slot_after_data_call_test( |
| 696 | log, |
| 697 | ad, |
| 698 | disabled_slot, |
| 699 | rat=["", ""]): |
| 700 | """Disable/enable pSIM or eSIM with data call |
| 701 | |
| 702 | Test step: |
| 703 | 1. Get sub IDs of specific slots of both MO and MT devices. |
| 704 | 2. Set up phones in desired RAT. |
| 705 | 3. Disable assigned slot. |
| 706 | 4. Switch DDS to the other slot. |
| 707 | 5. Verify RAT and HTTP connection after DDS switch. |
| 708 | 6. Make a data call by http download. |
| 709 | 7. Enable assigned slot. |
| 710 | 8. Switch DDS to the assigned slot. |
| 711 | 9. Verify RAT and HTTP connection after DDS switch. |
| 712 | |
| 713 | Args: |
| 714 | log: logger object |
| 715 | ads: list of android devices |
| 716 | disabled_slot: slot to be disabled/enabled |
| 717 | mo_rat: RAT for both slots of MO device |
| 718 | mt_rat: RAT for both slots of MT device |
| 719 | |
| 720 | Returns: |
| 721 | TestFailure if failed. |
| 722 | """ |
| 723 | data_sub_id = get_subid_from_slot_index(log, ad, 1-disabled_slot) |
| 724 | if data_sub_id == INVALID_SUB_ID: |
| 725 | ad.log.warning("Failed to get sub ID at slot %s.", 1-disabled_slot) |
| 726 | raise signals.TestFailure( |
| 727 | "Failed", |
| 728 | extras={ |
| 729 | "fail_reason": "Failed to get sub ID at slot %s." % ( |
| 730 | 1-disabled_slot)}) |
| 731 | other_sub_id = get_subid_from_slot_index(log, ad, disabled_slot) |
| 732 | |
| 733 | log.info("Step 1: Set up phones in desired RAT.") |
| 734 | if not phone_setup_on_rat(log, ad, rat[1-disabled_slot], data_sub_id): |
| 735 | raise signals.TestFailure( |
| 736 | "Failed", |
| 737 | extras={"fail_reason": "Phone Failed to Set Up Properly."}) |
| 738 | |
| 739 | if not phone_setup_on_rat(log, ad, rat[disabled_slot], other_sub_id): |
| 740 | raise signals.TestFailure( |
| 741 | "Failed", |
| 742 | extras={"fail_reason": "Phone Failed to Set Up Properly."}) |
| 743 | |
| 744 | log.info("Step 2: Disable slot %s.", disabled_slot) |
| 745 | if not power_off_sim(ad, disabled_slot): |
| 746 | raise signals.TestFailure( |
| 747 | "Failed", |
| 748 | extras={"fail_reason": "Failed to disable slot %s." % disabled_slot}) |
| 749 | |
| 750 | log.info("Step 3: Switch DDS.") |
| 751 | if not set_dds_on_slot(ad, 1-disabled_slot): |
| 752 | log.error( |
| 753 | "Failed to set DDS at slot %s on %s.",(1-disabled_slot, ad.serial)) |
| 754 | raise signals.TestFailure( |
| 755 | "Failed", |
| 756 | extras={"fail_reason": "Failed to set DDS at slot %s on %s." % ( |
| 757 | 1-disabled_slot, ad.serial)}) |
| 758 | |
| 759 | log.info("Step 4: Verify RAT and HTTP connection after DDS switch.") |
| 760 | if not wait_for_network_idle(log, ad, rat[1-disabled_slot], data_sub_id): |
| 761 | raise signals.TestFailure( |
| 762 | "Failed", |
| 763 | extras={ |
| 764 | "fail_reason": "Idle state does not match the given " |
| 765 | "RAT %s." % rat[1-disabled_slot]}) |
| 766 | |
| 767 | if not verify_http_connection(log, ad): |
| 768 | log.error("Failed to verify http connection.") |
| 769 | raise signals.TestFailure("Failed", |
| 770 | extras={"fail_reason": "Failed to verify http connection."}) |
| 771 | else: |
| 772 | log.info("Verify http connection successfully.") |
| 773 | |
| 774 | duration = 30 |
| 775 | start_time = datetime.now() |
| 776 | while datetime.now() - start_time <= timedelta(seconds=duration): |
| 777 | if not active_file_download_test( |
| 778 | log, ad, file_name='20MB', method='sl4a'): |
| 779 | raise signals.TestFailure( |
| 780 | "Failed", |
| 781 | extras={"fail_reason": "Failed to download by sl4a."}) |
| 782 | |
| 783 | log.info("Step 6: Enable slot %s.", disabled_slot) |
| 784 | if not power_on_sim(ad, disabled_slot): |
| 785 | raise signals.TestFailure( |
| 786 | "Failed", |
| 787 | extras={"fail_reason": "Failed to enable slot %s." % disabled_slot}) |
| 788 | |
| 789 | log.info("Step 7: Switch DDS to slot %s.", disabled_slot) |
| 790 | if not set_dds_on_slot(ad, disabled_slot): |
| 791 | log.error( |
| 792 | "Failed to set DDS at slot %s on %s.",(disabled_slot, ad.serial)) |
| 793 | raise signals.TestFailure( |
| 794 | "Failed", |
| 795 | extras={"fail_reason": "Failed to set DDS at slot %s on %s." % ( |
| 796 | disabled_slot, ad.serial)}) |
| 797 | |
| 798 | log.info("Step 8: Verify RAT and HTTP connection after DDS switch.") |
| 799 | if not wait_for_network_idle(log, ad, rat[disabled_slot], other_sub_id): |
| 800 | raise signals.TestFailure( |
| 801 | "Failed", |
| 802 | extras={ |
| 803 | "fail_reason": "Idle state does not match the given " |
| 804 | "RAT %s." % rat[disabled_slot]}) |
| 805 | |
| 806 | if not verify_http_connection(log, ad): |
| 807 | log.error("Failed to verify http connection.") |
| 808 | raise signals.TestFailure( |
| 809 | "Failed", |
| 810 | extras={"fail_reason": "Failed to verify http connection."}) |
| 811 | else: |
| 812 | log.info("Verify http connection successfully.") |
| 813 | |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 814 | def erase_call_forwarding(log, ad): |
| 815 | slot0_sub_id = get_subid_from_slot_index(log, ad, 0) |
| 816 | slot1_sub_id = get_subid_from_slot_index(log, ad, 1) |
| 817 | current_voice_sub_id = get_incoming_voice_sub_id(ad) |
| 818 | for sub_id in (slot0_sub_id, slot1_sub_id): |
| 819 | set_voice_sub_id(ad, sub_id) |
| 820 | get_operator_name(log, ad, sub_id) |
| 821 | erase_call_forwarding_by_mmi(log, ad) |
| 822 | set_voice_sub_id(ad, current_voice_sub_id) |
| 823 | |
| 824 | def three_way_calling_mo_and_mt_with_hangup_once( |
| 825 | log, |
| 826 | ads, |
| 827 | phone_setups, |
| 828 | verify_funcs, |
| 829 | reject_once=False): |
| 830 | """Use 3 phones to make MO call and MT call. |
| 831 | |
| 832 | Call from PhoneA to PhoneB, accept on PhoneB. |
| 833 | Call from PhoneC to PhoneA, accept on PhoneA. |
| 834 | |
| 835 | Args: |
| 836 | ads: list of ad object. |
| 837 | The list should have three objects. |
| 838 | phone_setups: list of phone setup functions. |
| 839 | The list should have three objects. |
| 840 | verify_funcs: list of phone call verify functions. |
| 841 | The list should have three objects. |
| 842 | |
| 843 | Returns: |
| 844 | If success, return 'call_AB' id in PhoneA. |
| 845 | if fail, return None. |
| 846 | """ |
| 847 | |
| 848 | class _CallException(Exception): |
| 849 | pass |
| 850 | |
| 851 | try: |
| 852 | verify_func_a, verify_func_b, verify_func_c = verify_funcs |
| 853 | tasks = [] |
| 854 | for ad, setup_func in zip(ads, phone_setups): |
| 855 | if setup_func is not None: |
| 856 | tasks.append((setup_func, (log, ad, get_incoming_voice_sub_id(ad)))) |
| 857 | if tasks != [] and not multithread_func(log, tasks): |
| 858 | log.error("Phone Failed to Set Up Properly.") |
| 859 | raise _CallException("Setup failed.") |
| 860 | for ad in ads: |
| 861 | ad.droid.telecomCallClearCallList() |
| 862 | if num_active_calls(log, ad) != 0: |
| 863 | ad.log.error("Phone Call List is not empty.") |
| 864 | raise _CallException("Clear call list failed.") |
| 865 | |
| 866 | log.info("Step1: Call From PhoneA to PhoneB.") |
| 867 | if not call_setup_teardown( |
| 868 | log, |
| 869 | ads[0], |
| 870 | ads[1], |
| 871 | ad_hangup=None, |
| 872 | verify_caller_func=verify_func_a, |
| 873 | verify_callee_func=verify_func_b): |
| 874 | raise _CallException("PhoneA call PhoneB failed.") |
| 875 | |
| 876 | calls = ads[0].droid.telecomCallGetCallIds() |
| 877 | ads[0].log.info("Calls in PhoneA %s", calls) |
| 878 | if num_active_calls(log, ads[0]) != 1: |
| 879 | raise _CallException("Call list verify failed.") |
| 880 | call_ab_id = calls[0] |
| 881 | |
| 882 | log.info("Step2: Call From PhoneC to PhoneA.") |
| 883 | if reject_once: |
| 884 | log.info("Step2-1: Reject incoming call once.") |
| 885 | if not initiate_call( |
| 886 | log, |
| 887 | ads[2], |
| 888 | ads[0].telephony['subscription'][get_incoming_voice_sub_id( |
| 889 | ads[0])]['phone_num']): |
| 890 | ads[2].log.error("Initiate call failed.") |
| 891 | raise _CallException("Failed to initiate call.") |
| 892 | |
| 893 | if not wait_and_reject_call_for_subscription( |
| 894 | log, |
| 895 | ads[0], |
| 896 | get_incoming_voice_sub_id(ads[0]), |
| 897 | incoming_number= \ |
| 898 | ads[2].telephony['subscription'][ |
| 899 | get_incoming_voice_sub_id( |
| 900 | ads[2])]['phone_num']): |
| 901 | ads[0].log.error("Reject call fail.") |
| 902 | raise _CallException("Failed to reject call.") |
| 903 | |
| 904 | hangup_call(log, ads[2]) |
| 905 | time.sleep(15) |
| 906 | |
| 907 | if not call_setup_teardown( |
| 908 | log, |
| 909 | ads[2], |
| 910 | ads[0], |
| 911 | ad_hangup=None, |
| 912 | verify_caller_func=verify_func_c, |
| 913 | verify_callee_func=verify_func_a): |
| 914 | raise _CallException("PhoneA call PhoneC failed.") |
| 915 | if not verify_incall_state(log, [ads[0], ads[1], ads[2]], |
| 916 | True): |
| 917 | raise _CallException("Not All phones are in-call.") |
| 918 | |
| 919 | except Exception as e: |
| 920 | setattr(ads[0], "exception", e) |
| 921 | return None |
| 922 | |
| 923 | return call_ab_id |
| 924 | |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 925 | def msim_message_test( |
| 926 | log, |
| 927 | ad_mo, |
| 928 | ad_mt, |
| 929 | mo_sub_id, |
| 930 | mt_sub_id, msg="SMS", |
| 931 | max_wait_time=MAX_WAIT_TIME_SMS_RECEIVE, |
| 932 | expected_result=True): |
| 933 | """Make MO/MT SMS/MMS at specific slot. |
| 934 | |
| 935 | Args: |
| 936 | ad_mo: Android object of the device sending SMS/MMS |
| 937 | ad_mt: Android object of the device receiving SMS/MMS |
| 938 | mo_sub_id: Sub ID of MO device |
| 939 | mt_sub_id: Sub ID of MT device |
| 940 | max_wait_time: Max wait time before SMS/MMS is received. |
| 941 | expected_result: True for successful sending/receiving and False on |
| 942 | the contrary |
| 943 | |
| 944 | Returns: |
| 945 | True if the result matches expected_result and False on the |
| 946 | contrary. |
| 947 | """ |
| 948 | message_lengths = (50, 160, 180) |
| 949 | if msg == "SMS": |
| 950 | for length in message_lengths: |
| 951 | message_array = [rand_ascii_str(length)] |
| 952 | if not sms_send_receive_verify_for_subscription( |
| 953 | log, |
| 954 | ad_mo, |
| 955 | ad_mt, |
| 956 | mo_sub_id, |
| 957 | mt_sub_id, |
| 958 | message_array, |
| 959 | max_wait_time): |
| 960 | ad_mo.log.warning( |
| 961 | "%s of length %s test failed", msg, length) |
| 962 | return False |
| 963 | else: |
| 964 | ad_mo.log.info( |
| 965 | "%s of length %s test succeeded", msg, length) |
| 966 | log.info("%s test of length %s characters succeeded.", |
| 967 | msg, message_lengths) |
| 968 | |
| 969 | elif msg == "MMS": |
| 970 | for length in message_lengths: |
| 971 | message_array = [("Test Message", rand_ascii_str(length), None)] |
| 972 | |
| 973 | if not mms_send_receive_verify( |
| 974 | log, |
| 975 | ad_mo, |
| 976 | ad_mt, |
| 977 | message_array, |
| 978 | max_wait_time, |
| 979 | expected_result): |
| 980 | log.warning("%s of body length %s test failed", |
| 981 | msg, length) |
| 982 | return False |
| 983 | else: |
| 984 | log.info( |
| 985 | "%s of body length %s test succeeded", msg, length) |
| 986 | log.info("%s test of body lengths %s succeeded", |
| 987 | msg, message_lengths) |
| 988 | return True |
| 989 | |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 990 | def msim_call_forwarding( |
| 991 | log, |
| 992 | ads, |
| 993 | caller_slot, |
| 994 | callee_slot, |
| 995 | forwarded_callee_slot, |
| 996 | dds_slot, |
| 997 | caller_rat=["", ""], |
| 998 | callee_rat=["", ""], |
| 999 | forwarded_callee_rat=["", ""], |
| 1000 | call_forwarding_type="unconditional"): |
| 1001 | """Make MO voice call to the primary device at specific slot in specific |
| 1002 | RAT with DDS at specific slot, and then forwarded to 3rd device with |
| 1003 | specific call forwarding type. |
| 1004 | |
| 1005 | Test step: |
| 1006 | 1. Get sub IDs of specific slots of both MO and MT devices. |
| 1007 | 2. Switch DDS to specific slot. |
| 1008 | 3. Check HTTP connection after DDS switch. |
| 1009 | 4. Set up phones in desired RAT. |
| 1010 | 5. Register and enable call forwarding with specifc type. |
| 1011 | 5. Make voice call to the primary device and wait for being forwarded |
| 1012 | to 3rd device. |
| 1013 | |
| 1014 | Args: |
| 1015 | caller_slot: Slot of 2nd device making MO call (0 or 1) |
| 1016 | callee_slot: Slot of primary device receiving and forwarding MT call |
| 1017 | (0 or 1) |
| 1018 | forwarded_callee_slot: Slot of 3rd device receiving forwarded call. |
| 1019 | dds_slot: Preferred data slot |
| 1020 | caller_rat: RAT for both slots of the 2nd device |
| 1021 | callee_rat: RAT for both slots of the primary device |
| 1022 | forwarded_callee_rat: RAT for both slots of the 3rd device |
| 1023 | call_forwarding_type: |
| 1024 | "unconditional" |
| 1025 | "busy" |
| 1026 | "not_answered" |
| 1027 | "not_reachable" |
| 1028 | |
| 1029 | Returns: |
| 1030 | True or False |
| 1031 | """ |
| 1032 | ad_caller = ads[1] |
| 1033 | ad_callee = ads[0] |
| 1034 | ad_forwarded_callee = ads[2] |
| 1035 | |
| 1036 | if callee_slot is not None: |
| 1037 | callee_sub_id = get_subid_from_slot_index( |
| 1038 | log, ad_callee, callee_slot) |
| 1039 | if callee_sub_id == INVALID_SUB_ID: |
| 1040 | ad_callee.log.warning( |
| 1041 | "Failed to get sub ID at slot %s.", callee_slot) |
| 1042 | return False |
| 1043 | callee_other_sub_id = get_subid_from_slot_index( |
| 1044 | log, ad_callee, 1-callee_slot) |
| 1045 | set_voice_sub_id(ad_callee, callee_sub_id) |
| 1046 | else: |
| 1047 | callee_sub_id, _, _ = get_subid_on_same_network_of_host_ad(ads) |
| 1048 | if callee_sub_id == INVALID_SUB_ID: |
| 1049 | ad_callee.log.warning( |
| 1050 | "Failed to get sub ID at slot %s.", callee_slot) |
| 1051 | return False |
| 1052 | callee_slot = "auto" |
| 1053 | set_voice_sub_id(ad_callee, callee_sub_id) |
| 1054 | ad_callee.log.info( |
| 1055 | "Sub ID for incoming call at slot %s: %s", |
| 1056 | callee_slot, get_incoming_voice_sub_id(ad_callee)) |
| 1057 | |
| 1058 | if caller_slot is not None: |
| 1059 | caller_sub_id = get_subid_from_slot_index( |
| 1060 | log, ad_caller, caller_slot) |
| 1061 | if caller_sub_id == INVALID_SUB_ID: |
| 1062 | ad_caller.log.warning( |
| 1063 | "Failed to get sub ID at slot %s.", caller_slot) |
| 1064 | return False |
| 1065 | caller_other_sub_id = get_subid_from_slot_index( |
| 1066 | log, ad_caller, 1-caller_slot) |
| 1067 | set_voice_sub_id(ad_caller, caller_sub_id) |
| 1068 | else: |
| 1069 | _, caller_sub_id, _ = get_subid_on_same_network_of_host_ad(ads) |
| 1070 | if caller_sub_id == INVALID_SUB_ID: |
| 1071 | ad_caller.log.warning( |
| 1072 | "Failed to get sub ID at slot %s.", caller_slot) |
| 1073 | return False |
| 1074 | caller_slot = "auto" |
| 1075 | set_voice_sub_id(ad_caller, caller_sub_id) |
| 1076 | ad_caller.log.info( |
| 1077 | "Sub ID for outgoing call at slot %s: %s", |
| 1078 | caller_slot, get_outgoing_voice_sub_id(ad_caller)) |
| 1079 | |
| 1080 | if forwarded_callee_slot is not None: |
| 1081 | forwarded_callee_sub_id = get_subid_from_slot_index( |
| 1082 | log, ad_forwarded_callee, forwarded_callee_slot) |
| 1083 | if forwarded_callee_sub_id == INVALID_SUB_ID: |
| 1084 | ad_forwarded_callee.log.warning( |
| 1085 | "Failed to get sub ID at slot %s.", forwarded_callee_slot) |
| 1086 | return False |
| 1087 | forwarded_callee_other_sub_id = get_subid_from_slot_index( |
| 1088 | log, ad_forwarded_callee, 1-forwarded_callee_slot) |
| 1089 | set_voice_sub_id( |
| 1090 | ad_forwarded_callee, forwarded_callee_sub_id) |
| 1091 | else: |
| 1092 | _, _, forwarded_callee_sub_id = \ |
| 1093 | get_subid_on_same_network_of_host_ad(ads) |
| 1094 | if forwarded_callee_sub_id == INVALID_SUB_ID: |
| 1095 | ad_forwarded_callee.log.warning( |
| 1096 | "Failed to get sub ID at slot %s.", forwarded_callee_slot) |
| 1097 | return False |
| 1098 | forwarded_callee_slot = "auto" |
| 1099 | set_voice_sub_id( |
| 1100 | ad_forwarded_callee, forwarded_callee_sub_id) |
| 1101 | ad_forwarded_callee.log.info( |
| 1102 | "Sub ID for incoming call at slot %s: %s", |
| 1103 | forwarded_callee_slot, |
| 1104 | get_incoming_voice_sub_id(ad_forwarded_callee)) |
| 1105 | |
| 1106 | log.info("Step 1: Switch DDS.") |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 1107 | if not set_dds_on_slot(ads[0], dds_slot): |
| 1108 | log.error( |
| 1109 | "Failed to set DDS at slot %s on %s",(dds_slot, ads[0].serial)) |
| 1110 | return False |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 1111 | |
| 1112 | log.info("Step 2: Check HTTP connection after DDS switch.") |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 1113 | if not verify_http_connection(log, ads[0]): |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 1114 | log.error("Failed to verify http connection.") |
| 1115 | return False |
| 1116 | else: |
| 1117 | log.info("Verify http connection successfully.") |
| 1118 | |
| 1119 | if caller_slot == 1: |
| 1120 | phone_setup_on_rat( |
| 1121 | log, |
| 1122 | ad_caller, |
| 1123 | caller_rat[0], |
| 1124 | caller_other_sub_id) |
| 1125 | |
| 1126 | elif caller_slot == 0: |
| 1127 | phone_setup_on_rat( |
| 1128 | log, |
| 1129 | ad_caller, |
| 1130 | caller_rat[1], |
| 1131 | caller_other_sub_id) |
| 1132 | else: |
| 1133 | phone_setup_on_rat( |
| 1134 | log, |
| 1135 | ad_caller, |
| 1136 | 'general') |
| 1137 | |
| 1138 | if callee_slot == 1: |
| 1139 | phone_setup_on_rat( |
| 1140 | log, |
| 1141 | ad_callee, |
| 1142 | callee_rat[0], |
| 1143 | callee_other_sub_id) |
| 1144 | |
| 1145 | elif callee_slot == 0: |
| 1146 | phone_setup_on_rat( |
| 1147 | log, |
| 1148 | ad_callee, |
| 1149 | callee_rat[1], |
| 1150 | callee_other_sub_id) |
| 1151 | else: |
| 1152 | phone_setup_on_rat( |
| 1153 | log, |
| 1154 | ad_callee, |
| 1155 | 'general') |
| 1156 | |
| 1157 | if forwarded_callee_slot == 1: |
| 1158 | phone_setup_on_rat( |
| 1159 | log, |
| 1160 | ad_forwarded_callee, |
| 1161 | forwarded_callee_rat[0], |
| 1162 | forwarded_callee_other_sub_id) |
| 1163 | |
| 1164 | elif forwarded_callee_slot == 0: |
| 1165 | phone_setup_on_rat( |
| 1166 | log, |
| 1167 | ad_forwarded_callee, |
| 1168 | forwarded_callee_rat[1], |
| 1169 | forwarded_callee_other_sub_id) |
| 1170 | else: |
| 1171 | phone_setup_on_rat( |
| 1172 | log, |
| 1173 | ad_forwarded_callee, |
| 1174 | 'general') |
| 1175 | |
| 1176 | if caller_slot == 0 or caller_slot == 1: |
| 1177 | caller_phone_setup_func_argv = (log, ad_caller, caller_rat[caller_slot], caller_sub_id) |
| 1178 | else: |
| 1179 | caller_phone_setup_func_argv = (log, ad_caller, 'general') |
| 1180 | |
| 1181 | callee_phone_setup_func_argv = (log, ad_callee, callee_rat[callee_slot], callee_sub_id) |
| 1182 | |
| 1183 | if forwarded_callee_slot == 0 or forwarded_callee_slot == 1: |
| 1184 | forwarded_callee_phone_setup_func_argv = ( |
| 1185 | log, |
| 1186 | ad_forwarded_callee, |
| 1187 | forwarded_callee_rat[forwarded_callee_slot], |
| 1188 | forwarded_callee_sub_id) |
| 1189 | else: |
| 1190 | forwarded_callee_phone_setup_func_argv = ( |
| 1191 | log, |
| 1192 | ad_forwarded_callee, |
| 1193 | 'general') |
| 1194 | |
| 1195 | log.info("Step 3: Set up phones in desired RAT.") |
| 1196 | tasks = [(phone_setup_on_rat, caller_phone_setup_func_argv), |
| 1197 | (phone_setup_on_rat, callee_phone_setup_func_argv), |
| 1198 | (phone_setup_on_rat, |
| 1199 | forwarded_callee_phone_setup_func_argv)] |
| 1200 | if not multithread_func(log, tasks): |
| 1201 | log.error("Phone Failed to Set Up Properly.") |
| 1202 | tel_logger.set_result(CallResult("CALL_SETUP_FAILURE")) |
| 1203 | raise signals.TestFailure("Failed", |
| 1204 | extras={"fail_reason": "Phone Failed to Set Up Properly."}) |
| 1205 | |
| 1206 | is_callee_in_call = is_phone_in_call_on_rat( |
| 1207 | log, ad_callee, callee_rat[callee_slot], only_return_fn=True) |
| 1208 | |
| 1209 | is_call_waiting = re.search( |
| 1210 | "call_waiting (True (\d)|False)", call_forwarding_type, re.I) |
| 1211 | if is_call_waiting: |
| 1212 | if is_call_waiting.group(1) == "False": |
| 1213 | call_waiting = False |
| 1214 | scenario = None |
| 1215 | else: |
| 1216 | call_waiting = True |
| 1217 | scenario = int(is_call_waiting.group(2)) |
| 1218 | |
| 1219 | log.info( |
| 1220 | "Step 4: Make voice call with call waiting enabled = %s.", |
| 1221 | call_waiting) |
| 1222 | result = three_phone_call_waiting_short_seq( |
| 1223 | log, |
| 1224 | ads[0], |
| 1225 | None, |
| 1226 | is_callee_in_call, |
| 1227 | ads[1], |
| 1228 | ads[2], |
| 1229 | call_waiting=call_waiting, scenario=scenario) |
| 1230 | else: |
| 1231 | log.info( |
| 1232 | "Step 4: Make voice call with call forwarding %s.", |
| 1233 | call_forwarding_type) |
| 1234 | result = three_phone_call_forwarding_short_seq( |
| 1235 | log, |
| 1236 | ads[0], |
| 1237 | None, |
| 1238 | is_callee_in_call, |
| 1239 | ads[1], |
| 1240 | ads[2], |
| 1241 | call_forwarding_type=call_forwarding_type) |
| 1242 | |
| 1243 | if not result: |
| 1244 | if is_call_waiting: |
| 1245 | pass |
| 1246 | else: |
| 1247 | log.error( |
| 1248 | "Failed to make MO call from %s slot %s to %s slot %s" |
| 1249 | " and forward to %s slot %s", |
| 1250 | ad_caller.serial, |
| 1251 | caller_slot, |
| 1252 | ad_callee.serial, |
| 1253 | callee_slot, |
| 1254 | ad_forwarded_callee.serial, |
| 1255 | forwarded_callee_slot) |
| 1256 | |
| 1257 | return result |
| 1258 | |
| 1259 | def msim_call_voice_conf( |
| 1260 | log, |
| 1261 | ads, |
| 1262 | host_slot, |
| 1263 | p1_slot, |
| 1264 | p2_slot, |
| 1265 | dds_slot, |
| 1266 | host_rat=["volte", "volte"], |
| 1267 | p1_rat="", |
| 1268 | p2_rat="", |
| 1269 | merge=True, |
| 1270 | disable_cw=False): |
| 1271 | """Make a voice conference call at specific slot in specific RAT with |
| 1272 | DDS at specific slot. |
| 1273 | |
| 1274 | Test step: |
| 1275 | 1. Get sub IDs of specific slots of both MO and MT devices. |
| 1276 | 2. Switch DDS to specific slot. |
| 1277 | 3. Check HTTP connection after DDS switch. |
| 1278 | 4. Set up phones in desired RAT and make 3-way voice call. |
| 1279 | 5. Swap calls. |
| 1280 | 6. Merge calls. |
| 1281 | |
| 1282 | Args: |
| 1283 | host_slot: Slot on the primary device to host the comference call. |
| 1284 | 0 or 1 (0 for pSIM or 1 for eSIM) |
| 1285 | p1_slot: Slot on the participant device for the call |
| 1286 | p2_slot: Slot on another participant device for the call |
| 1287 | dds_slot: Preferred data slot |
| 1288 | host_rat: RAT for both slots of the primary device |
| 1289 | p1_rat: RAT for both slots of the participant device |
| 1290 | p2_rat: RAT for both slots of another participant device |
| 1291 | merge: True for merging 2 calls into the conference call. False for |
| 1292 | not merging 2 separated call. |
| 1293 | disable_cw: True for disabling call waiting and False on the |
| 1294 | contrary. |
| 1295 | |
| 1296 | Returns: |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 1297 | True or False |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 1298 | """ |
| 1299 | ad_host = ads[0] |
| 1300 | ad_p1 = ads[1] |
| 1301 | ad_p2 = ads[2] |
| 1302 | |
| 1303 | if host_slot is not None: |
| 1304 | host_sub_id = get_subid_from_slot_index( |
| 1305 | log, ad_host, host_slot) |
| 1306 | if host_sub_id == INVALID_SUB_ID: |
| 1307 | ad_host.log.warning("Failed to get sub ID at slot.", host_slot) |
| 1308 | return False |
| 1309 | host_other_sub_id = get_subid_from_slot_index( |
| 1310 | log, ad_host, 1-host_slot) |
| 1311 | set_voice_sub_id(ad_host, host_sub_id) |
| 1312 | else: |
| 1313 | host_sub_id, _, _ = get_subid_on_same_network_of_host_ad(ads) |
| 1314 | if host_sub_id == INVALID_SUB_ID: |
| 1315 | ad_host.log.warning("Failed to get sub ID at slot.", host_slot) |
| 1316 | return False |
| 1317 | host_slot = "auto" |
| 1318 | set_voice_sub_id(ad_host, host_sub_id) |
| 1319 | |
| 1320 | ad_host.log.info("Sub ID for outgoing call at slot %s: %s", |
| 1321 | host_slot, get_outgoing_voice_sub_id(ad_host)) |
| 1322 | |
| 1323 | if p1_slot is not None: |
| 1324 | p1_sub_id = get_subid_from_slot_index(log, ad_p1, p1_slot) |
| 1325 | if p1_sub_id == INVALID_SUB_ID: |
| 1326 | ad_p1.log.warning("Failed to get sub ID at slot %s.", p1_slot) |
| 1327 | return False |
| 1328 | set_voice_sub_id(ad_p1, p1_sub_id) |
| 1329 | else: |
| 1330 | _, p1_sub_id, _ = get_subid_on_same_network_of_host_ad(ads) |
| 1331 | if p1_sub_id == INVALID_SUB_ID: |
| 1332 | ad_p1.log.warning("Failed to get sub ID at slot %s.", p1_slot) |
| 1333 | return False |
| 1334 | p1_slot = "auto" |
| 1335 | set_voice_sub_id(ad_p1, p1_sub_id) |
| 1336 | ad_p1.log.info("Sub ID for incoming call at slot %s: %s", |
| 1337 | p1_slot, get_incoming_voice_sub_id(ad_p1)) |
| 1338 | |
| 1339 | if p2_slot is not None: |
| 1340 | p2_sub_id = get_subid_from_slot_index(log, ad_p2, p2_slot) |
| 1341 | if p2_sub_id == INVALID_SUB_ID: |
| 1342 | ad_p2.log.warning("Failed to get sub ID at slot %s.", p2_slot) |
| 1343 | return False |
| 1344 | set_voice_sub_id(ad_p2, p2_sub_id) |
| 1345 | else: |
| 1346 | _, _, p2_sub_id = get_subid_on_same_network_of_host_ad(ads) |
| 1347 | if p2_sub_id == INVALID_SUB_ID: |
| 1348 | ad_p2.log.warning("Failed to get sub ID at slot %s.", p2_slot) |
| 1349 | return False |
| 1350 | p2_slot = "auto" |
| 1351 | set_voice_sub_id(ad_p2, p2_sub_id) |
| 1352 | ad_p2.log.info("Sub ID for incoming call at slot %s: %s", |
| 1353 | p2_slot, get_incoming_voice_sub_id(ad_p2)) |
| 1354 | |
| 1355 | log.info("Step 1: Switch DDS.") |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 1356 | if not set_dds_on_slot(ads[0], dds_slot): |
| 1357 | log.error( |
| 1358 | "Failed to set DDS at slot %s on %s",(dds_slot, ads[0].serial)) |
| 1359 | return False |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 1360 | |
| 1361 | log.info("Step 2: Check HTTP connection after DDS switch.") |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 1362 | if not verify_http_connection(log, ads[0]): |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 1363 | log.error("Failed to verify http connection.") |
| 1364 | return False |
| 1365 | else: |
| 1366 | log.info("Verify http connection successfully.") |
| 1367 | |
| 1368 | if disable_cw: |
| 1369 | if not set_call_waiting(log, ad_host, enable=0): |
| 1370 | return False |
| 1371 | else: |
| 1372 | if not set_call_waiting(log, ad_host, enable=1): |
| 1373 | return False |
| 1374 | |
| 1375 | if host_slot == 1: |
| 1376 | phone_setup_on_rat( |
| 1377 | log, |
| 1378 | ad_host, |
| 1379 | host_rat[0], |
| 1380 | host_other_sub_id) |
| 1381 | |
| 1382 | elif host_slot == 0: |
| 1383 | phone_setup_on_rat( |
| 1384 | log, |
| 1385 | ad_host, |
| 1386 | host_rat[1], |
| 1387 | host_other_sub_id) |
| 1388 | |
| 1389 | if host_slot == 0 or host_slot == 1: |
| 1390 | host_phone_setup_func_argv = (log, ad_host, host_rat[host_slot], host_sub_id) |
| 1391 | is_host_in_call = is_phone_in_call_on_rat( |
| 1392 | log, ad_host, host_rat[host_slot], only_return_fn=True) |
| 1393 | else: |
| 1394 | host_phone_setup_func_argv = (log, ad_host, 'general') |
| 1395 | is_host_in_call = is_phone_in_call_on_rat( |
| 1396 | log, ad_host, 'general', only_return_fn=True) |
| 1397 | |
| 1398 | if p1_rat: |
| 1399 | p1_phone_setup_func_argv = (log, ad_p1, p1_rat, p1_sub_id) |
| 1400 | is_p1_in_call = is_phone_in_call_on_rat( |
| 1401 | log, ad_p1, p1_rat, only_return_fn=True) |
| 1402 | else: |
| 1403 | p1_phone_setup_func_argv = (log, ad_p1, 'general') |
| 1404 | is_p1_in_call = is_phone_in_call_on_rat( |
| 1405 | log, ad_p1, 'general', only_return_fn=True) |
| 1406 | |
| 1407 | if p2_rat: |
| 1408 | p2_phone_setup_func_argv = (log, ad_p2, p2_rat, p2_sub_id) |
| 1409 | is_p2_in_call = is_phone_in_call_on_rat( |
| 1410 | log, ad_p2, p2_rat, only_return_fn=True) |
| 1411 | else: |
| 1412 | p2_phone_setup_func_argv = (log, ad_p2, 'general') |
| 1413 | is_p2_in_call = is_phone_in_call_on_rat( |
| 1414 | log, ad_p2, 'general', only_return_fn=True) |
| 1415 | |
| 1416 | log.info("Step 3: Set up phone in desired RAT and make 3-way" |
| 1417 | " voice call.") |
| 1418 | |
| 1419 | tasks = [(phone_setup_on_rat, host_phone_setup_func_argv), |
| 1420 | (phone_setup_on_rat, p1_phone_setup_func_argv), |
| 1421 | (phone_setup_on_rat, p2_phone_setup_func_argv)] |
| 1422 | if not multithread_func(log, tasks): |
| 1423 | log.error("Phone Failed to Set Up Properly.") |
| 1424 | tel_logger.set_result(CallResult("CALL_SETUP_FAILURE")) |
| 1425 | raise signals.TestFailure("Failed", |
| 1426 | extras={"fail_reason": "Phone Failed to Set Up Properly."}) |
| 1427 | |
| 1428 | call_ab_id = three_way_calling_mo_and_mt_with_hangup_once( |
| 1429 | log, |
| 1430 | [ad_host, ad_p1, ad_p2], |
| 1431 | [None, None, None], [ |
| 1432 | is_host_in_call, is_p1_in_call, |
| 1433 | is_p2_in_call |
| 1434 | ]) |
| 1435 | |
| 1436 | if call_ab_id is None: |
| 1437 | if disable_cw: |
| 1438 | set_call_waiting(log, ad_host, enable=1) |
| 1439 | if str(getattr(ad_host, "exception", None)) == \ |
| 1440 | "PhoneA call PhoneC failed.": |
| 1441 | ads[0].log.info("PhoneA failed to call PhoneC due to call" |
| 1442 | " waiting being disabled.") |
| 1443 | delattr(ad_host, "exception") |
| 1444 | return True |
| 1445 | log.error("Failed to get call_ab_id") |
| 1446 | return False |
| 1447 | else: |
| 1448 | if disable_cw: |
| 1449 | return False |
| 1450 | |
| 1451 | calls = ads[0].droid.telecomCallGetCallIds() |
| 1452 | ads[0].log.info("Calls in PhoneA %s", calls) |
| 1453 | if num_active_calls(log, ads[0]) != 2: |
| 1454 | return False |
| 1455 | if calls[0] == call_ab_id: |
| 1456 | call_ac_id = calls[1] |
| 1457 | else: |
| 1458 | call_ac_id = calls[0] |
| 1459 | |
| 1460 | if call_ac_id is None: |
| 1461 | log.error("Failed to get call_ac_id") |
| 1462 | return False |
| 1463 | |
| 1464 | num_swaps = 2 |
| 1465 | log.info("Step 4: Begin Swap x%s test.", num_swaps) |
| 1466 | if not swap_calls(log, ads, call_ab_id, call_ac_id, |
| 1467 | num_swaps): |
| 1468 | log.error("Swap test failed.") |
| 1469 | return False |
| 1470 | |
| 1471 | if not merge: |
| 1472 | result = True |
| 1473 | if not hangup_call(log, ads[1]): |
| 1474 | result = False |
| 1475 | if not hangup_call(log, ads[2]): |
| 1476 | result = False |
| 1477 | return result |
| 1478 | else: |
| 1479 | log.info("Step 5: Merge calls.") |
| 1480 | if host_rat[host_slot] == "volte": |
| 1481 | return _test_ims_conference_merge_drop_second_call_from_participant( |
| 1482 | log, ads, call_ab_id, call_ac_id) |
| 1483 | else: |
| 1484 | return _test_wcdma_conference_merge_drop( |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 1485 | log, ads, call_ab_id, call_ac_id) |
| 1486 | |
| 1487 | def msim_volte_wfc_call_forwarding( |
| 1488 | log, |
| 1489 | ads, |
| 1490 | callee_slot, |
| 1491 | dds_slot, |
| 1492 | callee_rat=["5g_wfc", "5g_wfc"], |
| 1493 | call_forwarding_type="unconditional", |
| 1494 | is_airplane_mode=False, |
| 1495 | is_wifi_connected=False, |
| 1496 | wfc_mode=[ |
| 1497 | WFC_MODE_CELLULAR_PREFERRED, |
| 1498 | WFC_MODE_CELLULAR_PREFERRED], |
| 1499 | wifi_network_ssid=None, |
| 1500 | wifi_network_pass=None): |
| 1501 | """Make VoLTE/WFC call to the primary device at specific slot with DDS |
| 1502 | at specific slot, and then forwarded to 3rd device with specific call |
| 1503 | forwarding type. |
| 1504 | |
| 1505 | Test step: |
| 1506 | 1. Get sub IDs of specific slots of both MO and MT devices. |
| 1507 | 2. Switch DDS to specific slot. |
| 1508 | 3. Check HTTP connection after DDS switch. |
| 1509 | 4. Set up phones in desired RAT. |
| 1510 | 5. Register and enable call forwarding with specifc type. |
| 1511 | 6. Make VoLTE/WFC call to the primary device and wait for being |
| 1512 | forwarded to 3rd device. |
| 1513 | |
| 1514 | Args: |
| 1515 | callee_slot: Slot of primary device receiving and forwarding MT call |
| 1516 | (0 or 1) |
| 1517 | dds_slot: Preferred data slot |
| 1518 | callee_rat: RAT for both slots of the primary device |
| 1519 | call_forwarding_type: |
| 1520 | "unconditional" |
| 1521 | "busy" |
| 1522 | "not_answered" |
| 1523 | "not_reachable" |
| 1524 | is_airplane_mode: True or False for WFC setup |
| 1525 | wfc_mode: Cellular preferred or Wi-Fi preferred. |
| 1526 | wifi_network_ssid: SSID of Wi-Fi AP |
| 1527 | wifi_network_pass: Password of Wi-Fi AP SSID |
| 1528 | |
| 1529 | Returns: |
| 1530 | True or False |
| 1531 | """ |
| 1532 | ad_caller = ads[1] |
| 1533 | ad_callee = ads[0] |
| 1534 | ad_forwarded_callee = ads[2] |
| 1535 | |
| 1536 | if not toggle_airplane_mode(log, ad_callee, False): |
| 1537 | ad_callee.log.error("Failed to disable airplane mode.") |
| 1538 | return False |
| 1539 | |
| 1540 | # Set up callee (primary device) |
| 1541 | callee_sub_id = get_subid_from_slot_index( |
| 1542 | log, ad_callee, callee_slot) |
| 1543 | if callee_sub_id == INVALID_SUB_ID: |
| 1544 | log.warning( |
| 1545 | "Failed to get sub ID at slot %s.", callee_slot) |
| 1546 | return |
| 1547 | callee_other_sub_id = get_subid_from_slot_index( |
| 1548 | log, ad_callee, 1-callee_slot) |
| 1549 | set_voice_sub_id(ad_callee, callee_sub_id) |
| 1550 | ad_callee.log.info( |
| 1551 | "Sub ID for incoming call at slot %s: %s", |
| 1552 | callee_slot, get_incoming_voice_sub_id(ad_callee)) |
| 1553 | |
| 1554 | # Set up caller |
| 1555 | _, caller_sub_id, _ = get_subid_on_same_network_of_host_ad(ads) |
| 1556 | if caller_sub_id == INVALID_SUB_ID: |
| 1557 | ad_caller.log.warning("Failed to get proper sub ID of the caller") |
| 1558 | return |
| 1559 | set_voice_sub_id(ad_caller, caller_sub_id) |
| 1560 | ad_caller.log.info( |
| 1561 | "Sub ID for outgoing call of the caller: %s", |
| 1562 | get_outgoing_voice_sub_id(ad_caller)) |
| 1563 | |
| 1564 | # Set up forwarded callee |
| 1565 | _, _, forwarded_callee_sub_id = get_subid_on_same_network_of_host_ad( |
| 1566 | ads) |
| 1567 | if forwarded_callee_sub_id == INVALID_SUB_ID: |
| 1568 | ad_forwarded_callee.log.warning( |
| 1569 | "Failed to get proper sub ID of the forwarded callee.") |
| 1570 | return |
| 1571 | set_voice_sub_id(ad_forwarded_callee, forwarded_callee_sub_id) |
| 1572 | ad_forwarded_callee.log.info( |
| 1573 | "Sub ID for incoming call of the forwarded callee: %s", |
| 1574 | get_incoming_voice_sub_id(ad_forwarded_callee)) |
| 1575 | |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 1576 | log.info("Step 1: Switch DDS.") |
| 1577 | if not set_dds_on_slot(ads[0], dds_slot): |
| 1578 | log.error( |
| 1579 | "Failed to set DDS at slot %s on %s",(dds_slot, ads[0].serial)) |
| 1580 | return False |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 1581 | |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 1582 | log.info("Step 2: Check HTTP connection after DDS switch.") |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 1583 | if not verify_http_connection(log, ad_callee): |
| 1584 | ad_callee.log.error("Failed to verify http connection.") |
| 1585 | return False |
| 1586 | else: |
| 1587 | ad_callee.log.info("Verify http connection successfully.") |
| 1588 | |
| 1589 | is_callee_in_call = is_phone_in_call_on_rat( |
| 1590 | log, ad_callee, callee_rat[callee_slot], only_return_fn=True) |
| 1591 | |
| 1592 | if is_airplane_mode: |
| 1593 | set_call_forwarding_by_mmi(log, ad_callee, ad_forwarded_callee) |
| 1594 | |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 1595 | log.info("Step 3: Set up phones in desired RAT.") |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 1596 | if callee_slot == 1: |
| 1597 | phone_setup_on_rat( |
| 1598 | log, |
| 1599 | ad_callee, |
| 1600 | callee_rat[0], |
| 1601 | callee_other_sub_id, |
| 1602 | is_airplane_mode, |
| 1603 | wfc_mode[0], |
| 1604 | wifi_network_ssid, |
| 1605 | wifi_network_pass) |
| 1606 | |
| 1607 | elif callee_slot == 0: |
| 1608 | phone_setup_on_rat( |
| 1609 | log, |
| 1610 | ad_callee, |
| 1611 | callee_rat[1], |
| 1612 | callee_other_sub_id, |
| 1613 | is_airplane_mode, |
| 1614 | wfc_mode[1], |
| 1615 | wifi_network_ssid, |
| 1616 | wifi_network_pass) |
| 1617 | |
| 1618 | argv = ( |
| 1619 | log, |
| 1620 | ad_callee, |
| 1621 | callee_rat[callee_slot], |
| 1622 | callee_sub_id, |
| 1623 | is_airplane_mode, |
| 1624 | wfc_mode[callee_slot], |
| 1625 | wifi_network_ssid, |
| 1626 | wifi_network_pass) |
| 1627 | |
| 1628 | tasks = [(phone_setup_voice_general, (log, ad_caller)), |
| 1629 | (phone_setup_on_rat, argv), |
| 1630 | (phone_setup_voice_general, (log, ad_forwarded_callee))] |
| 1631 | |
| 1632 | if not multithread_func(log, tasks): |
| 1633 | log.error("Phone Failed to Set Up Properly.") |
| 1634 | tel_logger.set_result(CallResult("CALL_SETUP_FAILURE")) |
| 1635 | raise signals.TestFailure("Failed", |
| 1636 | extras={"fail_reason": "Phone Failed to Set Up Properly."}) |
| 1637 | |
| 1638 | if is_wifi_connected: |
| 1639 | if not ensure_wifi_connected( |
| 1640 | log, |
| 1641 | ad_callee, |
| 1642 | wifi_network_ssid, |
| 1643 | wifi_network_pass, |
| 1644 | apm=is_airplane_mode): |
| 1645 | return False |
| 1646 | time.sleep(5) |
| 1647 | |
| 1648 | if "wfc" not in callee_rat[callee_slot]: |
| 1649 | if not toggle_wfc_for_subscription( |
| 1650 | log, |
| 1651 | ad_callee, |
| 1652 | new_state=True, |
| 1653 | sub_id=callee_sub_id): |
| 1654 | return False |
| 1655 | if not set_wfc_mode_for_subscription( |
| 1656 | ad_callee, wfc_mode[callee_slot], sub_id=callee_sub_id): |
| 1657 | return False |
| 1658 | |
| 1659 | log.info( |
| 1660 | "Step 4: Make voice call with call forwarding %s.", |
| 1661 | call_forwarding_type) |
| 1662 | result = three_phone_call_forwarding_short_seq( |
| 1663 | log, |
| 1664 | ad_callee, |
| 1665 | None, |
| 1666 | is_callee_in_call, |
| 1667 | ad_caller, |
| 1668 | ad_forwarded_callee, |
| 1669 | call_forwarding_type=call_forwarding_type) |
| 1670 | |
| 1671 | if not result: |
| 1672 | log.error( |
| 1673 | "Failed to make MO call from %s to %s slot %s and forward" |
| 1674 | " to %s.", |
| 1675 | ad_caller.serial, |
| 1676 | ad_callee.serial, |
| 1677 | callee_slot, |
| 1678 | ad_forwarded_callee.serial) |
| 1679 | return result |
| 1680 | |
| 1681 | def msim_volte_wfc_call_voice_conf( |
| 1682 | log, |
| 1683 | ads, |
| 1684 | host_slot, |
| 1685 | dds_slot, |
| 1686 | host_rat=["5g_wfc", "5g_wfc"], |
| 1687 | merge=True, |
| 1688 | disable_cw=False, |
| 1689 | is_airplane_mode=False, |
| 1690 | is_wifi_connected=False, |
| 1691 | wfc_mode=[WFC_MODE_CELLULAR_PREFERRED, WFC_MODE_CELLULAR_PREFERRED], |
| 1692 | reject_once=False, |
| 1693 | wifi_network_ssid=None, |
| 1694 | wifi_network_pass=None): |
| 1695 | """Make a VoLTE/WFC conference call at specific slot with DDS at |
| 1696 | specific slot. |
| 1697 | |
| 1698 | Test step: |
| 1699 | 1. Get sub IDs of specific slots of both MO and MT devices. |
| 1700 | 2. Set up phones in desired RAT |
| 1701 | 3. Enable VoLTE/WFC. |
| 1702 | 4. Switch DDS to specific slot. |
| 1703 | 5. Check HTTP connection after DDS switch. |
| 1704 | 6. Make 3-way VoLTE/WFC call. |
| 1705 | 7. Swap calls. |
| 1706 | 8. Merge calls. |
| 1707 | |
| 1708 | Args: |
| 1709 | host_slot: Slot on the primary device to host the comference call. |
| 1710 | 0 or 1 (0 for pSIM or 1 for eSIM)call |
| 1711 | dds_slot: Preferred data slot |
| 1712 | host_rat: RAT for both slots of the primary devicevice |
| 1713 | merge: True for merging 2 calls into the conference call. False for |
| 1714 | not merging 2 separated call. |
| 1715 | disable_cw: True for disabling call waiting and False on the |
| 1716 | contrary. |
| 1717 | enable_volte: True for enabling and False for disabling VoLTE for |
| 1718 | each slot on the primary device |
| 1719 | enable_wfc: True for enabling and False for disabling WFC for |
| 1720 | each slot on the primary device |
| 1721 | is_airplane_mode: True or False for WFC setup |
| 1722 | wfc_mode: Cellular preferred or Wi-Fi preferred. |
| 1723 | reject_once: True for rejecting the 2nd call once from the 3rd |
| 1724 | device (Phone C) to the primary device (Phone A). |
| 1725 | wifi_network_ssid: SSID of Wi-Fi AP |
| 1726 | wifi_network_pass: Password of Wi-Fi AP SSID |
| 1727 | |
| 1728 | Returns: |
| 1729 | True or False |
| 1730 | """ |
| 1731 | ad_host = ads[0] |
| 1732 | ad_p1 = ads[1] |
| 1733 | ad_p2 = ads[2] |
| 1734 | |
| 1735 | host_sub_id = get_subid_from_slot_index(log, ad_host, host_slot) |
| 1736 | if host_sub_id == INVALID_SUB_ID: |
| 1737 | ad_host.log.warning("Failed to get sub ID at slot.", host_slot) |
| 1738 | return |
| 1739 | host_other_sub_id = get_subid_from_slot_index( |
| 1740 | log, ad_host, 1-host_slot) |
| 1741 | set_voice_sub_id(ad_host, host_sub_id) |
| 1742 | ad_host.log.info( |
| 1743 | "Sub ID for outgoing call at slot %s: %s", |
| 1744 | host_slot, get_outgoing_voice_sub_id(ad_host)) |
| 1745 | |
| 1746 | _, p1_sub_id, p2_sub_id = get_subid_on_same_network_of_host_ad(ads) |
| 1747 | |
| 1748 | if p1_sub_id == INVALID_SUB_ID: |
| 1749 | ad_p1.log.warning("Failed to get proper sub ID.") |
| 1750 | return |
| 1751 | set_voice_sub_id(ad_p1, p1_sub_id) |
| 1752 | ad_p1.log.info( |
| 1753 | "Sub ID for incoming call: %s", |
| 1754 | get_incoming_voice_sub_id(ad_p1)) |
| 1755 | |
| 1756 | if p2_sub_id == INVALID_SUB_ID: |
| 1757 | ad_p2.log.warning("Failed to get proper sub ID.") |
| 1758 | return |
| 1759 | set_voice_sub_id(ad_p2, p2_sub_id) |
| 1760 | ad_p2.log.info( |
| 1761 | "Sub ID for incoming call: %s", get_incoming_voice_sub_id(ad_p2)) |
| 1762 | |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 1763 | log.info("Step 1: Switch DDS.") |
| 1764 | if not set_dds_on_slot(ads[0], dds_slot): |
| 1765 | log.error( |
| 1766 | "Failed to set DDS at slot %s on %s",(dds_slot, ads[0].serial)) |
| 1767 | return False |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 1768 | |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 1769 | log.info("Step 2: Check HTTP connection after DDS switch.") |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 1770 | if not verify_http_connection(log, ads[0]): |
| 1771 | ad_host.log.error("Failed to verify http connection.") |
| 1772 | return False |
| 1773 | else: |
| 1774 | ad_host.log.info("Verify http connection successfully.") |
| 1775 | |
| 1776 | if disable_cw: |
| 1777 | if not set_call_waiting(log, ad_host, enable=0): |
| 1778 | return False |
| 1779 | |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 1780 | log.info("Step 3: Set up phones in desired RAT.") |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 1781 | if host_slot == 1: |
| 1782 | phone_setup_on_rat( |
| 1783 | log, |
| 1784 | ad_host, |
| 1785 | host_rat[0], |
| 1786 | host_other_sub_id, |
| 1787 | is_airplane_mode, |
| 1788 | wfc_mode[0], |
| 1789 | wifi_network_ssid, |
| 1790 | wifi_network_pass) |
| 1791 | |
| 1792 | elif host_slot == 0: |
| 1793 | phone_setup_on_rat( |
| 1794 | log, |
| 1795 | ad_host, |
| 1796 | host_rat[1], |
| 1797 | host_other_sub_id, |
| 1798 | is_airplane_mode, |
| 1799 | wfc_mode[1], |
| 1800 | wifi_network_ssid, |
| 1801 | wifi_network_pass) |
| 1802 | |
| 1803 | argv = ( |
| 1804 | log, |
| 1805 | ad_host, |
| 1806 | host_rat[host_slot], |
| 1807 | host_sub_id, |
| 1808 | is_airplane_mode, |
| 1809 | wfc_mode[host_slot], |
| 1810 | wifi_network_ssid, |
| 1811 | wifi_network_pass) |
| 1812 | |
| 1813 | tasks = [(phone_setup_voice_general, (log, ad_p1)), |
| 1814 | (phone_setup_on_rat, argv), |
| 1815 | (phone_setup_voice_general, (log, ad_p2))] |
| 1816 | |
| 1817 | if not multithread_func(log, tasks): |
| 1818 | log.error("Phone Failed to Set Up Properly.") |
| 1819 | tel_logger.set_result(CallResult("CALL_SETUP_FAILURE")) |
| 1820 | raise signals.TestFailure("Failed", |
| 1821 | extras={"fail_reason": "Phone Failed to Set Up Properly."}) |
| 1822 | |
| 1823 | if is_wifi_connected: |
| 1824 | if not ensure_wifi_connected( |
| 1825 | log, |
| 1826 | ad_host, |
| 1827 | wifi_network_ssid, |
| 1828 | wifi_network_pass, |
| 1829 | apm=is_airplane_mode): |
| 1830 | return False |
| 1831 | time.sleep(5) |
| 1832 | |
| 1833 | if "wfc" not in host_rat[host_slot]: |
| 1834 | if not toggle_wfc_for_subscription( |
| 1835 | log, |
| 1836 | ad_host, |
| 1837 | new_state=True, |
| 1838 | sub_id=host_sub_id): |
| 1839 | return False |
| 1840 | if not set_wfc_mode_for_subscription( |
| 1841 | ad_host, wfc_mode[host_slot], sub_id=host_sub_id): |
| 1842 | return False |
| 1843 | |
| 1844 | log.info("Step 4: Make 3-way voice call.") |
| 1845 | is_host_in_call = is_phone_in_call_on_rat( |
| 1846 | log, ad_host, host_rat[host_slot], only_return_fn=True) |
| 1847 | call_ab_id = _three_phone_call_mo_add_mt( |
| 1848 | log, |
| 1849 | [ad_host, ad_p1, ad_p2], |
| 1850 | [None, None, None], |
| 1851 | [is_host_in_call, None, None], |
| 1852 | reject_once=reject_once) |
| 1853 | |
| 1854 | if call_ab_id is None: |
| 1855 | if disable_cw: |
| 1856 | set_call_waiting(log, ad_host, enable=1) |
| 1857 | if str(getattr(ad_host, "exception", None)) == \ |
| 1858 | "PhoneA call PhoneC failed.": |
| 1859 | ads[0].log.info("PhoneA failed to call PhoneC due to call" |
| 1860 | " waiting being disabled.") |
| 1861 | delattr(ad_host, "exception") |
| 1862 | return True |
| 1863 | log.error("Failed to get call_ab_id") |
| 1864 | return False |
| 1865 | else: |
| 1866 | if disable_cw: |
| 1867 | set_call_waiting(log, ad_host, enable=0) |
| 1868 | return False |
| 1869 | |
| 1870 | calls = ads[0].droid.telecomCallGetCallIds() |
| 1871 | ads[0].log.info("Calls in PhoneA %s", calls) |
| 1872 | if num_active_calls(log, ads[0]) != 2: |
| 1873 | return False |
| 1874 | if calls[0] == call_ab_id: |
| 1875 | call_ac_id = calls[1] |
| 1876 | else: |
| 1877 | call_ac_id = calls[0] |
| 1878 | |
| 1879 | if call_ac_id is None: |
| 1880 | log.error("Failed to get call_ac_id") |
| 1881 | return False |
| 1882 | |
| 1883 | num_swaps = 2 |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 1884 | log.info("Step 5: Begin Swap x%s test.", num_swaps) |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 1885 | if not swap_calls(log, ads, call_ab_id, call_ac_id, |
| 1886 | num_swaps): |
| 1887 | ad_host.log.error("Swap test failed.") |
| 1888 | return False |
| 1889 | |
| 1890 | if not merge: |
| 1891 | result = True |
| 1892 | if not hangup_call(log, ads[1]): |
| 1893 | result = False |
| 1894 | if not hangup_call(log, ads[2]): |
| 1895 | result = False |
| 1896 | return result |
| 1897 | else: |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 1898 | log.info("Step 6: Merge calls.") |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 1899 | |
| 1900 | if re.search('csfb|2g|3g', host_rat[host_slot].lower(), re.I): |
| 1901 | return _test_wcdma_conference_merge_drop( |
| 1902 | log, ads, call_ab_id, call_ac_id) |
| 1903 | else: |
| 1904 | return _test_ims_conference_merge_drop_second_call_from_participant( |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 1905 | log, ads, call_ab_id, call_ac_id) |