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 |
Markus Liu | 6dc6e4e | 2021-11-29 20:22:28 +0800 | [diff] [blame^] | 42 | from acts_contrib.test_utils.tel.tel_subscription_utils import get_slot_index_from_subid |
Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 43 | 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] | 44 | from acts_contrib.test_utils.tel.tel_subscription_utils import get_subid_on_same_network_of_host_ad |
| 45 | 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] | 46 | from acts_contrib.test_utils.tel.tel_subscription_utils import set_message_subid |
| 47 | from acts_contrib.test_utils.tel.tel_subscription_utils import set_subid_for_data |
| 48 | 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] | 49 | 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] | 50 | 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] | 51 | 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] | 52 | 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] | 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, |
Markus Liu | 6dc6e4e | 2021-11-29 20:22:28 +0800 | [diff] [blame^] | 260 | get_slot_index_from_subid(ad_mo, mo_sub_id), |
Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 261 | None, |
| 262 | is_mo_in_call, |
| 263 | ad_mt, |
Markus Liu | 6dc6e4e | 2021-11-29 20:22:28 +0800 | [diff] [blame^] | 264 | get_slot_index_from_subid(ad_mt, mt_sub_id), |
Markus Liu | e314391 | 2021-03-31 10:49:00 +0800 | [diff] [blame] | 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.") |
Markus Liu | 6dc6e4e | 2021-11-29 20:22:28 +0800 | [diff] [blame^] | 665 | mo_slot = get_slot_index_from_subid(ad_mo, mo_sub_id) |
| 666 | mt_slot = get_slot_index_from_subid(ad_mt, mt_sub_id) |
Richard Chang | 2243e0e | 2021-08-03 01:15:05 +0800 | [diff] [blame] | 667 | result = two_phone_call_msim_for_slot( |
| 668 | log, |
| 669 | ad_mo, |
| 670 | mo_slot, |
| 671 | None, |
| 672 | is_mo_in_call, |
| 673 | ad_mt, |
| 674 | mt_slot, |
| 675 | None, |
| 676 | is_mt_in_call) |
| 677 | tel_logger.set_result(result.result_value) |
| 678 | |
| 679 | if not result: |
| 680 | log.error( |
| 681 | "Failed to make MO call from %s slot %s to %s" |
| 682 | " slot %s", ad_mo.serial, mo_slot, ad_mt.serial, |
| 683 | mt_slot) |
| 684 | raise signals.TestFailure("Failed", |
| 685 | extras={"fail_reason": str(result.result_value)}) |
| 686 | else: |
| 687 | log.info("Step 4: Send %s.", call_or_sms_or_mms) |
| 688 | if call_or_sms_or_mms == "sms": |
| 689 | result = msim_message_test( |
| 690 | ad_mo, |
| 691 | ad_mt, |
| 692 | mo_sub_id, |
| 693 | mt_sub_id, |
| 694 | msg=call_or_sms_or_mms.upper()) |
| 695 | elif call_or_sms_or_mms == "mms": |
| 696 | result = msim_message_test( |
| 697 | ad_mo, |
| 698 | ad_mt, |
| 699 | mo_sub_id, |
| 700 | mt_sub_id, |
| 701 | msg=call_or_sms_or_mms.upper(), |
| 702 | expected_result=expected_result) |
| 703 | if not result: |
| 704 | log_messaging_screen_shot( |
| 705 | ad_mo, test_name="%s_tx" % call_or_sms_or_mms) |
| 706 | log_messaging_screen_shot( |
| 707 | ad_mt, test_name="%s_rx" % call_or_sms_or_mms) |
| 708 | return False |
| 709 | if streaming: |
| 710 | ad.force_stop_apk(YOUTUBE_PACKAGE_NAME) |
| 711 | return True |
| 712 | |
| 713 | |
Markus Liu | ccd9534 | 2021-07-05 01:55:05 +0800 | [diff] [blame] | 714 | def enable_slot_after_voice_call_test( |
| 715 | log, |
Markus Liu | 86d0683 | 2021-10-13 17:31:02 +0800 | [diff] [blame] | 716 | tel_logger, |
Markus Liu | ccd9534 | 2021-07-05 01:55:05 +0800 | [diff] [blame] | 717 | ads, |
| 718 | mo_slot, |
| 719 | mt_slot, |
| 720 | disabled_slot, |
| 721 | mo_rat=["", ""], |
| 722 | mt_rat=["", ""], |
| 723 | call_direction="mo"): |
| 724 | """Disable/enable pSIM or eSIM with voice call |
| 725 | |
| 726 | Test step: |
| 727 | 1. Get sub IDs of specific slots of both MO and MT devices. |
| 728 | 2. Set up phones in desired RAT. |
| 729 | 3. Disable assigned slot. |
| 730 | 4. Switch DDS to the other slot. |
| 731 | 5. Verify RAT and HTTP connection after DDS switch. |
| 732 | 6. Make voice call. |
| 733 | 7. Enable assigned slot. |
| 734 | 8. Switch DDS to the assigned slot. |
| 735 | 9. Verify RAT and HTTP connection after DDS switch. |
| 736 | |
| 737 | Args: |
| 738 | log: logger object |
Markus Liu | 86d0683 | 2021-10-13 17:31:02 +0800 | [diff] [blame] | 739 | tel_logger: logger object for telephony proto |
Markus Liu | ccd9534 | 2021-07-05 01:55:05 +0800 | [diff] [blame] | 740 | ads: list of android devices |
| 741 | mo_slot: Slot making MO call (0 or 1) |
| 742 | mt_slot: Slot receiving MT call (0 or 1) |
| 743 | disabled_slot: slot to be disabled/enabled |
| 744 | mo_rat: RAT for both slots of MO device |
| 745 | mt_rat: RAT for both slots of MT device |
| 746 | call_direction: "mo" or "mt" |
| 747 | |
| 748 | Returns: |
| 749 | TestFailure if failed. |
| 750 | """ |
| 751 | if call_direction == "mo": |
| 752 | ad_mo = ads[0] |
| 753 | ad_mt = ads[1] |
| 754 | else: |
| 755 | ad_mo = ads[1] |
| 756 | ad_mt = ads[0] |
| 757 | |
| 758 | if mo_slot is not None: |
| 759 | mo_sub_id = get_subid_from_slot_index(log, ad_mo, mo_slot) |
| 760 | if mo_sub_id == INVALID_SUB_ID: |
| 761 | ad_mo.log.warning("Failed to get sub ID at slot %s.", mo_slot) |
| 762 | raise signals.TestFailure( |
| 763 | "Failed", |
| 764 | extras={ |
| 765 | "fail_reason": "Failed to get sub ID at slot %s." % mo_slot}) |
| 766 | mo_other_sub_id = get_subid_from_slot_index( |
| 767 | log, ad_mo, 1-mo_slot) |
| 768 | set_voice_sub_id(ad_mo, mo_sub_id) |
| 769 | else: |
| 770 | _, mo_sub_id, _ = get_subid_on_same_network_of_host_ad(ads) |
| 771 | if mo_sub_id == INVALID_SUB_ID: |
| 772 | ad_mo.log.warning("Failed to get sub ID at slot %s.", mo_slot) |
| 773 | raise signals.TestFailure( |
| 774 | "Failed", |
| 775 | extras={ |
| 776 | "fail_reason": "Failed to get sub ID at slot %s." % mo_slot}) |
| 777 | mo_slot = "auto" |
| 778 | set_voice_sub_id(ad_mo, mo_sub_id) |
| 779 | ad_mo.log.info("Sub ID for outgoing call at slot %s: %s", |
| 780 | mo_slot, get_outgoing_voice_sub_id(ad_mo)) |
| 781 | |
| 782 | if mt_slot is not None: |
| 783 | mt_sub_id = get_subid_from_slot_index(log, ad_mt, mt_slot) |
| 784 | if mt_sub_id == INVALID_SUB_ID: |
| 785 | ad_mt.log.warning("Failed to get sub ID at slot %s.", mt_slot) |
| 786 | raise signals.TestFailure( |
| 787 | "Failed", |
| 788 | extras={ |
| 789 | "fail_reason": "Failed to get sub ID at slot %s." % mt_slot}) |
| 790 | mt_other_sub_id = get_subid_from_slot_index( |
| 791 | log, ad_mt, 1-mt_slot) |
| 792 | set_voice_sub_id(ad_mt, mt_sub_id) |
| 793 | else: |
| 794 | _, mt_sub_id, _ = get_subid_on_same_network_of_host_ad(ads) |
| 795 | if mt_sub_id == INVALID_SUB_ID: |
| 796 | ad_mt.log.warning("Failed to get sub ID at slot %s.", mt_slot) |
| 797 | raise signals.TestFailure( |
| 798 | "Failed", |
| 799 | extras={ |
| 800 | "fail_reason": "Failed to get sub ID at slot %s." % mt_slot}) |
| 801 | mt_slot = "auto" |
| 802 | set_voice_sub_id(ad_mt, mt_sub_id) |
| 803 | ad_mt.log.info("Sub ID for incoming call at slot %s: %s", mt_slot, |
| 804 | get_incoming_voice_sub_id(ad_mt)) |
| 805 | |
| 806 | if mo_slot == 0 or mo_slot == 1: |
| 807 | phone_setup_on_rat(log, ad_mo, mo_rat[1-mo_slot], mo_other_sub_id) |
| 808 | mo_phone_setup_func_argv = (log, ad_mo, mo_rat[mo_slot], mo_sub_id) |
| 809 | is_mo_in_call = is_phone_in_call_on_rat( |
| 810 | log, ad_mo, mo_rat[mo_slot], only_return_fn=True) |
| 811 | else: |
| 812 | mo_phone_setup_func_argv = (log, ad_mo, 'general') |
| 813 | is_mo_in_call = is_phone_in_call_on_rat( |
| 814 | log, ad_mo, 'general', only_return_fn=True) |
| 815 | |
| 816 | if mt_slot == 0 or mt_slot == 1: |
| 817 | phone_setup_on_rat(log, ad_mt, mt_rat[1-mt_slot], mt_other_sub_id) |
| 818 | mt_phone_setup_func_argv = (log, ad_mt, mt_rat[mt_slot], mt_sub_id) |
| 819 | is_mt_in_call = is_phone_in_call_on_rat( |
| 820 | log, ad_mt, mt_rat[mt_slot], only_return_fn=True) |
| 821 | else: |
| 822 | mt_phone_setup_func_argv = (log, ad_mt, 'general') |
| 823 | is_mt_in_call = is_phone_in_call_on_rat( |
| 824 | log, ad_mt, 'general', only_return_fn=True) |
| 825 | |
| 826 | log.info("Step 1: Set up phones in desired RAT.") |
| 827 | tasks = [(phone_setup_on_rat, mo_phone_setup_func_argv), |
| 828 | (phone_setup_on_rat, mt_phone_setup_func_argv)] |
| 829 | if not multithread_func(log, tasks): |
| 830 | log.error("Phone Failed to Set Up Properly.") |
| 831 | tel_logger.set_result(CallResult("CALL_SETUP_FAILURE")) |
| 832 | raise signals.TestFailure( |
| 833 | "Failed", |
| 834 | extras={"fail_reason": "Phone Failed to Set Up Properly."}) |
| 835 | |
| 836 | log.info("Step 2: Disable slot %s.", disabled_slot) |
| 837 | if not power_off_sim(ads[0], disabled_slot): |
| 838 | raise signals.TestFailure( |
| 839 | "Failed", |
| 840 | extras={ |
| 841 | "fail_reason": "Failed to disable slot %s." % disabled_slot}) |
| 842 | |
| 843 | log.info("Step 3: Switch DDS.") |
| 844 | if not set_dds_on_slot(ads[0], 1-disabled_slot): |
| 845 | log.error( |
| 846 | "Failed to set DDS at slot %s on %s.", |
| 847 | (1-disabled_slot, ads[0].serial)) |
| 848 | raise signals.TestFailure( |
| 849 | "Failed", |
| 850 | extras={"fail_reason": "Failed to set DDS at slot %s on %s." % ( |
| 851 | 1-disabled_slot, ads[0].serial)}) |
| 852 | |
| 853 | log.info("Step 4: Verify RAT and HTTP connection after DDS switch.") |
| 854 | if mo_slot == 0 or mo_slot == 1: |
| 855 | if not wait_for_network_idle( |
| 856 | log, ad_mo, mo_rat[1-disabled_slot], mo_sub_id): |
| 857 | raise signals.TestFailure( |
| 858 | "Failed", |
| 859 | extras={ |
| 860 | "fail_reason": "Idle state does not match the given " |
| 861 | "RAT %s." % mo_rat[1-disabled_slot]}) |
| 862 | |
| 863 | if mt_slot == 0 or mt_slot == 1: |
| 864 | if not wait_for_network_idle( |
| 865 | log, ad_mt, mt_rat[1-disabled_slot], mt_sub_id): |
| 866 | raise signals.TestFailure( |
| 867 | "Failed", |
| 868 | extras={ |
| 869 | "fail_reason": "Idle state does not match the given " |
| 870 | "RAT %s." % mt_rat[1-disabled_slot]}) |
| 871 | |
| 872 | if not verify_http_connection(log, ads[0]): |
| 873 | log.error("Failed to verify http connection.") |
| 874 | raise signals.TestFailure( |
| 875 | "Failed", |
| 876 | extras={"fail_reason": "Failed to verify http connection."}) |
| 877 | else: |
| 878 | log.info("Verify http connection successfully.") |
| 879 | |
| 880 | log.info("Step 5: Make voice call.") |
| 881 | result = two_phone_call_msim_for_slot( |
| 882 | log, |
| 883 | ad_mo, |
Markus Liu | 6dc6e4e | 2021-11-29 20:22:28 +0800 | [diff] [blame^] | 884 | get_slot_index_from_subid(ad_mo, mo_sub_id), |
Markus Liu | ccd9534 | 2021-07-05 01:55:05 +0800 | [diff] [blame] | 885 | None, |
| 886 | is_mo_in_call, |
| 887 | ad_mt, |
Markus Liu | 6dc6e4e | 2021-11-29 20:22:28 +0800 | [diff] [blame^] | 888 | get_slot_index_from_subid(ad_mt, mt_sub_id), |
Markus Liu | ccd9534 | 2021-07-05 01:55:05 +0800 | [diff] [blame] | 889 | None, |
| 890 | is_mt_in_call) |
| 891 | |
| 892 | tel_logger.set_result(result.result_value) |
| 893 | |
| 894 | if not result: |
| 895 | log.error( |
| 896 | "Failed to make MO call from %s slot %s to %s slot %s", |
| 897 | ad_mo.serial, mo_slot, ad_mt.serial, mt_slot) |
| 898 | raise signals.TestFailure("Failed", |
| 899 | extras={"fail_reason": str(result.result_value)}) |
| 900 | |
| 901 | log.info("Step 6: Enable slot %s.", disabled_slot) |
| 902 | if not power_on_sim(ads[0], disabled_slot): |
| 903 | raise signals.TestFailure( |
| 904 | "Failed", |
| 905 | extras={"fail_reason": "Failed to enable slot %s." % disabled_slot}) |
| 906 | |
| 907 | log.info("Step 7: Switch DDS to slot %s.", disabled_slot) |
| 908 | if not set_dds_on_slot(ads[0], disabled_slot): |
| 909 | log.error( |
| 910 | "Failed to set DDS at slot %s on %s.",(disabled_slot, ads[0].serial)) |
| 911 | raise signals.TestFailure( |
| 912 | "Failed", |
| 913 | extras={"fail_reason": "Failed to set DDS at slot %s on %s." % ( |
| 914 | disabled_slot, ads[0].serial)}) |
| 915 | |
| 916 | log.info("Step 8: Verify RAT and HTTP connection after DDS switch.") |
| 917 | if mo_slot == 0 or mo_slot == 1: |
| 918 | if not wait_for_network_idle( |
| 919 | log, ad_mo, mo_rat[disabled_slot], mo_other_sub_id): |
| 920 | raise signals.TestFailure( |
| 921 | "Failed", |
| 922 | extras={ |
| 923 | "fail_reason": "Idle state does not match the given " |
| 924 | "RAT %s." % mo_rat[mo_slot]}) |
| 925 | |
| 926 | if mt_slot == 0 or mt_slot == 1: |
| 927 | if not wait_for_network_idle( |
| 928 | log, ad_mt, mt_rat[disabled_slot], mt_other_sub_id): |
| 929 | raise signals.TestFailure( |
| 930 | "Failed", |
| 931 | extras={"fail_reason": "Idle state does not match the given " |
| 932 | "RAT %s." % mt_rat[mt_slot]}) |
| 933 | |
| 934 | if not verify_http_connection(log, ads[0]): |
| 935 | log.error("Failed to verify http connection.") |
| 936 | raise signals.TestFailure( |
| 937 | "Failed", |
| 938 | extras={"fail_reason": "Failed to verify http connection."}) |
| 939 | else: |
| 940 | log.info("Verify http connection successfully.") |
| 941 | |
Richard Chang | 2243e0e | 2021-08-03 01:15:05 +0800 | [diff] [blame] | 942 | |
Markus Liu | ccd9534 | 2021-07-05 01:55:05 +0800 | [diff] [blame] | 943 | def enable_slot_after_data_call_test( |
| 944 | log, |
| 945 | ad, |
| 946 | disabled_slot, |
| 947 | rat=["", ""]): |
| 948 | """Disable/enable pSIM or eSIM with data call |
| 949 | |
| 950 | Test step: |
| 951 | 1. Get sub IDs of specific slots of both MO and MT devices. |
| 952 | 2. Set up phones in desired RAT. |
| 953 | 3. Disable assigned slot. |
| 954 | 4. Switch DDS to the other slot. |
| 955 | 5. Verify RAT and HTTP connection after DDS switch. |
| 956 | 6. Make a data call by http download. |
| 957 | 7. Enable assigned slot. |
| 958 | 8. Switch DDS to the assigned slot. |
| 959 | 9. Verify RAT and HTTP connection after DDS switch. |
| 960 | |
| 961 | Args: |
| 962 | log: logger object |
| 963 | ads: list of android devices |
| 964 | disabled_slot: slot to be disabled/enabled |
| 965 | mo_rat: RAT for both slots of MO device |
| 966 | mt_rat: RAT for both slots of MT device |
| 967 | |
| 968 | Returns: |
| 969 | TestFailure if failed. |
| 970 | """ |
| 971 | data_sub_id = get_subid_from_slot_index(log, ad, 1-disabled_slot) |
| 972 | if data_sub_id == INVALID_SUB_ID: |
| 973 | ad.log.warning("Failed to get sub ID at slot %s.", 1-disabled_slot) |
| 974 | raise signals.TestFailure( |
| 975 | "Failed", |
| 976 | extras={ |
| 977 | "fail_reason": "Failed to get sub ID at slot %s." % ( |
| 978 | 1-disabled_slot)}) |
| 979 | other_sub_id = get_subid_from_slot_index(log, ad, disabled_slot) |
| 980 | |
| 981 | log.info("Step 1: Set up phones in desired RAT.") |
| 982 | if not phone_setup_on_rat(log, ad, rat[1-disabled_slot], data_sub_id): |
| 983 | raise signals.TestFailure( |
| 984 | "Failed", |
| 985 | extras={"fail_reason": "Phone Failed to Set Up Properly."}) |
| 986 | |
| 987 | if not phone_setup_on_rat(log, ad, rat[disabled_slot], other_sub_id): |
| 988 | raise signals.TestFailure( |
| 989 | "Failed", |
| 990 | extras={"fail_reason": "Phone Failed to Set Up Properly."}) |
| 991 | |
| 992 | log.info("Step 2: Disable slot %s.", disabled_slot) |
| 993 | if not power_off_sim(ad, disabled_slot): |
| 994 | raise signals.TestFailure( |
| 995 | "Failed", |
| 996 | extras={"fail_reason": "Failed to disable slot %s." % disabled_slot}) |
| 997 | |
| 998 | log.info("Step 3: Switch DDS.") |
| 999 | if not set_dds_on_slot(ad, 1-disabled_slot): |
| 1000 | log.error( |
| 1001 | "Failed to set DDS at slot %s on %s.",(1-disabled_slot, ad.serial)) |
| 1002 | raise signals.TestFailure( |
| 1003 | "Failed", |
| 1004 | extras={"fail_reason": "Failed to set DDS at slot %s on %s." % ( |
| 1005 | 1-disabled_slot, ad.serial)}) |
| 1006 | |
| 1007 | log.info("Step 4: Verify RAT and HTTP connection after DDS switch.") |
| 1008 | if not wait_for_network_idle(log, ad, rat[1-disabled_slot], data_sub_id): |
| 1009 | raise signals.TestFailure( |
| 1010 | "Failed", |
| 1011 | extras={ |
| 1012 | "fail_reason": "Idle state does not match the given " |
| 1013 | "RAT %s." % rat[1-disabled_slot]}) |
| 1014 | |
| 1015 | if not verify_http_connection(log, ad): |
| 1016 | log.error("Failed to verify http connection.") |
| 1017 | raise signals.TestFailure("Failed", |
| 1018 | extras={"fail_reason": "Failed to verify http connection."}) |
| 1019 | else: |
| 1020 | log.info("Verify http connection successfully.") |
| 1021 | |
| 1022 | duration = 30 |
| 1023 | start_time = datetime.now() |
| 1024 | while datetime.now() - start_time <= timedelta(seconds=duration): |
| 1025 | if not active_file_download_test( |
| 1026 | log, ad, file_name='20MB', method='sl4a'): |
| 1027 | raise signals.TestFailure( |
| 1028 | "Failed", |
| 1029 | extras={"fail_reason": "Failed to download by sl4a."}) |
| 1030 | |
| 1031 | log.info("Step 6: Enable slot %s.", disabled_slot) |
| 1032 | if not power_on_sim(ad, disabled_slot): |
| 1033 | raise signals.TestFailure( |
| 1034 | "Failed", |
| 1035 | extras={"fail_reason": "Failed to enable slot %s." % disabled_slot}) |
| 1036 | |
| 1037 | log.info("Step 7: Switch DDS to slot %s.", disabled_slot) |
| 1038 | if not set_dds_on_slot(ad, disabled_slot): |
| 1039 | log.error( |
| 1040 | "Failed to set DDS at slot %s on %s.",(disabled_slot, ad.serial)) |
| 1041 | raise signals.TestFailure( |
| 1042 | "Failed", |
| 1043 | extras={"fail_reason": "Failed to set DDS at slot %s on %s." % ( |
| 1044 | disabled_slot, ad.serial)}) |
| 1045 | |
| 1046 | log.info("Step 8: Verify RAT and HTTP connection after DDS switch.") |
| 1047 | if not wait_for_network_idle(log, ad, rat[disabled_slot], other_sub_id): |
| 1048 | raise signals.TestFailure( |
| 1049 | "Failed", |
| 1050 | extras={ |
| 1051 | "fail_reason": "Idle state does not match the given " |
| 1052 | "RAT %s." % rat[disabled_slot]}) |
| 1053 | |
| 1054 | if not verify_http_connection(log, ad): |
| 1055 | log.error("Failed to verify http connection.") |
| 1056 | raise signals.TestFailure( |
| 1057 | "Failed", |
| 1058 | extras={"fail_reason": "Failed to verify http connection."}) |
| 1059 | else: |
| 1060 | log.info("Verify http connection successfully.") |
| 1061 | |
Richard Chang | 2243e0e | 2021-08-03 01:15:05 +0800 | [diff] [blame] | 1062 | |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 1063 | def erase_call_forwarding(log, ad): |
| 1064 | slot0_sub_id = get_subid_from_slot_index(log, ad, 0) |
| 1065 | slot1_sub_id = get_subid_from_slot_index(log, ad, 1) |
| 1066 | current_voice_sub_id = get_incoming_voice_sub_id(ad) |
| 1067 | for sub_id in (slot0_sub_id, slot1_sub_id): |
| 1068 | set_voice_sub_id(ad, sub_id) |
| 1069 | get_operator_name(log, ad, sub_id) |
| 1070 | erase_call_forwarding_by_mmi(log, ad) |
| 1071 | set_voice_sub_id(ad, current_voice_sub_id) |
| 1072 | |
Richard Chang | 2243e0e | 2021-08-03 01:15:05 +0800 | [diff] [blame] | 1073 | |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 1074 | def three_way_calling_mo_and_mt_with_hangup_once( |
| 1075 | log, |
| 1076 | ads, |
| 1077 | phone_setups, |
| 1078 | verify_funcs, |
| 1079 | reject_once=False): |
| 1080 | """Use 3 phones to make MO call and MT call. |
| 1081 | |
| 1082 | Call from PhoneA to PhoneB, accept on PhoneB. |
| 1083 | Call from PhoneC to PhoneA, accept on PhoneA. |
| 1084 | |
| 1085 | Args: |
| 1086 | ads: list of ad object. |
| 1087 | The list should have three objects. |
| 1088 | phone_setups: list of phone setup functions. |
| 1089 | The list should have three objects. |
| 1090 | verify_funcs: list of phone call verify functions. |
| 1091 | The list should have three objects. |
| 1092 | |
| 1093 | Returns: |
| 1094 | If success, return 'call_AB' id in PhoneA. |
| 1095 | if fail, return None. |
| 1096 | """ |
| 1097 | |
| 1098 | class _CallException(Exception): |
| 1099 | pass |
| 1100 | |
| 1101 | try: |
| 1102 | verify_func_a, verify_func_b, verify_func_c = verify_funcs |
| 1103 | tasks = [] |
| 1104 | for ad, setup_func in zip(ads, phone_setups): |
| 1105 | if setup_func is not None: |
| 1106 | tasks.append((setup_func, (log, ad, get_incoming_voice_sub_id(ad)))) |
| 1107 | if tasks != [] and not multithread_func(log, tasks): |
| 1108 | log.error("Phone Failed to Set Up Properly.") |
| 1109 | raise _CallException("Setup failed.") |
| 1110 | for ad in ads: |
| 1111 | ad.droid.telecomCallClearCallList() |
| 1112 | if num_active_calls(log, ad) != 0: |
| 1113 | ad.log.error("Phone Call List is not empty.") |
| 1114 | raise _CallException("Clear call list failed.") |
| 1115 | |
| 1116 | log.info("Step1: Call From PhoneA to PhoneB.") |
| 1117 | if not call_setup_teardown( |
| 1118 | log, |
| 1119 | ads[0], |
| 1120 | ads[1], |
| 1121 | ad_hangup=None, |
| 1122 | verify_caller_func=verify_func_a, |
| 1123 | verify_callee_func=verify_func_b): |
| 1124 | raise _CallException("PhoneA call PhoneB failed.") |
| 1125 | |
| 1126 | calls = ads[0].droid.telecomCallGetCallIds() |
| 1127 | ads[0].log.info("Calls in PhoneA %s", calls) |
| 1128 | if num_active_calls(log, ads[0]) != 1: |
| 1129 | raise _CallException("Call list verify failed.") |
| 1130 | call_ab_id = calls[0] |
| 1131 | |
| 1132 | log.info("Step2: Call From PhoneC to PhoneA.") |
| 1133 | if reject_once: |
| 1134 | log.info("Step2-1: Reject incoming call once.") |
| 1135 | if not initiate_call( |
| 1136 | log, |
| 1137 | ads[2], |
| 1138 | ads[0].telephony['subscription'][get_incoming_voice_sub_id( |
| 1139 | ads[0])]['phone_num']): |
| 1140 | ads[2].log.error("Initiate call failed.") |
| 1141 | raise _CallException("Failed to initiate call.") |
| 1142 | |
| 1143 | if not wait_and_reject_call_for_subscription( |
| 1144 | log, |
| 1145 | ads[0], |
| 1146 | get_incoming_voice_sub_id(ads[0]), |
| 1147 | incoming_number= \ |
| 1148 | ads[2].telephony['subscription'][ |
| 1149 | get_incoming_voice_sub_id( |
| 1150 | ads[2])]['phone_num']): |
| 1151 | ads[0].log.error("Reject call fail.") |
| 1152 | raise _CallException("Failed to reject call.") |
| 1153 | |
| 1154 | hangup_call(log, ads[2]) |
| 1155 | time.sleep(15) |
| 1156 | |
| 1157 | if not call_setup_teardown( |
| 1158 | log, |
| 1159 | ads[2], |
| 1160 | ads[0], |
| 1161 | ad_hangup=None, |
| 1162 | verify_caller_func=verify_func_c, |
| 1163 | verify_callee_func=verify_func_a): |
| 1164 | raise _CallException("PhoneA call PhoneC failed.") |
| 1165 | if not verify_incall_state(log, [ads[0], ads[1], ads[2]], |
| 1166 | True): |
| 1167 | raise _CallException("Not All phones are in-call.") |
| 1168 | |
| 1169 | except Exception as e: |
| 1170 | setattr(ads[0], "exception", e) |
| 1171 | return None |
| 1172 | |
| 1173 | return call_ab_id |
| 1174 | |
Richard Chang | 2243e0e | 2021-08-03 01:15:05 +0800 | [diff] [blame] | 1175 | |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 1176 | def msim_message_test( |
| 1177 | log, |
| 1178 | ad_mo, |
| 1179 | ad_mt, |
| 1180 | mo_sub_id, |
| 1181 | mt_sub_id, msg="SMS", |
| 1182 | max_wait_time=MAX_WAIT_TIME_SMS_RECEIVE, |
| 1183 | expected_result=True): |
| 1184 | """Make MO/MT SMS/MMS at specific slot. |
| 1185 | |
| 1186 | Args: |
| 1187 | ad_mo: Android object of the device sending SMS/MMS |
| 1188 | ad_mt: Android object of the device receiving SMS/MMS |
| 1189 | mo_sub_id: Sub ID of MO device |
| 1190 | mt_sub_id: Sub ID of MT device |
| 1191 | max_wait_time: Max wait time before SMS/MMS is received. |
| 1192 | expected_result: True for successful sending/receiving and False on |
| 1193 | the contrary |
| 1194 | |
| 1195 | Returns: |
| 1196 | True if the result matches expected_result and False on the |
| 1197 | contrary. |
| 1198 | """ |
| 1199 | message_lengths = (50, 160, 180) |
| 1200 | if msg == "SMS": |
| 1201 | for length in message_lengths: |
| 1202 | message_array = [rand_ascii_str(length)] |
| 1203 | if not sms_send_receive_verify_for_subscription( |
| 1204 | log, |
| 1205 | ad_mo, |
| 1206 | ad_mt, |
| 1207 | mo_sub_id, |
| 1208 | mt_sub_id, |
| 1209 | message_array, |
| 1210 | max_wait_time): |
| 1211 | ad_mo.log.warning( |
| 1212 | "%s of length %s test failed", msg, length) |
| 1213 | return False |
| 1214 | else: |
| 1215 | ad_mo.log.info( |
| 1216 | "%s of length %s test succeeded", msg, length) |
| 1217 | log.info("%s test of length %s characters succeeded.", |
| 1218 | msg, message_lengths) |
| 1219 | |
| 1220 | elif msg == "MMS": |
| 1221 | for length in message_lengths: |
| 1222 | message_array = [("Test Message", rand_ascii_str(length), None)] |
| 1223 | |
| 1224 | if not mms_send_receive_verify( |
| 1225 | log, |
| 1226 | ad_mo, |
| 1227 | ad_mt, |
| 1228 | message_array, |
| 1229 | max_wait_time, |
| 1230 | expected_result): |
| 1231 | log.warning("%s of body length %s test failed", |
| 1232 | msg, length) |
| 1233 | return False |
| 1234 | else: |
| 1235 | log.info( |
| 1236 | "%s of body length %s test succeeded", msg, length) |
| 1237 | log.info("%s test of body lengths %s succeeded", |
| 1238 | msg, message_lengths) |
| 1239 | return True |
| 1240 | |
Richard Chang | 2243e0e | 2021-08-03 01:15:05 +0800 | [diff] [blame] | 1241 | |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 1242 | def msim_call_forwarding( |
| 1243 | log, |
Markus Liu | 86d0683 | 2021-10-13 17:31:02 +0800 | [diff] [blame] | 1244 | tel_logger, |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 1245 | ads, |
| 1246 | caller_slot, |
| 1247 | callee_slot, |
| 1248 | forwarded_callee_slot, |
| 1249 | dds_slot, |
| 1250 | caller_rat=["", ""], |
| 1251 | callee_rat=["", ""], |
| 1252 | forwarded_callee_rat=["", ""], |
| 1253 | call_forwarding_type="unconditional"): |
| 1254 | """Make MO voice call to the primary device at specific slot in specific |
| 1255 | RAT with DDS at specific slot, and then forwarded to 3rd device with |
| 1256 | specific call forwarding type. |
| 1257 | |
| 1258 | Test step: |
| 1259 | 1. Get sub IDs of specific slots of both MO and MT devices. |
| 1260 | 2. Switch DDS to specific slot. |
| 1261 | 3. Check HTTP connection after DDS switch. |
| 1262 | 4. Set up phones in desired RAT. |
| 1263 | 5. Register and enable call forwarding with specifc type. |
| 1264 | 5. Make voice call to the primary device and wait for being forwarded |
| 1265 | to 3rd device. |
| 1266 | |
| 1267 | Args: |
Markus Liu | 86d0683 | 2021-10-13 17:31:02 +0800 | [diff] [blame] | 1268 | log: logger object |
| 1269 | tel_logger: logger object for telephony proto |
| 1270 | ads: list of android devices |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 1271 | caller_slot: Slot of 2nd device making MO call (0 or 1) |
| 1272 | callee_slot: Slot of primary device receiving and forwarding MT call |
| 1273 | (0 or 1) |
| 1274 | forwarded_callee_slot: Slot of 3rd device receiving forwarded call. |
| 1275 | dds_slot: Preferred data slot |
| 1276 | caller_rat: RAT for both slots of the 2nd device |
| 1277 | callee_rat: RAT for both slots of the primary device |
| 1278 | forwarded_callee_rat: RAT for both slots of the 3rd device |
| 1279 | call_forwarding_type: |
| 1280 | "unconditional" |
| 1281 | "busy" |
| 1282 | "not_answered" |
| 1283 | "not_reachable" |
| 1284 | |
| 1285 | Returns: |
| 1286 | True or False |
| 1287 | """ |
| 1288 | ad_caller = ads[1] |
| 1289 | ad_callee = ads[0] |
| 1290 | ad_forwarded_callee = ads[2] |
| 1291 | |
| 1292 | if callee_slot is not None: |
| 1293 | callee_sub_id = get_subid_from_slot_index( |
| 1294 | log, ad_callee, callee_slot) |
| 1295 | if callee_sub_id == INVALID_SUB_ID: |
| 1296 | ad_callee.log.warning( |
| 1297 | "Failed to get sub ID at slot %s.", callee_slot) |
| 1298 | return False |
| 1299 | callee_other_sub_id = get_subid_from_slot_index( |
| 1300 | log, ad_callee, 1-callee_slot) |
| 1301 | set_voice_sub_id(ad_callee, callee_sub_id) |
| 1302 | else: |
| 1303 | callee_sub_id, _, _ = get_subid_on_same_network_of_host_ad(ads) |
| 1304 | if callee_sub_id == INVALID_SUB_ID: |
| 1305 | ad_callee.log.warning( |
| 1306 | "Failed to get sub ID at slot %s.", callee_slot) |
| 1307 | return False |
| 1308 | callee_slot = "auto" |
| 1309 | set_voice_sub_id(ad_callee, callee_sub_id) |
| 1310 | ad_callee.log.info( |
| 1311 | "Sub ID for incoming call at slot %s: %s", |
| 1312 | callee_slot, get_incoming_voice_sub_id(ad_callee)) |
| 1313 | |
| 1314 | if caller_slot is not None: |
| 1315 | caller_sub_id = get_subid_from_slot_index( |
| 1316 | log, ad_caller, caller_slot) |
| 1317 | if caller_sub_id == INVALID_SUB_ID: |
| 1318 | ad_caller.log.warning( |
| 1319 | "Failed to get sub ID at slot %s.", caller_slot) |
| 1320 | return False |
| 1321 | caller_other_sub_id = get_subid_from_slot_index( |
| 1322 | log, ad_caller, 1-caller_slot) |
| 1323 | set_voice_sub_id(ad_caller, caller_sub_id) |
| 1324 | else: |
| 1325 | _, caller_sub_id, _ = get_subid_on_same_network_of_host_ad(ads) |
| 1326 | if caller_sub_id == INVALID_SUB_ID: |
| 1327 | ad_caller.log.warning( |
| 1328 | "Failed to get sub ID at slot %s.", caller_slot) |
| 1329 | return False |
| 1330 | caller_slot = "auto" |
| 1331 | set_voice_sub_id(ad_caller, caller_sub_id) |
| 1332 | ad_caller.log.info( |
| 1333 | "Sub ID for outgoing call at slot %s: %s", |
| 1334 | caller_slot, get_outgoing_voice_sub_id(ad_caller)) |
| 1335 | |
| 1336 | if forwarded_callee_slot is not None: |
| 1337 | forwarded_callee_sub_id = get_subid_from_slot_index( |
| 1338 | log, ad_forwarded_callee, forwarded_callee_slot) |
| 1339 | if forwarded_callee_sub_id == INVALID_SUB_ID: |
| 1340 | ad_forwarded_callee.log.warning( |
| 1341 | "Failed to get sub ID at slot %s.", forwarded_callee_slot) |
| 1342 | return False |
| 1343 | forwarded_callee_other_sub_id = get_subid_from_slot_index( |
| 1344 | log, ad_forwarded_callee, 1-forwarded_callee_slot) |
| 1345 | set_voice_sub_id( |
| 1346 | ad_forwarded_callee, forwarded_callee_sub_id) |
| 1347 | else: |
| 1348 | _, _, forwarded_callee_sub_id = \ |
| 1349 | get_subid_on_same_network_of_host_ad(ads) |
| 1350 | if forwarded_callee_sub_id == INVALID_SUB_ID: |
| 1351 | ad_forwarded_callee.log.warning( |
| 1352 | "Failed to get sub ID at slot %s.", forwarded_callee_slot) |
| 1353 | return False |
| 1354 | forwarded_callee_slot = "auto" |
| 1355 | set_voice_sub_id( |
| 1356 | ad_forwarded_callee, forwarded_callee_sub_id) |
| 1357 | ad_forwarded_callee.log.info( |
| 1358 | "Sub ID for incoming call at slot %s: %s", |
| 1359 | forwarded_callee_slot, |
| 1360 | get_incoming_voice_sub_id(ad_forwarded_callee)) |
| 1361 | |
| 1362 | log.info("Step 1: Switch DDS.") |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 1363 | if not set_dds_on_slot(ads[0], dds_slot): |
| 1364 | log.error( |
| 1365 | "Failed to set DDS at slot %s on %s",(dds_slot, ads[0].serial)) |
| 1366 | return False |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 1367 | |
| 1368 | log.info("Step 2: Check HTTP connection after DDS switch.") |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 1369 | if not verify_http_connection(log, ads[0]): |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 1370 | log.error("Failed to verify http connection.") |
| 1371 | return False |
| 1372 | else: |
| 1373 | log.info("Verify http connection successfully.") |
| 1374 | |
| 1375 | if caller_slot == 1: |
| 1376 | phone_setup_on_rat( |
| 1377 | log, |
| 1378 | ad_caller, |
| 1379 | caller_rat[0], |
| 1380 | caller_other_sub_id) |
| 1381 | |
| 1382 | elif caller_slot == 0: |
| 1383 | phone_setup_on_rat( |
| 1384 | log, |
| 1385 | ad_caller, |
| 1386 | caller_rat[1], |
| 1387 | caller_other_sub_id) |
| 1388 | else: |
| 1389 | phone_setup_on_rat( |
| 1390 | log, |
| 1391 | ad_caller, |
| 1392 | 'general') |
| 1393 | |
| 1394 | if callee_slot == 1: |
| 1395 | phone_setup_on_rat( |
| 1396 | log, |
| 1397 | ad_callee, |
| 1398 | callee_rat[0], |
| 1399 | callee_other_sub_id) |
| 1400 | |
| 1401 | elif callee_slot == 0: |
| 1402 | phone_setup_on_rat( |
| 1403 | log, |
| 1404 | ad_callee, |
| 1405 | callee_rat[1], |
| 1406 | callee_other_sub_id) |
| 1407 | else: |
| 1408 | phone_setup_on_rat( |
| 1409 | log, |
| 1410 | ad_callee, |
| 1411 | 'general') |
| 1412 | |
| 1413 | if forwarded_callee_slot == 1: |
| 1414 | phone_setup_on_rat( |
| 1415 | log, |
| 1416 | ad_forwarded_callee, |
| 1417 | forwarded_callee_rat[0], |
| 1418 | forwarded_callee_other_sub_id) |
| 1419 | |
| 1420 | elif forwarded_callee_slot == 0: |
| 1421 | phone_setup_on_rat( |
| 1422 | log, |
| 1423 | ad_forwarded_callee, |
| 1424 | forwarded_callee_rat[1], |
| 1425 | forwarded_callee_other_sub_id) |
| 1426 | else: |
| 1427 | phone_setup_on_rat( |
| 1428 | log, |
| 1429 | ad_forwarded_callee, |
| 1430 | 'general') |
| 1431 | |
| 1432 | if caller_slot == 0 or caller_slot == 1: |
| 1433 | caller_phone_setup_func_argv = (log, ad_caller, caller_rat[caller_slot], caller_sub_id) |
| 1434 | else: |
| 1435 | caller_phone_setup_func_argv = (log, ad_caller, 'general') |
| 1436 | |
| 1437 | callee_phone_setup_func_argv = (log, ad_callee, callee_rat[callee_slot], callee_sub_id) |
| 1438 | |
| 1439 | if forwarded_callee_slot == 0 or forwarded_callee_slot == 1: |
| 1440 | forwarded_callee_phone_setup_func_argv = ( |
| 1441 | log, |
| 1442 | ad_forwarded_callee, |
| 1443 | forwarded_callee_rat[forwarded_callee_slot], |
| 1444 | forwarded_callee_sub_id) |
| 1445 | else: |
| 1446 | forwarded_callee_phone_setup_func_argv = ( |
| 1447 | log, |
| 1448 | ad_forwarded_callee, |
| 1449 | 'general') |
| 1450 | |
| 1451 | log.info("Step 3: Set up phones in desired RAT.") |
| 1452 | tasks = [(phone_setup_on_rat, caller_phone_setup_func_argv), |
| 1453 | (phone_setup_on_rat, callee_phone_setup_func_argv), |
| 1454 | (phone_setup_on_rat, |
| 1455 | forwarded_callee_phone_setup_func_argv)] |
| 1456 | if not multithread_func(log, tasks): |
| 1457 | log.error("Phone Failed to Set Up Properly.") |
| 1458 | tel_logger.set_result(CallResult("CALL_SETUP_FAILURE")) |
| 1459 | raise signals.TestFailure("Failed", |
| 1460 | extras={"fail_reason": "Phone Failed to Set Up Properly."}) |
| 1461 | |
| 1462 | is_callee_in_call = is_phone_in_call_on_rat( |
| 1463 | log, ad_callee, callee_rat[callee_slot], only_return_fn=True) |
| 1464 | |
| 1465 | is_call_waiting = re.search( |
| 1466 | "call_waiting (True (\d)|False)", call_forwarding_type, re.I) |
| 1467 | if is_call_waiting: |
| 1468 | if is_call_waiting.group(1) == "False": |
| 1469 | call_waiting = False |
| 1470 | scenario = None |
| 1471 | else: |
| 1472 | call_waiting = True |
| 1473 | scenario = int(is_call_waiting.group(2)) |
| 1474 | |
| 1475 | log.info( |
| 1476 | "Step 4: Make voice call with call waiting enabled = %s.", |
| 1477 | call_waiting) |
| 1478 | result = three_phone_call_waiting_short_seq( |
| 1479 | log, |
| 1480 | ads[0], |
| 1481 | None, |
| 1482 | is_callee_in_call, |
| 1483 | ads[1], |
| 1484 | ads[2], |
| 1485 | call_waiting=call_waiting, scenario=scenario) |
| 1486 | else: |
| 1487 | log.info( |
| 1488 | "Step 4: Make voice call with call forwarding %s.", |
| 1489 | call_forwarding_type) |
| 1490 | result = three_phone_call_forwarding_short_seq( |
| 1491 | log, |
| 1492 | ads[0], |
| 1493 | None, |
| 1494 | is_callee_in_call, |
| 1495 | ads[1], |
| 1496 | ads[2], |
| 1497 | call_forwarding_type=call_forwarding_type) |
| 1498 | |
| 1499 | if not result: |
| 1500 | if is_call_waiting: |
| 1501 | pass |
| 1502 | else: |
| 1503 | log.error( |
| 1504 | "Failed to make MO call from %s slot %s to %s slot %s" |
| 1505 | " and forward to %s slot %s", |
| 1506 | ad_caller.serial, |
| 1507 | caller_slot, |
| 1508 | ad_callee.serial, |
| 1509 | callee_slot, |
| 1510 | ad_forwarded_callee.serial, |
| 1511 | forwarded_callee_slot) |
| 1512 | |
| 1513 | return result |
| 1514 | |
Richard Chang | 2243e0e | 2021-08-03 01:15:05 +0800 | [diff] [blame] | 1515 | |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 1516 | def msim_call_voice_conf( |
| 1517 | log, |
Markus Liu | 86d0683 | 2021-10-13 17:31:02 +0800 | [diff] [blame] | 1518 | tel_logger, |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 1519 | ads, |
| 1520 | host_slot, |
| 1521 | p1_slot, |
| 1522 | p2_slot, |
| 1523 | dds_slot, |
| 1524 | host_rat=["volte", "volte"], |
| 1525 | p1_rat="", |
| 1526 | p2_rat="", |
| 1527 | merge=True, |
| 1528 | disable_cw=False): |
| 1529 | """Make a voice conference call at specific slot in specific RAT with |
| 1530 | DDS at specific slot. |
| 1531 | |
| 1532 | Test step: |
| 1533 | 1. Get sub IDs of specific slots of both MO and MT devices. |
| 1534 | 2. Switch DDS to specific slot. |
| 1535 | 3. Check HTTP connection after DDS switch. |
| 1536 | 4. Set up phones in desired RAT and make 3-way voice call. |
| 1537 | 5. Swap calls. |
| 1538 | 6. Merge calls. |
| 1539 | |
| 1540 | Args: |
Markus Liu | 86d0683 | 2021-10-13 17:31:02 +0800 | [diff] [blame] | 1541 | log: logger object |
| 1542 | tel_logger: logger object for telephony proto |
| 1543 | ads: list of android devices |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 1544 | host_slot: Slot on the primary device to host the comference call. |
| 1545 | 0 or 1 (0 for pSIM or 1 for eSIM) |
| 1546 | p1_slot: Slot on the participant device for the call |
| 1547 | p2_slot: Slot on another participant device for the call |
| 1548 | dds_slot: Preferred data slot |
| 1549 | host_rat: RAT for both slots of the primary device |
| 1550 | p1_rat: RAT for both slots of the participant device |
| 1551 | p2_rat: RAT for both slots of another participant device |
| 1552 | merge: True for merging 2 calls into the conference call. False for |
| 1553 | not merging 2 separated call. |
| 1554 | disable_cw: True for disabling call waiting and False on the |
| 1555 | contrary. |
| 1556 | |
| 1557 | Returns: |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 1558 | True or False |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 1559 | """ |
| 1560 | ad_host = ads[0] |
| 1561 | ad_p1 = ads[1] |
| 1562 | ad_p2 = ads[2] |
| 1563 | |
| 1564 | if host_slot is not None: |
| 1565 | host_sub_id = get_subid_from_slot_index( |
| 1566 | log, ad_host, host_slot) |
| 1567 | if host_sub_id == INVALID_SUB_ID: |
| 1568 | ad_host.log.warning("Failed to get sub ID at slot.", host_slot) |
| 1569 | return False |
| 1570 | host_other_sub_id = get_subid_from_slot_index( |
| 1571 | log, ad_host, 1-host_slot) |
| 1572 | set_voice_sub_id(ad_host, host_sub_id) |
| 1573 | else: |
| 1574 | host_sub_id, _, _ = get_subid_on_same_network_of_host_ad(ads) |
| 1575 | if host_sub_id == INVALID_SUB_ID: |
| 1576 | ad_host.log.warning("Failed to get sub ID at slot.", host_slot) |
| 1577 | return False |
| 1578 | host_slot = "auto" |
| 1579 | set_voice_sub_id(ad_host, host_sub_id) |
| 1580 | |
| 1581 | ad_host.log.info("Sub ID for outgoing call at slot %s: %s", |
| 1582 | host_slot, get_outgoing_voice_sub_id(ad_host)) |
| 1583 | |
| 1584 | if p1_slot is not None: |
| 1585 | p1_sub_id = get_subid_from_slot_index(log, ad_p1, p1_slot) |
| 1586 | if p1_sub_id == INVALID_SUB_ID: |
| 1587 | ad_p1.log.warning("Failed to get sub ID at slot %s.", p1_slot) |
| 1588 | return False |
| 1589 | set_voice_sub_id(ad_p1, p1_sub_id) |
| 1590 | else: |
| 1591 | _, p1_sub_id, _ = get_subid_on_same_network_of_host_ad(ads) |
| 1592 | if p1_sub_id == INVALID_SUB_ID: |
| 1593 | ad_p1.log.warning("Failed to get sub ID at slot %s.", p1_slot) |
| 1594 | return False |
| 1595 | p1_slot = "auto" |
| 1596 | set_voice_sub_id(ad_p1, p1_sub_id) |
| 1597 | ad_p1.log.info("Sub ID for incoming call at slot %s: %s", |
| 1598 | p1_slot, get_incoming_voice_sub_id(ad_p1)) |
| 1599 | |
| 1600 | if p2_slot is not None: |
| 1601 | p2_sub_id = get_subid_from_slot_index(log, ad_p2, p2_slot) |
| 1602 | if p2_sub_id == INVALID_SUB_ID: |
| 1603 | ad_p2.log.warning("Failed to get sub ID at slot %s.", p2_slot) |
| 1604 | return False |
| 1605 | set_voice_sub_id(ad_p2, p2_sub_id) |
| 1606 | else: |
| 1607 | _, _, p2_sub_id = get_subid_on_same_network_of_host_ad(ads) |
| 1608 | if p2_sub_id == INVALID_SUB_ID: |
| 1609 | ad_p2.log.warning("Failed to get sub ID at slot %s.", p2_slot) |
| 1610 | return False |
| 1611 | p2_slot = "auto" |
| 1612 | set_voice_sub_id(ad_p2, p2_sub_id) |
| 1613 | ad_p2.log.info("Sub ID for incoming call at slot %s: %s", |
| 1614 | p2_slot, get_incoming_voice_sub_id(ad_p2)) |
| 1615 | |
| 1616 | log.info("Step 1: Switch DDS.") |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 1617 | if not set_dds_on_slot(ads[0], dds_slot): |
| 1618 | log.error( |
| 1619 | "Failed to set DDS at slot %s on %s",(dds_slot, ads[0].serial)) |
| 1620 | return False |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 1621 | |
| 1622 | log.info("Step 2: Check HTTP connection after DDS switch.") |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 1623 | if not verify_http_connection(log, ads[0]): |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 1624 | log.error("Failed to verify http connection.") |
| 1625 | return False |
| 1626 | else: |
| 1627 | log.info("Verify http connection successfully.") |
| 1628 | |
| 1629 | if disable_cw: |
| 1630 | if not set_call_waiting(log, ad_host, enable=0): |
| 1631 | return False |
| 1632 | else: |
| 1633 | if not set_call_waiting(log, ad_host, enable=1): |
| 1634 | return False |
| 1635 | |
| 1636 | if host_slot == 1: |
| 1637 | phone_setup_on_rat( |
| 1638 | log, |
| 1639 | ad_host, |
| 1640 | host_rat[0], |
| 1641 | host_other_sub_id) |
| 1642 | |
| 1643 | elif host_slot == 0: |
| 1644 | phone_setup_on_rat( |
| 1645 | log, |
| 1646 | ad_host, |
| 1647 | host_rat[1], |
| 1648 | host_other_sub_id) |
| 1649 | |
| 1650 | if host_slot == 0 or host_slot == 1: |
| 1651 | host_phone_setup_func_argv = (log, ad_host, host_rat[host_slot], host_sub_id) |
| 1652 | is_host_in_call = is_phone_in_call_on_rat( |
| 1653 | log, ad_host, host_rat[host_slot], only_return_fn=True) |
| 1654 | else: |
| 1655 | host_phone_setup_func_argv = (log, ad_host, 'general') |
| 1656 | is_host_in_call = is_phone_in_call_on_rat( |
| 1657 | log, ad_host, 'general', only_return_fn=True) |
| 1658 | |
| 1659 | if p1_rat: |
| 1660 | p1_phone_setup_func_argv = (log, ad_p1, p1_rat, p1_sub_id) |
| 1661 | is_p1_in_call = is_phone_in_call_on_rat( |
| 1662 | log, ad_p1, p1_rat, only_return_fn=True) |
| 1663 | else: |
| 1664 | p1_phone_setup_func_argv = (log, ad_p1, 'general') |
| 1665 | is_p1_in_call = is_phone_in_call_on_rat( |
| 1666 | log, ad_p1, 'general', only_return_fn=True) |
| 1667 | |
| 1668 | if p2_rat: |
| 1669 | p2_phone_setup_func_argv = (log, ad_p2, p2_rat, p2_sub_id) |
| 1670 | is_p2_in_call = is_phone_in_call_on_rat( |
| 1671 | log, ad_p2, p2_rat, only_return_fn=True) |
| 1672 | else: |
| 1673 | p2_phone_setup_func_argv = (log, ad_p2, 'general') |
| 1674 | is_p2_in_call = is_phone_in_call_on_rat( |
| 1675 | log, ad_p2, 'general', only_return_fn=True) |
| 1676 | |
| 1677 | log.info("Step 3: Set up phone in desired RAT and make 3-way" |
| 1678 | " voice call.") |
| 1679 | |
| 1680 | tasks = [(phone_setup_on_rat, host_phone_setup_func_argv), |
| 1681 | (phone_setup_on_rat, p1_phone_setup_func_argv), |
| 1682 | (phone_setup_on_rat, p2_phone_setup_func_argv)] |
| 1683 | if not multithread_func(log, tasks): |
| 1684 | log.error("Phone Failed to Set Up Properly.") |
| 1685 | tel_logger.set_result(CallResult("CALL_SETUP_FAILURE")) |
| 1686 | raise signals.TestFailure("Failed", |
| 1687 | extras={"fail_reason": "Phone Failed to Set Up Properly."}) |
| 1688 | |
| 1689 | call_ab_id = three_way_calling_mo_and_mt_with_hangup_once( |
| 1690 | log, |
| 1691 | [ad_host, ad_p1, ad_p2], |
| 1692 | [None, None, None], [ |
| 1693 | is_host_in_call, is_p1_in_call, |
| 1694 | is_p2_in_call |
| 1695 | ]) |
| 1696 | |
| 1697 | if call_ab_id is None: |
| 1698 | if disable_cw: |
| 1699 | set_call_waiting(log, ad_host, enable=1) |
| 1700 | if str(getattr(ad_host, "exception", None)) == \ |
| 1701 | "PhoneA call PhoneC failed.": |
| 1702 | ads[0].log.info("PhoneA failed to call PhoneC due to call" |
| 1703 | " waiting being disabled.") |
| 1704 | delattr(ad_host, "exception") |
| 1705 | return True |
| 1706 | log.error("Failed to get call_ab_id") |
| 1707 | return False |
| 1708 | else: |
| 1709 | if disable_cw: |
| 1710 | return False |
| 1711 | |
| 1712 | calls = ads[0].droid.telecomCallGetCallIds() |
| 1713 | ads[0].log.info("Calls in PhoneA %s", calls) |
| 1714 | if num_active_calls(log, ads[0]) != 2: |
| 1715 | return False |
| 1716 | if calls[0] == call_ab_id: |
| 1717 | call_ac_id = calls[1] |
| 1718 | else: |
| 1719 | call_ac_id = calls[0] |
| 1720 | |
| 1721 | if call_ac_id is None: |
| 1722 | log.error("Failed to get call_ac_id") |
| 1723 | return False |
| 1724 | |
| 1725 | num_swaps = 2 |
| 1726 | log.info("Step 4: Begin Swap x%s test.", num_swaps) |
| 1727 | if not swap_calls(log, ads, call_ab_id, call_ac_id, |
| 1728 | num_swaps): |
| 1729 | log.error("Swap test failed.") |
| 1730 | return False |
| 1731 | |
| 1732 | if not merge: |
| 1733 | result = True |
| 1734 | if not hangup_call(log, ads[1]): |
| 1735 | result = False |
| 1736 | if not hangup_call(log, ads[2]): |
| 1737 | result = False |
| 1738 | return result |
| 1739 | else: |
| 1740 | log.info("Step 5: Merge calls.") |
| 1741 | if host_rat[host_slot] == "volte": |
| 1742 | return _test_ims_conference_merge_drop_second_call_from_participant( |
| 1743 | log, ads, call_ab_id, call_ac_id) |
| 1744 | else: |
| 1745 | return _test_wcdma_conference_merge_drop( |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 1746 | log, ads, call_ab_id, call_ac_id) |
| 1747 | |
Richard Chang | 2243e0e | 2021-08-03 01:15:05 +0800 | [diff] [blame] | 1748 | |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 1749 | def msim_volte_wfc_call_forwarding( |
| 1750 | log, |
Markus Liu | 86d0683 | 2021-10-13 17:31:02 +0800 | [diff] [blame] | 1751 | tel_logger, |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 1752 | ads, |
| 1753 | callee_slot, |
| 1754 | dds_slot, |
| 1755 | callee_rat=["5g_wfc", "5g_wfc"], |
| 1756 | call_forwarding_type="unconditional", |
| 1757 | is_airplane_mode=False, |
| 1758 | is_wifi_connected=False, |
| 1759 | wfc_mode=[ |
| 1760 | WFC_MODE_CELLULAR_PREFERRED, |
| 1761 | WFC_MODE_CELLULAR_PREFERRED], |
| 1762 | wifi_network_ssid=None, |
| 1763 | wifi_network_pass=None): |
| 1764 | """Make VoLTE/WFC call to the primary device at specific slot with DDS |
| 1765 | at specific slot, and then forwarded to 3rd device with specific call |
| 1766 | forwarding type. |
| 1767 | |
| 1768 | Test step: |
| 1769 | 1. Get sub IDs of specific slots of both MO and MT devices. |
| 1770 | 2. Switch DDS to specific slot. |
| 1771 | 3. Check HTTP connection after DDS switch. |
| 1772 | 4. Set up phones in desired RAT. |
| 1773 | 5. Register and enable call forwarding with specifc type. |
| 1774 | 6. Make VoLTE/WFC call to the primary device and wait for being |
| 1775 | forwarded to 3rd device. |
| 1776 | |
| 1777 | Args: |
Markus Liu | 86d0683 | 2021-10-13 17:31:02 +0800 | [diff] [blame] | 1778 | log: logger object |
| 1779 | tel_logger: logger object for telephony proto |
| 1780 | ads: list of android devices |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 1781 | callee_slot: Slot of primary device receiving and forwarding MT call |
| 1782 | (0 or 1) |
| 1783 | dds_slot: Preferred data slot |
| 1784 | callee_rat: RAT for both slots of the primary device |
| 1785 | call_forwarding_type: |
| 1786 | "unconditional" |
| 1787 | "busy" |
| 1788 | "not_answered" |
| 1789 | "not_reachable" |
| 1790 | is_airplane_mode: True or False for WFC setup |
| 1791 | wfc_mode: Cellular preferred or Wi-Fi preferred. |
| 1792 | wifi_network_ssid: SSID of Wi-Fi AP |
| 1793 | wifi_network_pass: Password of Wi-Fi AP SSID |
| 1794 | |
| 1795 | Returns: |
| 1796 | True or False |
| 1797 | """ |
| 1798 | ad_caller = ads[1] |
| 1799 | ad_callee = ads[0] |
| 1800 | ad_forwarded_callee = ads[2] |
| 1801 | |
| 1802 | if not toggle_airplane_mode(log, ad_callee, False): |
| 1803 | ad_callee.log.error("Failed to disable airplane mode.") |
| 1804 | return False |
| 1805 | |
| 1806 | # Set up callee (primary device) |
| 1807 | callee_sub_id = get_subid_from_slot_index( |
| 1808 | log, ad_callee, callee_slot) |
| 1809 | if callee_sub_id == INVALID_SUB_ID: |
| 1810 | log.warning( |
| 1811 | "Failed to get sub ID at slot %s.", callee_slot) |
| 1812 | return |
| 1813 | callee_other_sub_id = get_subid_from_slot_index( |
| 1814 | log, ad_callee, 1-callee_slot) |
| 1815 | set_voice_sub_id(ad_callee, callee_sub_id) |
| 1816 | ad_callee.log.info( |
| 1817 | "Sub ID for incoming call at slot %s: %s", |
| 1818 | callee_slot, get_incoming_voice_sub_id(ad_callee)) |
| 1819 | |
| 1820 | # Set up caller |
| 1821 | _, caller_sub_id, _ = get_subid_on_same_network_of_host_ad(ads) |
| 1822 | if caller_sub_id == INVALID_SUB_ID: |
| 1823 | ad_caller.log.warning("Failed to get proper sub ID of the caller") |
| 1824 | return |
| 1825 | set_voice_sub_id(ad_caller, caller_sub_id) |
| 1826 | ad_caller.log.info( |
| 1827 | "Sub ID for outgoing call of the caller: %s", |
| 1828 | get_outgoing_voice_sub_id(ad_caller)) |
| 1829 | |
| 1830 | # Set up forwarded callee |
| 1831 | _, _, forwarded_callee_sub_id = get_subid_on_same_network_of_host_ad( |
| 1832 | ads) |
| 1833 | if forwarded_callee_sub_id == INVALID_SUB_ID: |
| 1834 | ad_forwarded_callee.log.warning( |
| 1835 | "Failed to get proper sub ID of the forwarded callee.") |
| 1836 | return |
| 1837 | set_voice_sub_id(ad_forwarded_callee, forwarded_callee_sub_id) |
| 1838 | ad_forwarded_callee.log.info( |
| 1839 | "Sub ID for incoming call of the forwarded callee: %s", |
| 1840 | get_incoming_voice_sub_id(ad_forwarded_callee)) |
| 1841 | |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 1842 | log.info("Step 1: Switch DDS.") |
| 1843 | if not set_dds_on_slot(ads[0], dds_slot): |
| 1844 | log.error( |
| 1845 | "Failed to set DDS at slot %s on %s",(dds_slot, ads[0].serial)) |
| 1846 | return False |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 1847 | |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 1848 | log.info("Step 2: Check HTTP connection after DDS switch.") |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 1849 | if not verify_http_connection(log, ad_callee): |
| 1850 | ad_callee.log.error("Failed to verify http connection.") |
| 1851 | return False |
| 1852 | else: |
| 1853 | ad_callee.log.info("Verify http connection successfully.") |
| 1854 | |
| 1855 | is_callee_in_call = is_phone_in_call_on_rat( |
| 1856 | log, ad_callee, callee_rat[callee_slot], only_return_fn=True) |
| 1857 | |
| 1858 | if is_airplane_mode: |
| 1859 | set_call_forwarding_by_mmi(log, ad_callee, ad_forwarded_callee) |
| 1860 | |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 1861 | log.info("Step 3: Set up phones in desired RAT.") |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 1862 | if callee_slot == 1: |
| 1863 | phone_setup_on_rat( |
| 1864 | log, |
| 1865 | ad_callee, |
| 1866 | callee_rat[0], |
| 1867 | callee_other_sub_id, |
| 1868 | is_airplane_mode, |
| 1869 | wfc_mode[0], |
| 1870 | wifi_network_ssid, |
| 1871 | wifi_network_pass) |
| 1872 | |
| 1873 | elif callee_slot == 0: |
| 1874 | phone_setup_on_rat( |
| 1875 | log, |
| 1876 | ad_callee, |
| 1877 | callee_rat[1], |
| 1878 | callee_other_sub_id, |
| 1879 | is_airplane_mode, |
| 1880 | wfc_mode[1], |
| 1881 | wifi_network_ssid, |
| 1882 | wifi_network_pass) |
| 1883 | |
| 1884 | argv = ( |
| 1885 | log, |
| 1886 | ad_callee, |
| 1887 | callee_rat[callee_slot], |
| 1888 | callee_sub_id, |
| 1889 | is_airplane_mode, |
| 1890 | wfc_mode[callee_slot], |
| 1891 | wifi_network_ssid, |
| 1892 | wifi_network_pass) |
| 1893 | |
| 1894 | tasks = [(phone_setup_voice_general, (log, ad_caller)), |
| 1895 | (phone_setup_on_rat, argv), |
| 1896 | (phone_setup_voice_general, (log, ad_forwarded_callee))] |
| 1897 | |
| 1898 | if not multithread_func(log, tasks): |
| 1899 | log.error("Phone Failed to Set Up Properly.") |
| 1900 | tel_logger.set_result(CallResult("CALL_SETUP_FAILURE")) |
| 1901 | raise signals.TestFailure("Failed", |
| 1902 | extras={"fail_reason": "Phone Failed to Set Up Properly."}) |
| 1903 | |
| 1904 | if is_wifi_connected: |
| 1905 | if not ensure_wifi_connected( |
| 1906 | log, |
| 1907 | ad_callee, |
| 1908 | wifi_network_ssid, |
| 1909 | wifi_network_pass, |
| 1910 | apm=is_airplane_mode): |
| 1911 | return False |
| 1912 | time.sleep(5) |
| 1913 | |
| 1914 | if "wfc" not in callee_rat[callee_slot]: |
| 1915 | if not toggle_wfc_for_subscription( |
| 1916 | log, |
| 1917 | ad_callee, |
| 1918 | new_state=True, |
| 1919 | sub_id=callee_sub_id): |
| 1920 | return False |
| 1921 | if not set_wfc_mode_for_subscription( |
| 1922 | ad_callee, wfc_mode[callee_slot], sub_id=callee_sub_id): |
| 1923 | return False |
| 1924 | |
| 1925 | log.info( |
| 1926 | "Step 4: Make voice call with call forwarding %s.", |
| 1927 | call_forwarding_type) |
| 1928 | result = three_phone_call_forwarding_short_seq( |
| 1929 | log, |
| 1930 | ad_callee, |
| 1931 | None, |
| 1932 | is_callee_in_call, |
| 1933 | ad_caller, |
| 1934 | ad_forwarded_callee, |
| 1935 | call_forwarding_type=call_forwarding_type) |
| 1936 | |
| 1937 | if not result: |
| 1938 | log.error( |
| 1939 | "Failed to make MO call from %s to %s slot %s and forward" |
| 1940 | " to %s.", |
| 1941 | ad_caller.serial, |
| 1942 | ad_callee.serial, |
| 1943 | callee_slot, |
| 1944 | ad_forwarded_callee.serial) |
| 1945 | return result |
| 1946 | |
Richard Chang | 2243e0e | 2021-08-03 01:15:05 +0800 | [diff] [blame] | 1947 | |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 1948 | def msim_volte_wfc_call_voice_conf( |
| 1949 | log, |
Markus Liu | 86d0683 | 2021-10-13 17:31:02 +0800 | [diff] [blame] | 1950 | tel_logger, |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 1951 | ads, |
| 1952 | host_slot, |
| 1953 | dds_slot, |
| 1954 | host_rat=["5g_wfc", "5g_wfc"], |
| 1955 | merge=True, |
| 1956 | disable_cw=False, |
| 1957 | is_airplane_mode=False, |
| 1958 | is_wifi_connected=False, |
| 1959 | wfc_mode=[WFC_MODE_CELLULAR_PREFERRED, WFC_MODE_CELLULAR_PREFERRED], |
| 1960 | reject_once=False, |
| 1961 | wifi_network_ssid=None, |
| 1962 | wifi_network_pass=None): |
| 1963 | """Make a VoLTE/WFC conference call at specific slot with DDS at |
| 1964 | specific slot. |
| 1965 | |
| 1966 | Test step: |
| 1967 | 1. Get sub IDs of specific slots of both MO and MT devices. |
| 1968 | 2. Set up phones in desired RAT |
| 1969 | 3. Enable VoLTE/WFC. |
| 1970 | 4. Switch DDS to specific slot. |
| 1971 | 5. Check HTTP connection after DDS switch. |
| 1972 | 6. Make 3-way VoLTE/WFC call. |
| 1973 | 7. Swap calls. |
| 1974 | 8. Merge calls. |
| 1975 | |
| 1976 | Args: |
Markus Liu | 86d0683 | 2021-10-13 17:31:02 +0800 | [diff] [blame] | 1977 | log: logger object |
| 1978 | tel_logger: logger object for telephony proto |
| 1979 | ads: list of android devices |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 1980 | host_slot: Slot on the primary device to host the comference call. |
| 1981 | 0 or 1 (0 for pSIM or 1 for eSIM)call |
| 1982 | dds_slot: Preferred data slot |
| 1983 | host_rat: RAT for both slots of the primary devicevice |
| 1984 | merge: True for merging 2 calls into the conference call. False for |
| 1985 | not merging 2 separated call. |
| 1986 | disable_cw: True for disabling call waiting and False on the |
| 1987 | contrary. |
| 1988 | enable_volte: True for enabling and False for disabling VoLTE for |
| 1989 | each slot on the primary device |
| 1990 | enable_wfc: True for enabling and False for disabling WFC for |
| 1991 | each slot on the primary device |
| 1992 | is_airplane_mode: True or False for WFC setup |
| 1993 | wfc_mode: Cellular preferred or Wi-Fi preferred. |
| 1994 | reject_once: True for rejecting the 2nd call once from the 3rd |
| 1995 | device (Phone C) to the primary device (Phone A). |
| 1996 | wifi_network_ssid: SSID of Wi-Fi AP |
| 1997 | wifi_network_pass: Password of Wi-Fi AP SSID |
| 1998 | |
| 1999 | Returns: |
| 2000 | True or False |
| 2001 | """ |
| 2002 | ad_host = ads[0] |
| 2003 | ad_p1 = ads[1] |
| 2004 | ad_p2 = ads[2] |
| 2005 | |
| 2006 | host_sub_id = get_subid_from_slot_index(log, ad_host, host_slot) |
| 2007 | if host_sub_id == INVALID_SUB_ID: |
| 2008 | ad_host.log.warning("Failed to get sub ID at slot.", host_slot) |
| 2009 | return |
| 2010 | host_other_sub_id = get_subid_from_slot_index( |
| 2011 | log, ad_host, 1-host_slot) |
| 2012 | set_voice_sub_id(ad_host, host_sub_id) |
| 2013 | ad_host.log.info( |
| 2014 | "Sub ID for outgoing call at slot %s: %s", |
| 2015 | host_slot, get_outgoing_voice_sub_id(ad_host)) |
| 2016 | |
| 2017 | _, p1_sub_id, p2_sub_id = get_subid_on_same_network_of_host_ad(ads) |
| 2018 | |
| 2019 | if p1_sub_id == INVALID_SUB_ID: |
| 2020 | ad_p1.log.warning("Failed to get proper sub ID.") |
| 2021 | return |
| 2022 | set_voice_sub_id(ad_p1, p1_sub_id) |
| 2023 | ad_p1.log.info( |
| 2024 | "Sub ID for incoming call: %s", |
| 2025 | get_incoming_voice_sub_id(ad_p1)) |
| 2026 | |
| 2027 | if p2_sub_id == INVALID_SUB_ID: |
| 2028 | ad_p2.log.warning("Failed to get proper sub ID.") |
| 2029 | return |
| 2030 | set_voice_sub_id(ad_p2, p2_sub_id) |
| 2031 | ad_p2.log.info( |
| 2032 | "Sub ID for incoming call: %s", get_incoming_voice_sub_id(ad_p2)) |
| 2033 | |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 2034 | log.info("Step 1: Switch DDS.") |
| 2035 | if not set_dds_on_slot(ads[0], dds_slot): |
| 2036 | log.error( |
| 2037 | "Failed to set DDS at slot %s on %s",(dds_slot, ads[0].serial)) |
| 2038 | return False |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 2039 | |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 2040 | log.info("Step 2: Check HTTP connection after DDS switch.") |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 2041 | if not verify_http_connection(log, ads[0]): |
| 2042 | ad_host.log.error("Failed to verify http connection.") |
| 2043 | return False |
| 2044 | else: |
| 2045 | ad_host.log.info("Verify http connection successfully.") |
| 2046 | |
| 2047 | if disable_cw: |
| 2048 | if not set_call_waiting(log, ad_host, enable=0): |
| 2049 | return False |
| 2050 | |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 2051 | log.info("Step 3: Set up phones in desired RAT.") |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 2052 | if host_slot == 1: |
| 2053 | phone_setup_on_rat( |
| 2054 | log, |
| 2055 | ad_host, |
| 2056 | host_rat[0], |
| 2057 | host_other_sub_id, |
| 2058 | is_airplane_mode, |
| 2059 | wfc_mode[0], |
| 2060 | wifi_network_ssid, |
| 2061 | wifi_network_pass) |
| 2062 | |
| 2063 | elif host_slot == 0: |
| 2064 | phone_setup_on_rat( |
| 2065 | log, |
| 2066 | ad_host, |
| 2067 | host_rat[1], |
| 2068 | host_other_sub_id, |
| 2069 | is_airplane_mode, |
| 2070 | wfc_mode[1], |
| 2071 | wifi_network_ssid, |
| 2072 | wifi_network_pass) |
| 2073 | |
| 2074 | argv = ( |
| 2075 | log, |
| 2076 | ad_host, |
| 2077 | host_rat[host_slot], |
| 2078 | host_sub_id, |
| 2079 | is_airplane_mode, |
| 2080 | wfc_mode[host_slot], |
| 2081 | wifi_network_ssid, |
| 2082 | wifi_network_pass) |
| 2083 | |
| 2084 | tasks = [(phone_setup_voice_general, (log, ad_p1)), |
| 2085 | (phone_setup_on_rat, argv), |
| 2086 | (phone_setup_voice_general, (log, ad_p2))] |
| 2087 | |
| 2088 | if not multithread_func(log, tasks): |
| 2089 | log.error("Phone Failed to Set Up Properly.") |
| 2090 | tel_logger.set_result(CallResult("CALL_SETUP_FAILURE")) |
| 2091 | raise signals.TestFailure("Failed", |
| 2092 | extras={"fail_reason": "Phone Failed to Set Up Properly."}) |
| 2093 | |
| 2094 | if is_wifi_connected: |
| 2095 | if not ensure_wifi_connected( |
| 2096 | log, |
| 2097 | ad_host, |
| 2098 | wifi_network_ssid, |
| 2099 | wifi_network_pass, |
| 2100 | apm=is_airplane_mode): |
| 2101 | return False |
| 2102 | time.sleep(5) |
| 2103 | |
| 2104 | if "wfc" not in host_rat[host_slot]: |
| 2105 | if not toggle_wfc_for_subscription( |
| 2106 | log, |
| 2107 | ad_host, |
| 2108 | new_state=True, |
| 2109 | sub_id=host_sub_id): |
| 2110 | return False |
| 2111 | if not set_wfc_mode_for_subscription( |
| 2112 | ad_host, wfc_mode[host_slot], sub_id=host_sub_id): |
| 2113 | return False |
| 2114 | |
| 2115 | log.info("Step 4: Make 3-way voice call.") |
| 2116 | is_host_in_call = is_phone_in_call_on_rat( |
| 2117 | log, ad_host, host_rat[host_slot], only_return_fn=True) |
| 2118 | call_ab_id = _three_phone_call_mo_add_mt( |
| 2119 | log, |
| 2120 | [ad_host, ad_p1, ad_p2], |
| 2121 | [None, None, None], |
| 2122 | [is_host_in_call, None, None], |
| 2123 | reject_once=reject_once) |
| 2124 | |
| 2125 | if call_ab_id is None: |
| 2126 | if disable_cw: |
| 2127 | set_call_waiting(log, ad_host, enable=1) |
| 2128 | if str(getattr(ad_host, "exception", None)) == \ |
| 2129 | "PhoneA call PhoneC failed.": |
| 2130 | ads[0].log.info("PhoneA failed to call PhoneC due to call" |
| 2131 | " waiting being disabled.") |
| 2132 | delattr(ad_host, "exception") |
| 2133 | return True |
| 2134 | log.error("Failed to get call_ab_id") |
| 2135 | return False |
| 2136 | else: |
| 2137 | if disable_cw: |
| 2138 | set_call_waiting(log, ad_host, enable=0) |
| 2139 | return False |
| 2140 | |
| 2141 | calls = ads[0].droid.telecomCallGetCallIds() |
| 2142 | ads[0].log.info("Calls in PhoneA %s", calls) |
| 2143 | if num_active_calls(log, ads[0]) != 2: |
| 2144 | return False |
| 2145 | if calls[0] == call_ab_id: |
| 2146 | call_ac_id = calls[1] |
| 2147 | else: |
| 2148 | call_ac_id = calls[0] |
| 2149 | |
| 2150 | if call_ac_id is None: |
| 2151 | log.error("Failed to get call_ac_id") |
| 2152 | return False |
| 2153 | |
| 2154 | num_swaps = 2 |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 2155 | log.info("Step 5: Begin Swap x%s test.", num_swaps) |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 2156 | if not swap_calls(log, ads, call_ab_id, call_ac_id, |
| 2157 | num_swaps): |
| 2158 | ad_host.log.error("Swap test failed.") |
| 2159 | return False |
| 2160 | |
| 2161 | if not merge: |
| 2162 | result = True |
| 2163 | if not hangup_call(log, ads[1]): |
| 2164 | result = False |
| 2165 | if not hangup_call(log, ads[2]): |
| 2166 | result = False |
| 2167 | return result |
| 2168 | else: |
Markus Liu | fdef306 | 2021-06-27 15:08:29 +0800 | [diff] [blame] | 2169 | log.info("Step 6: Merge calls.") |
Markus Liu | 3bedf21 | 2021-06-16 17:39:07 +0800 | [diff] [blame] | 2170 | |
| 2171 | if re.search('csfb|2g|3g', host_rat[host_slot].lower(), re.I): |
| 2172 | return _test_wcdma_conference_merge_drop( |
| 2173 | log, ads, call_ab_id, call_ac_id) |
| 2174 | else: |
| 2175 | return _test_ims_conference_merge_drop_second_call_from_participant( |
Markus Liu | 481eccd | 2021-04-21 14:36:15 +0800 | [diff] [blame] | 2176 | log, ads, call_ab_id, call_ac_id) |