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