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