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