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