blob: d5c6dc5835f9a46096979c414a66fc161459731a [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 Liue3143912021-03-31 10:49:00 +080019
20from acts import asserts
21from acts import signals
22from acts_contrib.test_utils.tel.loggers.protos.telephony_metric_pb2 import TelephonyVoiceTestResult
23from acts_contrib.test_utils.tel.loggers.telephony_metric_logger import TelephonyMetricLogger
24from acts_contrib.test_utils.tel.tel_defines import INVALID_SUB_ID
Markus Liu3bedf212021-06-16 17:39:07 +080025from acts_contrib.test_utils.tel.tel_defines import WFC_MODE_CELLULAR_PREFERRED
Markus Liue3143912021-03-31 10:49:00 +080026from acts_contrib.test_utils.tel.tel_subscription_utils import get_incoming_voice_sub_id
27from acts_contrib.test_utils.tel.tel_subscription_utils import get_outgoing_voice_sub_id
28from acts_contrib.test_utils.tel.tel_subscription_utils import get_subid_from_slot_index
29from acts_contrib.test_utils.tel.tel_subscription_utils import set_voice_sub_id
30from acts_contrib.test_utils.tel.tel_subscription_utils import set_dds_on_slot_0
31from acts_contrib.test_utils.tel.tel_subscription_utils import set_dds_on_slot_1
32from acts_contrib.test_utils.tel.tel_subscription_utils import get_subid_on_same_network_of_host_ad
Markus Liu481eccd2021-04-21 14:36:15 +080033from acts_contrib.test_utils.tel.tel_test_utils import call_setup_teardown
34from acts_contrib.test_utils.tel.tel_test_utils import hangup_call
Markus Liu3bedf212021-06-16 17:39:07 +080035from acts_contrib.test_utils.tel.tel_test_utils import ensure_wifi_connected
Markus Liue3143912021-03-31 10:49:00 +080036from acts_contrib.test_utils.tel.tel_test_utils import multithread_func
Markus Liu481eccd2021-04-21 14:36:15 +080037from acts_contrib.test_utils.tel.tel_test_utils import num_active_calls
38from acts_contrib.test_utils.tel.tel_test_utils import verify_incall_state
Markus Liue3143912021-03-31 10:49:00 +080039from acts_contrib.test_utils.tel.tel_test_utils import verify_http_connection
Markus Liu3bedf212021-06-16 17:39:07 +080040from acts_contrib.test_utils.tel.tel_test_utils import toggle_airplane_mode
Markus Liu481eccd2021-04-21 14:36:15 +080041from acts_contrib.test_utils.tel.tel_test_utils import set_call_waiting
42from acts_contrib.test_utils.tel.tel_test_utils import initiate_call
43from acts_contrib.test_utils.tel.tel_test_utils import wait_and_reject_call_for_subscription
Markus Liue3143912021-03-31 10:49:00 +080044from acts_contrib.test_utils.tel.tel_test_utils import get_slot_index_from_subid
Markus Liu481eccd2021-04-21 14:36:15 +080045from acts_contrib.test_utils.tel.tel_test_utils import erase_call_forwarding_by_mmi
46from acts_contrib.test_utils.tel.tel_test_utils import get_operator_name
Markus Liu3bedf212021-06-16 17:39:07 +080047from acts_contrib.test_utils.tel.tel_test_utils import toggle_wfc_for_subscription
48from acts_contrib.test_utils.tel.tel_test_utils import set_wfc_mode_for_subscription
49from acts_contrib.test_utils.tel.tel_test_utils import set_call_forwarding_by_mmi
Markus Liu481eccd2021-04-21 14:36:15 +080050from acts_contrib.test_utils.tel.tel_voice_utils import three_phone_call_forwarding_short_seq
51from acts_contrib.test_utils.tel.tel_voice_utils import three_phone_call_waiting_short_seq
52from acts_contrib.test_utils.tel.tel_voice_utils import swap_calls
Markus Liu3bedf212021-06-16 17:39:07 +080053from acts_contrib.test_utils.tel.tel_voice_utils import phone_setup_voice_general
Markus Liue3143912021-03-31 10:49:00 +080054from acts_contrib.test_utils.tel.tel_voice_utils import phone_setup_on_rat
55from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_on_rat
56from acts_contrib.test_utils.tel.tel_voice_utils import two_phone_call_msim_for_slot
Markus Liu481eccd2021-04-21 14:36:15 +080057from acts_contrib.test_utils.tel.tel_voice_conf_utils import _test_ims_conference_merge_drop_second_call_from_participant
58from acts_contrib.test_utils.tel.tel_voice_conf_utils import _test_wcdma_conference_merge_drop
Markus Liu3bedf212021-06-16 17:39:07 +080059from acts_contrib.test_utils.tel.tel_voice_conf_utils import _three_phone_call_mo_add_mt
Markus Liue3143912021-03-31 10:49:00 +080060
61CallResult = TelephonyVoiceTestResult.CallResult.Value
62tel_logger = TelephonyMetricLogger.for_test_case()
63
64def dsds_voice_call_test(
65 log,
66 ads,
67 mo_slot,
68 mt_slot,
69 dds,
70 mo_rat=["", ""],
71 mt_rat=["", ""],
72 call_direction="mo"):
73 """Make MO/MT voice call at specific slot in specific RAT with DDS at
74 specific slot.
75
76 Test step:
77 1. Get sub IDs of specific slots of both MO and MT devices.
78 2. Switch DDS to specific slot.
79 3. Check HTTP connection after DDS switch.
80 4. Set up phones in desired RAT.
81 5. Make voice call.
82
83 Args:
84 log: logger object
85 ads: list of android devices
86 mo_slot: Slot making MO call (0 or 1)
87 mt_slot: Slot receiving MT call (0 or 1)
88 dds: Preferred data slot
89 mo_rat: RAT for both slots of MO device
90 mt_rat: RAT for both slots of MT device
91 call_direction: "mo" or "mt"
92
93 Returns:
94 TestFailure if failed.
95 """
96 if call_direction == "mo":
97 ad_mo = ads[0]
98 ad_mt = ads[1]
99 else:
100 ad_mo = ads[1]
101 ad_mt = ads[0]
102
103 if mo_slot is not None:
104 mo_sub_id = get_subid_from_slot_index(log, ad_mo, mo_slot)
105 if mo_sub_id == INVALID_SUB_ID:
106 ad_mo.log.warning("Failed to get sub ID ar slot %s.", mo_slot)
107 return False
108 mo_other_sub_id = get_subid_from_slot_index(
109 log, ad_mo, 1-mo_slot)
110 set_voice_sub_id(ad_mo, mo_sub_id)
111 else:
112 _, mo_sub_id, _ = get_subid_on_same_network_of_host_ad(ads)
113 if mo_sub_id == INVALID_SUB_ID:
114 ad_mo.log.warning("Failed to get sub ID ar slot %s.", mo_slot)
115 return False
116 mo_slot = "auto"
117 set_voice_sub_id(ad_mo, mo_sub_id)
118 ad_mo.log.info("Sub ID for outgoing call at slot %s: %s",
119 mo_slot, get_outgoing_voice_sub_id(ad_mo))
120
121 if mt_slot is not None:
122 mt_sub_id = get_subid_from_slot_index(log, ad_mt, mt_slot)
123 if mt_sub_id == INVALID_SUB_ID:
124 ad_mt.log.warning("Failed to get sub ID at slot %s.", mt_slot)
125 return False
126 mt_other_sub_id = get_subid_from_slot_index(
127 log, ad_mt, 1-mt_slot)
128 set_voice_sub_id(ad_mt, mt_sub_id)
129 else:
130 _, mt_sub_id, _ = get_subid_on_same_network_of_host_ad(ads)
131 if mt_sub_id == INVALID_SUB_ID:
132 ad_mt.log.warning("Failed to get sub ID at slot %s.", mt_slot)
133 return False
134 mt_slot = "auto"
135 set_voice_sub_id(ad_mt, mt_sub_id)
136 ad_mt.log.info("Sub ID for incoming call at slot %s: %s", mt_slot,
137 get_incoming_voice_sub_id(ad_mt))
138
139 log.info("Step 1: Switch DDS.")
140 if dds:
141 if not set_dds_on_slot_1(ads[0]):
142 ads[0].log.warning("Failed to set DDS at eSIM.")
143 return False
144 else:
145 if not set_dds_on_slot_0(ads[0]):
146 ads[0].log.warning("Failed to set DDS at pSIM.")
147 return False
148
149 log.info("Step 2: Check HTTP connection after DDS switch.")
150 if not verify_http_connection(log,
151 ads[0],
152 url="https://www.google.com",
153 retry=5,
154 retry_interval=15,
155 expected_state=True):
156
157 log.error("Failed to verify http connection.")
158 return False
159 else:
160 log.info("Verify http connection successfully.")
161
162 if mo_slot == 0 or mo_slot == 1:
163 phone_setup_on_rat(log, ad_mo, mo_rat[1-mo_slot], mo_other_sub_id)
164 mo_phone_setup_func_argv = (log, ad_mo, mo_rat[mo_slot], mo_sub_id)
165 is_mo_in_call = is_phone_in_call_on_rat(
166 log, ad_mo, mo_rat[mo_slot], only_return_fn=True)
167 else:
168 mo_phone_setup_func_argv = (log, ad_mo, 'general')
169 is_mo_in_call = is_phone_in_call_on_rat(
170 log, ad_mo, 'general', only_return_fn=True)
171
172 if mt_slot == 0 or mt_slot == 1:
173 phone_setup_on_rat(log, ad_mt, mt_rat[1-mt_slot], mt_other_sub_id)
174 mt_phone_setup_func_argv = (log, ad_mt, mt_rat[mt_slot], mt_sub_id)
175 is_mt_in_call = is_phone_in_call_on_rat(
176 log, ad_mt, mt_rat[mt_slot], only_return_fn=True)
177 else:
178 mt_phone_setup_func_argv = (log, ad_mt, 'general')
179 is_mt_in_call = is_phone_in_call_on_rat(
180 log, ad_mt, 'general', only_return_fn=True)
181
182 log.info("Step 3: Set up phones in desired RAT.")
183 tasks = [(phone_setup_on_rat, mo_phone_setup_func_argv),
184 (phone_setup_on_rat, mt_phone_setup_func_argv)]
185 if not multithread_func(log, tasks):
186 log.error("Phone Failed to Set Up Properly.")
187 tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
188 raise signals.TestFailure("Failed",
189 extras={"fail_reason": "Phone Failed to Set Up Properly."})
190
191 log.info("Step 4: Make voice call.")
192 result = two_phone_call_msim_for_slot(
193 log,
194 ad_mo,
195 get_slot_index_from_subid(log, ad_mo, mo_sub_id),
196 None,
197 is_mo_in_call,
198 ad_mt,
199 get_slot_index_from_subid(log, ad_mt, mt_sub_id),
200 None,
201 is_mt_in_call)
202
203 tel_logger.set_result(result.result_value)
204
205 if not result:
206 log.error(
207 "Failed to make MO call from %s slot %s to %s slot %s",
208 ad_mo.serial, mo_slot, ad_mt.serial, mt_slot)
209 raise signals.TestFailure("Failed",
Markus Liu481eccd2021-04-21 14:36:15 +0800210 extras={"fail_reason": str(result.result_value)})
211
212def erase_call_forwarding(log, ad):
213 slot0_sub_id = get_subid_from_slot_index(log, ad, 0)
214 slot1_sub_id = get_subid_from_slot_index(log, ad, 1)
215 current_voice_sub_id = get_incoming_voice_sub_id(ad)
216 for sub_id in (slot0_sub_id, slot1_sub_id):
217 set_voice_sub_id(ad, sub_id)
218 get_operator_name(log, ad, sub_id)
219 erase_call_forwarding_by_mmi(log, ad)
220 set_voice_sub_id(ad, current_voice_sub_id)
221
222def three_way_calling_mo_and_mt_with_hangup_once(
223 log,
224 ads,
225 phone_setups,
226 verify_funcs,
227 reject_once=False):
228 """Use 3 phones to make MO call and MT call.
229
230 Call from PhoneA to PhoneB, accept on PhoneB.
231 Call from PhoneC to PhoneA, accept on PhoneA.
232
233 Args:
234 ads: list of ad object.
235 The list should have three objects.
236 phone_setups: list of phone setup functions.
237 The list should have three objects.
238 verify_funcs: list of phone call verify functions.
239 The list should have three objects.
240
241 Returns:
242 If success, return 'call_AB' id in PhoneA.
243 if fail, return None.
244 """
245
246 class _CallException(Exception):
247 pass
248
249 try:
250 verify_func_a, verify_func_b, verify_func_c = verify_funcs
251 tasks = []
252 for ad, setup_func in zip(ads, phone_setups):
253 if setup_func is not None:
254 tasks.append((setup_func, (log, ad, get_incoming_voice_sub_id(ad))))
255 if tasks != [] and not multithread_func(log, tasks):
256 log.error("Phone Failed to Set Up Properly.")
257 raise _CallException("Setup failed.")
258 for ad in ads:
259 ad.droid.telecomCallClearCallList()
260 if num_active_calls(log, ad) != 0:
261 ad.log.error("Phone Call List is not empty.")
262 raise _CallException("Clear call list failed.")
263
264 log.info("Step1: Call From PhoneA to PhoneB.")
265 if not call_setup_teardown(
266 log,
267 ads[0],
268 ads[1],
269 ad_hangup=None,
270 verify_caller_func=verify_func_a,
271 verify_callee_func=verify_func_b):
272 raise _CallException("PhoneA call PhoneB failed.")
273
274 calls = ads[0].droid.telecomCallGetCallIds()
275 ads[0].log.info("Calls in PhoneA %s", calls)
276 if num_active_calls(log, ads[0]) != 1:
277 raise _CallException("Call list verify failed.")
278 call_ab_id = calls[0]
279
280 log.info("Step2: Call From PhoneC to PhoneA.")
281 if reject_once:
282 log.info("Step2-1: Reject incoming call once.")
283 if not initiate_call(
284 log,
285 ads[2],
286 ads[0].telephony['subscription'][get_incoming_voice_sub_id(
287 ads[0])]['phone_num']):
288 ads[2].log.error("Initiate call failed.")
289 raise _CallException("Failed to initiate call.")
290
291 if not wait_and_reject_call_for_subscription(
292 log,
293 ads[0],
294 get_incoming_voice_sub_id(ads[0]),
295 incoming_number= \
296 ads[2].telephony['subscription'][
297 get_incoming_voice_sub_id(
298 ads[2])]['phone_num']):
299 ads[0].log.error("Reject call fail.")
300 raise _CallException("Failed to reject call.")
301
302 hangup_call(log, ads[2])
303 time.sleep(15)
304
305 if not call_setup_teardown(
306 log,
307 ads[2],
308 ads[0],
309 ad_hangup=None,
310 verify_caller_func=verify_func_c,
311 verify_callee_func=verify_func_a):
312 raise _CallException("PhoneA call PhoneC failed.")
313 if not verify_incall_state(log, [ads[0], ads[1], ads[2]],
314 True):
315 raise _CallException("Not All phones are in-call.")
316
317 except Exception as e:
318 setattr(ads[0], "exception", e)
319 return None
320
321 return call_ab_id
322
323def msim_call_forwarding(
324 log,
325 ads,
326 caller_slot,
327 callee_slot,
328 forwarded_callee_slot,
329 dds_slot,
330 caller_rat=["", ""],
331 callee_rat=["", ""],
332 forwarded_callee_rat=["", ""],
333 call_forwarding_type="unconditional"):
334 """Make MO voice call to the primary device at specific slot in specific
335 RAT with DDS at specific slot, and then forwarded to 3rd device with
336 specific call forwarding type.
337
338 Test step:
339 1. Get sub IDs of specific slots of both MO and MT devices.
340 2. Switch DDS to specific slot.
341 3. Check HTTP connection after DDS switch.
342 4. Set up phones in desired RAT.
343 5. Register and enable call forwarding with specifc type.
344 5. Make voice call to the primary device and wait for being forwarded
345 to 3rd device.
346
347 Args:
348 caller_slot: Slot of 2nd device making MO call (0 or 1)
349 callee_slot: Slot of primary device receiving and forwarding MT call
350 (0 or 1)
351 forwarded_callee_slot: Slot of 3rd device receiving forwarded call.
352 dds_slot: Preferred data slot
353 caller_rat: RAT for both slots of the 2nd device
354 callee_rat: RAT for both slots of the primary device
355 forwarded_callee_rat: RAT for both slots of the 3rd device
356 call_forwarding_type:
357 "unconditional"
358 "busy"
359 "not_answered"
360 "not_reachable"
361
362 Returns:
363 True or False
364 """
365 ad_caller = ads[1]
366 ad_callee = ads[0]
367 ad_forwarded_callee = ads[2]
368
369 if callee_slot is not None:
370 callee_sub_id = get_subid_from_slot_index(
371 log, ad_callee, callee_slot)
372 if callee_sub_id == INVALID_SUB_ID:
373 ad_callee.log.warning(
374 "Failed to get sub ID at slot %s.", callee_slot)
375 return False
376 callee_other_sub_id = get_subid_from_slot_index(
377 log, ad_callee, 1-callee_slot)
378 set_voice_sub_id(ad_callee, callee_sub_id)
379 else:
380 callee_sub_id, _, _ = get_subid_on_same_network_of_host_ad(ads)
381 if callee_sub_id == INVALID_SUB_ID:
382 ad_callee.log.warning(
383 "Failed to get sub ID at slot %s.", callee_slot)
384 return False
385 callee_slot = "auto"
386 set_voice_sub_id(ad_callee, callee_sub_id)
387 ad_callee.log.info(
388 "Sub ID for incoming call at slot %s: %s",
389 callee_slot, get_incoming_voice_sub_id(ad_callee))
390
391 if caller_slot is not None:
392 caller_sub_id = get_subid_from_slot_index(
393 log, ad_caller, caller_slot)
394 if caller_sub_id == INVALID_SUB_ID:
395 ad_caller.log.warning(
396 "Failed to get sub ID at slot %s.", caller_slot)
397 return False
398 caller_other_sub_id = get_subid_from_slot_index(
399 log, ad_caller, 1-caller_slot)
400 set_voice_sub_id(ad_caller, caller_sub_id)
401 else:
402 _, caller_sub_id, _ = get_subid_on_same_network_of_host_ad(ads)
403 if caller_sub_id == INVALID_SUB_ID:
404 ad_caller.log.warning(
405 "Failed to get sub ID at slot %s.", caller_slot)
406 return False
407 caller_slot = "auto"
408 set_voice_sub_id(ad_caller, caller_sub_id)
409 ad_caller.log.info(
410 "Sub ID for outgoing call at slot %s: %s",
411 caller_slot, get_outgoing_voice_sub_id(ad_caller))
412
413 if forwarded_callee_slot is not None:
414 forwarded_callee_sub_id = get_subid_from_slot_index(
415 log, ad_forwarded_callee, forwarded_callee_slot)
416 if forwarded_callee_sub_id == INVALID_SUB_ID:
417 ad_forwarded_callee.log.warning(
418 "Failed to get sub ID at slot %s.", forwarded_callee_slot)
419 return False
420 forwarded_callee_other_sub_id = get_subid_from_slot_index(
421 log, ad_forwarded_callee, 1-forwarded_callee_slot)
422 set_voice_sub_id(
423 ad_forwarded_callee, forwarded_callee_sub_id)
424 else:
425 _, _, forwarded_callee_sub_id = \
426 get_subid_on_same_network_of_host_ad(ads)
427 if forwarded_callee_sub_id == INVALID_SUB_ID:
428 ad_forwarded_callee.log.warning(
429 "Failed to get sub ID at slot %s.", forwarded_callee_slot)
430 return False
431 forwarded_callee_slot = "auto"
432 set_voice_sub_id(
433 ad_forwarded_callee, forwarded_callee_sub_id)
434 ad_forwarded_callee.log.info(
435 "Sub ID for incoming call at slot %s: %s",
436 forwarded_callee_slot,
437 get_incoming_voice_sub_id(ad_forwarded_callee))
438
439 log.info("Step 1: Switch DDS.")
440 if dds_slot:
441 if not set_dds_on_slot_1(ads[0]):
442 log.warning(
443 "Failed to set DDS at eSIM on %s", ads[0].serial)
444 return False
445 else:
446 if not set_dds_on_slot_0(ads[0]):
447 log.warning(
448 "Failed to set DDS at pSIM on %s", ads[0].serial)
449 return False
450
451 log.info("Step 2: Check HTTP connection after DDS switch.")
452 if not verify_http_connection(log,
453 ads[0],
454 url="https://www.google.com",
455 retry=5,
456 retry_interval=15,
457 expected_state=True):
458
459 log.error("Failed to verify http connection.")
460 return False
461 else:
462 log.info("Verify http connection successfully.")
463
464 if caller_slot == 1:
465 phone_setup_on_rat(
466 log,
467 ad_caller,
468 caller_rat[0],
469 caller_other_sub_id)
470
471 elif caller_slot == 0:
472 phone_setup_on_rat(
473 log,
474 ad_caller,
475 caller_rat[1],
476 caller_other_sub_id)
477 else:
478 phone_setup_on_rat(
479 log,
480 ad_caller,
481 'general')
482
483 if callee_slot == 1:
484 phone_setup_on_rat(
485 log,
486 ad_callee,
487 callee_rat[0],
488 callee_other_sub_id)
489
490 elif callee_slot == 0:
491 phone_setup_on_rat(
492 log,
493 ad_callee,
494 callee_rat[1],
495 callee_other_sub_id)
496 else:
497 phone_setup_on_rat(
498 log,
499 ad_callee,
500 'general')
501
502 if forwarded_callee_slot == 1:
503 phone_setup_on_rat(
504 log,
505 ad_forwarded_callee,
506 forwarded_callee_rat[0],
507 forwarded_callee_other_sub_id)
508
509 elif forwarded_callee_slot == 0:
510 phone_setup_on_rat(
511 log,
512 ad_forwarded_callee,
513 forwarded_callee_rat[1],
514 forwarded_callee_other_sub_id)
515 else:
516 phone_setup_on_rat(
517 log,
518 ad_forwarded_callee,
519 'general')
520
521 if caller_slot == 0 or caller_slot == 1:
522 caller_phone_setup_func_argv = (log, ad_caller, caller_rat[caller_slot], caller_sub_id)
523 else:
524 caller_phone_setup_func_argv = (log, ad_caller, 'general')
525
526 callee_phone_setup_func_argv = (log, ad_callee, callee_rat[callee_slot], callee_sub_id)
527
528 if forwarded_callee_slot == 0 or forwarded_callee_slot == 1:
529 forwarded_callee_phone_setup_func_argv = (
530 log,
531 ad_forwarded_callee,
532 forwarded_callee_rat[forwarded_callee_slot],
533 forwarded_callee_sub_id)
534 else:
535 forwarded_callee_phone_setup_func_argv = (
536 log,
537 ad_forwarded_callee,
538 'general')
539
540 log.info("Step 3: Set up phones in desired RAT.")
541 tasks = [(phone_setup_on_rat, caller_phone_setup_func_argv),
542 (phone_setup_on_rat, callee_phone_setup_func_argv),
543 (phone_setup_on_rat,
544 forwarded_callee_phone_setup_func_argv)]
545 if not multithread_func(log, tasks):
546 log.error("Phone Failed to Set Up Properly.")
547 tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
548 raise signals.TestFailure("Failed",
549 extras={"fail_reason": "Phone Failed to Set Up Properly."})
550
551 is_callee_in_call = is_phone_in_call_on_rat(
552 log, ad_callee, callee_rat[callee_slot], only_return_fn=True)
553
554 is_call_waiting = re.search(
555 "call_waiting (True (\d)|False)", call_forwarding_type, re.I)
556 if is_call_waiting:
557 if is_call_waiting.group(1) == "False":
558 call_waiting = False
559 scenario = None
560 else:
561 call_waiting = True
562 scenario = int(is_call_waiting.group(2))
563
564 log.info(
565 "Step 4: Make voice call with call waiting enabled = %s.",
566 call_waiting)
567 result = three_phone_call_waiting_short_seq(
568 log,
569 ads[0],
570 None,
571 is_callee_in_call,
572 ads[1],
573 ads[2],
574 call_waiting=call_waiting, scenario=scenario)
575 else:
576 log.info(
577 "Step 4: Make voice call with call forwarding %s.",
578 call_forwarding_type)
579 result = three_phone_call_forwarding_short_seq(
580 log,
581 ads[0],
582 None,
583 is_callee_in_call,
584 ads[1],
585 ads[2],
586 call_forwarding_type=call_forwarding_type)
587
588 if not result:
589 if is_call_waiting:
590 pass
591 else:
592 log.error(
593 "Failed to make MO call from %s slot %s to %s slot %s"
594 " and forward to %s slot %s",
595 ad_caller.serial,
596 caller_slot,
597 ad_callee.serial,
598 callee_slot,
599 ad_forwarded_callee.serial,
600 forwarded_callee_slot)
601
602 return result
603
604def msim_call_voice_conf(
605 log,
606 ads,
607 host_slot,
608 p1_slot,
609 p2_slot,
610 dds_slot,
611 host_rat=["volte", "volte"],
612 p1_rat="",
613 p2_rat="",
614 merge=True,
615 disable_cw=False):
616 """Make a voice conference call at specific slot in specific RAT with
617 DDS at specific slot.
618
619 Test step:
620 1. Get sub IDs of specific slots of both MO and MT devices.
621 2. Switch DDS to specific slot.
622 3. Check HTTP connection after DDS switch.
623 4. Set up phones in desired RAT and make 3-way voice call.
624 5. Swap calls.
625 6. Merge calls.
626
627 Args:
628 host_slot: Slot on the primary device to host the comference call.
629 0 or 1 (0 for pSIM or 1 for eSIM)
630 p1_slot: Slot on the participant device for the call
631 p2_slot: Slot on another participant device for the call
632 dds_slot: Preferred data slot
633 host_rat: RAT for both slots of the primary device
634 p1_rat: RAT for both slots of the participant device
635 p2_rat: RAT for both slots of another participant device
636 merge: True for merging 2 calls into the conference call. False for
637 not merging 2 separated call.
638 disable_cw: True for disabling call waiting and False on the
639 contrary.
640
641 Returns:
Markus Liu3bedf212021-06-16 17:39:07 +0800642 True or False
Markus Liu481eccd2021-04-21 14:36:15 +0800643 """
644 ad_host = ads[0]
645 ad_p1 = ads[1]
646 ad_p2 = ads[2]
647
648 if host_slot is not None:
649 host_sub_id = get_subid_from_slot_index(
650 log, ad_host, host_slot)
651 if host_sub_id == INVALID_SUB_ID:
652 ad_host.log.warning("Failed to get sub ID at slot.", host_slot)
653 return False
654 host_other_sub_id = get_subid_from_slot_index(
655 log, ad_host, 1-host_slot)
656 set_voice_sub_id(ad_host, host_sub_id)
657 else:
658 host_sub_id, _, _ = get_subid_on_same_network_of_host_ad(ads)
659 if host_sub_id == INVALID_SUB_ID:
660 ad_host.log.warning("Failed to get sub ID at slot.", host_slot)
661 return False
662 host_slot = "auto"
663 set_voice_sub_id(ad_host, host_sub_id)
664
665 ad_host.log.info("Sub ID for outgoing call at slot %s: %s",
666 host_slot, get_outgoing_voice_sub_id(ad_host))
667
668 if p1_slot is not None:
669 p1_sub_id = get_subid_from_slot_index(log, ad_p1, p1_slot)
670 if p1_sub_id == INVALID_SUB_ID:
671 ad_p1.log.warning("Failed to get sub ID at slot %s.", p1_slot)
672 return False
673 set_voice_sub_id(ad_p1, p1_sub_id)
674 else:
675 _, p1_sub_id, _ = get_subid_on_same_network_of_host_ad(ads)
676 if p1_sub_id == INVALID_SUB_ID:
677 ad_p1.log.warning("Failed to get sub ID at slot %s.", p1_slot)
678 return False
679 p1_slot = "auto"
680 set_voice_sub_id(ad_p1, p1_sub_id)
681 ad_p1.log.info("Sub ID for incoming call at slot %s: %s",
682 p1_slot, get_incoming_voice_sub_id(ad_p1))
683
684 if p2_slot is not None:
685 p2_sub_id = get_subid_from_slot_index(log, ad_p2, p2_slot)
686 if p2_sub_id == INVALID_SUB_ID:
687 ad_p2.log.warning("Failed to get sub ID at slot %s.", p2_slot)
688 return False
689 set_voice_sub_id(ad_p2, p2_sub_id)
690 else:
691 _, _, p2_sub_id = get_subid_on_same_network_of_host_ad(ads)
692 if p2_sub_id == INVALID_SUB_ID:
693 ad_p2.log.warning("Failed to get sub ID at slot %s.", p2_slot)
694 return False
695 p2_slot = "auto"
696 set_voice_sub_id(ad_p2, p2_sub_id)
697 ad_p2.log.info("Sub ID for incoming call at slot %s: %s",
698 p2_slot, get_incoming_voice_sub_id(ad_p2))
699
700 log.info("Step 1: Switch DDS.")
701 if dds_slot:
702 if not set_dds_on_slot_1(ads[0]):
703 log.warning(
704 "Failed to set DDS at eSIM on %s", ads[0].serial)
705 return False
706 else:
707 if not set_dds_on_slot_0(ads[0]):
708 log.warning(
709 "Failed to set DDS at pSIM on %s", ads[0].serial)
710 return False
711
712 log.info("Step 2: Check HTTP connection after DDS switch.")
713 if not verify_http_connection(log,
714 ads[0],
715 url="https://www.google.com",
716 retry=5,
717 retry_interval=15,
718 expected_state=True):
719
720 log.error("Failed to verify http connection.")
721 return False
722 else:
723 log.info("Verify http connection successfully.")
724
725 if disable_cw:
726 if not set_call_waiting(log, ad_host, enable=0):
727 return False
728 else:
729 if not set_call_waiting(log, ad_host, enable=1):
730 return False
731
732 if host_slot == 1:
733 phone_setup_on_rat(
734 log,
735 ad_host,
736 host_rat[0],
737 host_other_sub_id)
738
739 elif host_slot == 0:
740 phone_setup_on_rat(
741 log,
742 ad_host,
743 host_rat[1],
744 host_other_sub_id)
745
746 if host_slot == 0 or host_slot == 1:
747 host_phone_setup_func_argv = (log, ad_host, host_rat[host_slot], host_sub_id)
748 is_host_in_call = is_phone_in_call_on_rat(
749 log, ad_host, host_rat[host_slot], only_return_fn=True)
750 else:
751 host_phone_setup_func_argv = (log, ad_host, 'general')
752 is_host_in_call = is_phone_in_call_on_rat(
753 log, ad_host, 'general', only_return_fn=True)
754
755 if p1_rat:
756 p1_phone_setup_func_argv = (log, ad_p1, p1_rat, p1_sub_id)
757 is_p1_in_call = is_phone_in_call_on_rat(
758 log, ad_p1, p1_rat, only_return_fn=True)
759 else:
760 p1_phone_setup_func_argv = (log, ad_p1, 'general')
761 is_p1_in_call = is_phone_in_call_on_rat(
762 log, ad_p1, 'general', only_return_fn=True)
763
764 if p2_rat:
765 p2_phone_setup_func_argv = (log, ad_p2, p2_rat, p2_sub_id)
766 is_p2_in_call = is_phone_in_call_on_rat(
767 log, ad_p2, p2_rat, only_return_fn=True)
768 else:
769 p2_phone_setup_func_argv = (log, ad_p2, 'general')
770 is_p2_in_call = is_phone_in_call_on_rat(
771 log, ad_p2, 'general', only_return_fn=True)
772
773 log.info("Step 3: Set up phone in desired RAT and make 3-way"
774 " voice call.")
775
776 tasks = [(phone_setup_on_rat, host_phone_setup_func_argv),
777 (phone_setup_on_rat, p1_phone_setup_func_argv),
778 (phone_setup_on_rat, p2_phone_setup_func_argv)]
779 if not multithread_func(log, tasks):
780 log.error("Phone Failed to Set Up Properly.")
781 tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
782 raise signals.TestFailure("Failed",
783 extras={"fail_reason": "Phone Failed to Set Up Properly."})
784
785 call_ab_id = three_way_calling_mo_and_mt_with_hangup_once(
786 log,
787 [ad_host, ad_p1, ad_p2],
788 [None, None, None], [
789 is_host_in_call, is_p1_in_call,
790 is_p2_in_call
791 ])
792
793 if call_ab_id is None:
794 if disable_cw:
795 set_call_waiting(log, ad_host, enable=1)
796 if str(getattr(ad_host, "exception", None)) == \
797 "PhoneA call PhoneC failed.":
798 ads[0].log.info("PhoneA failed to call PhoneC due to call"
799 " waiting being disabled.")
800 delattr(ad_host, "exception")
801 return True
802 log.error("Failed to get call_ab_id")
803 return False
804 else:
805 if disable_cw:
806 return False
807
808 calls = ads[0].droid.telecomCallGetCallIds()
809 ads[0].log.info("Calls in PhoneA %s", calls)
810 if num_active_calls(log, ads[0]) != 2:
811 return False
812 if calls[0] == call_ab_id:
813 call_ac_id = calls[1]
814 else:
815 call_ac_id = calls[0]
816
817 if call_ac_id is None:
818 log.error("Failed to get call_ac_id")
819 return False
820
821 num_swaps = 2
822 log.info("Step 4: Begin Swap x%s test.", num_swaps)
823 if not swap_calls(log, ads, call_ab_id, call_ac_id,
824 num_swaps):
825 log.error("Swap test failed.")
826 return False
827
828 if not merge:
829 result = True
830 if not hangup_call(log, ads[1]):
831 result = False
832 if not hangup_call(log, ads[2]):
833 result = False
834 return result
835 else:
836 log.info("Step 5: Merge calls.")
837 if host_rat[host_slot] == "volte":
838 return _test_ims_conference_merge_drop_second_call_from_participant(
839 log, ads, call_ab_id, call_ac_id)
840 else:
841 return _test_wcdma_conference_merge_drop(
Markus Liu3bedf212021-06-16 17:39:07 +0800842 log, ads, call_ab_id, call_ac_id)
843
844def msim_volte_wfc_call_forwarding(
845 log,
846 ads,
847 callee_slot,
848 dds_slot,
849 callee_rat=["5g_wfc", "5g_wfc"],
850 call_forwarding_type="unconditional",
851 is_airplane_mode=False,
852 is_wifi_connected=False,
853 wfc_mode=[
854 WFC_MODE_CELLULAR_PREFERRED,
855 WFC_MODE_CELLULAR_PREFERRED],
856 wifi_network_ssid=None,
857 wifi_network_pass=None):
858 """Make VoLTE/WFC call to the primary device at specific slot with DDS
859 at specific slot, and then forwarded to 3rd device with specific call
860 forwarding type.
861
862 Test step:
863 1. Get sub IDs of specific slots of both MO and MT devices.
864 2. Switch DDS to specific slot.
865 3. Check HTTP connection after DDS switch.
866 4. Set up phones in desired RAT.
867 5. Register and enable call forwarding with specifc type.
868 6. Make VoLTE/WFC call to the primary device and wait for being
869 forwarded to 3rd device.
870
871 Args:
872 callee_slot: Slot of primary device receiving and forwarding MT call
873 (0 or 1)
874 dds_slot: Preferred data slot
875 callee_rat: RAT for both slots of the primary device
876 call_forwarding_type:
877 "unconditional"
878 "busy"
879 "not_answered"
880 "not_reachable"
881 is_airplane_mode: True or False for WFC setup
882 wfc_mode: Cellular preferred or Wi-Fi preferred.
883 wifi_network_ssid: SSID of Wi-Fi AP
884 wifi_network_pass: Password of Wi-Fi AP SSID
885
886 Returns:
887 True or False
888 """
889 ad_caller = ads[1]
890 ad_callee = ads[0]
891 ad_forwarded_callee = ads[2]
892
893 if not toggle_airplane_mode(log, ad_callee, False):
894 ad_callee.log.error("Failed to disable airplane mode.")
895 return False
896
897 # Set up callee (primary device)
898 callee_sub_id = get_subid_from_slot_index(
899 log, ad_callee, callee_slot)
900 if callee_sub_id == INVALID_SUB_ID:
901 log.warning(
902 "Failed to get sub ID at slot %s.", callee_slot)
903 return
904 callee_other_sub_id = get_subid_from_slot_index(
905 log, ad_callee, 1-callee_slot)
906 set_voice_sub_id(ad_callee, callee_sub_id)
907 ad_callee.log.info(
908 "Sub ID for incoming call at slot %s: %s",
909 callee_slot, get_incoming_voice_sub_id(ad_callee))
910
911 # Set up caller
912 _, caller_sub_id, _ = get_subid_on_same_network_of_host_ad(ads)
913 if caller_sub_id == INVALID_SUB_ID:
914 ad_caller.log.warning("Failed to get proper sub ID of the caller")
915 return
916 set_voice_sub_id(ad_caller, caller_sub_id)
917 ad_caller.log.info(
918 "Sub ID for outgoing call of the caller: %s",
919 get_outgoing_voice_sub_id(ad_caller))
920
921 # Set up forwarded callee
922 _, _, forwarded_callee_sub_id = get_subid_on_same_network_of_host_ad(
923 ads)
924 if forwarded_callee_sub_id == INVALID_SUB_ID:
925 ad_forwarded_callee.log.warning(
926 "Failed to get proper sub ID of the forwarded callee.")
927 return
928 set_voice_sub_id(ad_forwarded_callee, forwarded_callee_sub_id)
929 ad_forwarded_callee.log.info(
930 "Sub ID for incoming call of the forwarded callee: %s",
931 get_incoming_voice_sub_id(ad_forwarded_callee))
932
933 ad_callee.log.info("Step 1: Switch DDS.")
934 if dds_slot:
935 if not set_dds_on_slot_1(ad_callee):
936 ad_callee.log.warning(
937 "Failed to set DDS at eSIM on %s", ad_callee.serial)
938 return
939 else:
940 if not set_dds_on_slot_0(ad_callee):
941 ad_callee.log.warning(
942 "Failed to set DDS at pSIM on %s", ad_callee.serial)
943 return
944
945 ad_callee.log.info("Step 2: Check HTTP connection after DDS switch.")
946 if not verify_http_connection(log, ad_callee):
947 ad_callee.log.error("Failed to verify http connection.")
948 return False
949 else:
950 ad_callee.log.info("Verify http connection successfully.")
951
952 is_callee_in_call = is_phone_in_call_on_rat(
953 log, ad_callee, callee_rat[callee_slot], only_return_fn=True)
954
955 if is_airplane_mode:
956 set_call_forwarding_by_mmi(log, ad_callee, ad_forwarded_callee)
957
958 ad_callee.log.info("Step 3: Set up phones in desired RAT.")
959 if callee_slot == 1:
960 phone_setup_on_rat(
961 log,
962 ad_callee,
963 callee_rat[0],
964 callee_other_sub_id,
965 is_airplane_mode,
966 wfc_mode[0],
967 wifi_network_ssid,
968 wifi_network_pass)
969
970 elif callee_slot == 0:
971 phone_setup_on_rat(
972 log,
973 ad_callee,
974 callee_rat[1],
975 callee_other_sub_id,
976 is_airplane_mode,
977 wfc_mode[1],
978 wifi_network_ssid,
979 wifi_network_pass)
980
981 argv = (
982 log,
983 ad_callee,
984 callee_rat[callee_slot],
985 callee_sub_id,
986 is_airplane_mode,
987 wfc_mode[callee_slot],
988 wifi_network_ssid,
989 wifi_network_pass)
990
991 tasks = [(phone_setup_voice_general, (log, ad_caller)),
992 (phone_setup_on_rat, argv),
993 (phone_setup_voice_general, (log, ad_forwarded_callee))]
994
995 if not multithread_func(log, tasks):
996 log.error("Phone Failed to Set Up Properly.")
997 tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
998 raise signals.TestFailure("Failed",
999 extras={"fail_reason": "Phone Failed to Set Up Properly."})
1000
1001 if is_wifi_connected:
1002 if not ensure_wifi_connected(
1003 log,
1004 ad_callee,
1005 wifi_network_ssid,
1006 wifi_network_pass,
1007 apm=is_airplane_mode):
1008 return False
1009 time.sleep(5)
1010
1011 if "wfc" not in callee_rat[callee_slot]:
1012 if not toggle_wfc_for_subscription(
1013 log,
1014 ad_callee,
1015 new_state=True,
1016 sub_id=callee_sub_id):
1017 return False
1018 if not set_wfc_mode_for_subscription(
1019 ad_callee, wfc_mode[callee_slot], sub_id=callee_sub_id):
1020 return False
1021
1022 log.info(
1023 "Step 4: Make voice call with call forwarding %s.",
1024 call_forwarding_type)
1025 result = three_phone_call_forwarding_short_seq(
1026 log,
1027 ad_callee,
1028 None,
1029 is_callee_in_call,
1030 ad_caller,
1031 ad_forwarded_callee,
1032 call_forwarding_type=call_forwarding_type)
1033
1034 if not result:
1035 log.error(
1036 "Failed to make MO call from %s to %s slot %s and forward"
1037 " to %s.",
1038 ad_caller.serial,
1039 ad_callee.serial,
1040 callee_slot,
1041 ad_forwarded_callee.serial)
1042 return result
1043
1044def msim_volte_wfc_call_voice_conf(
1045 log,
1046 ads,
1047 host_slot,
1048 dds_slot,
1049 host_rat=["5g_wfc", "5g_wfc"],
1050 merge=True,
1051 disable_cw=False,
1052 is_airplane_mode=False,
1053 is_wifi_connected=False,
1054 wfc_mode=[WFC_MODE_CELLULAR_PREFERRED, WFC_MODE_CELLULAR_PREFERRED],
1055 reject_once=False,
1056 wifi_network_ssid=None,
1057 wifi_network_pass=None):
1058 """Make a VoLTE/WFC conference call at specific slot with DDS at
1059 specific slot.
1060
1061 Test step:
1062 1. Get sub IDs of specific slots of both MO and MT devices.
1063 2. Set up phones in desired RAT
1064 3. Enable VoLTE/WFC.
1065 4. Switch DDS to specific slot.
1066 5. Check HTTP connection after DDS switch.
1067 6. Make 3-way VoLTE/WFC call.
1068 7. Swap calls.
1069 8. Merge calls.
1070
1071 Args:
1072 host_slot: Slot on the primary device to host the comference call.
1073 0 or 1 (0 for pSIM or 1 for eSIM)call
1074 dds_slot: Preferred data slot
1075 host_rat: RAT for both slots of the primary devicevice
1076 merge: True for merging 2 calls into the conference call. False for
1077 not merging 2 separated call.
1078 disable_cw: True for disabling call waiting and False on the
1079 contrary.
1080 enable_volte: True for enabling and False for disabling VoLTE for
1081 each slot on the primary device
1082 enable_wfc: True for enabling and False for disabling WFC for
1083 each slot on the primary device
1084 is_airplane_mode: True or False for WFC setup
1085 wfc_mode: Cellular preferred or Wi-Fi preferred.
1086 reject_once: True for rejecting the 2nd call once from the 3rd
1087 device (Phone C) to the primary device (Phone A).
1088 wifi_network_ssid: SSID of Wi-Fi AP
1089 wifi_network_pass: Password of Wi-Fi AP SSID
1090
1091 Returns:
1092 True or False
1093 """
1094 ad_host = ads[0]
1095 ad_p1 = ads[1]
1096 ad_p2 = ads[2]
1097
1098 host_sub_id = get_subid_from_slot_index(log, ad_host, host_slot)
1099 if host_sub_id == INVALID_SUB_ID:
1100 ad_host.log.warning("Failed to get sub ID at slot.", host_slot)
1101 return
1102 host_other_sub_id = get_subid_from_slot_index(
1103 log, ad_host, 1-host_slot)
1104 set_voice_sub_id(ad_host, host_sub_id)
1105 ad_host.log.info(
1106 "Sub ID for outgoing call at slot %s: %s",
1107 host_slot, get_outgoing_voice_sub_id(ad_host))
1108
1109 _, p1_sub_id, p2_sub_id = get_subid_on_same_network_of_host_ad(ads)
1110
1111 if p1_sub_id == INVALID_SUB_ID:
1112 ad_p1.log.warning("Failed to get proper sub ID.")
1113 return
1114 set_voice_sub_id(ad_p1, p1_sub_id)
1115 ad_p1.log.info(
1116 "Sub ID for incoming call: %s",
1117 get_incoming_voice_sub_id(ad_p1))
1118
1119 if p2_sub_id == INVALID_SUB_ID:
1120 ad_p2.log.warning("Failed to get proper sub ID.")
1121 return
1122 set_voice_sub_id(ad_p2, p2_sub_id)
1123 ad_p2.log.info(
1124 "Sub ID for incoming call: %s", get_incoming_voice_sub_id(ad_p2))
1125
1126 ad_host.log.info("Step 1: Switch DDS.")
1127 if dds_slot:
1128 if not set_dds_on_slot_1(ad_host):
1129 ad_host.log.warning(
1130 "Failed to set DDS at eSIM on %s", ad_host.serial)
1131 return
1132 else:
1133 if not set_dds_on_slot_0(ad_host):
1134 ad_host.log.warning(
1135 "Failed to set DDS at pSIM on %s", ad_host.serial)
1136 return
1137
1138 ad_host.log.info("Step 2: Check HTTP connection after DDS switch.")
1139 if not verify_http_connection(log, ads[0]):
1140 ad_host.log.error("Failed to verify http connection.")
1141 return False
1142 else:
1143 ad_host.log.info("Verify http connection successfully.")
1144
1145 if disable_cw:
1146 if not set_call_waiting(log, ad_host, enable=0):
1147 return False
1148
1149 ad_host.log.info("Step 3: Set up phones in desired RAT.")
1150 if host_slot == 1:
1151 phone_setup_on_rat(
1152 log,
1153 ad_host,
1154 host_rat[0],
1155 host_other_sub_id,
1156 is_airplane_mode,
1157 wfc_mode[0],
1158 wifi_network_ssid,
1159 wifi_network_pass)
1160
1161 elif host_slot == 0:
1162 phone_setup_on_rat(
1163 log,
1164 ad_host,
1165 host_rat[1],
1166 host_other_sub_id,
1167 is_airplane_mode,
1168 wfc_mode[1],
1169 wifi_network_ssid,
1170 wifi_network_pass)
1171
1172 argv = (
1173 log,
1174 ad_host,
1175 host_rat[host_slot],
1176 host_sub_id,
1177 is_airplane_mode,
1178 wfc_mode[host_slot],
1179 wifi_network_ssid,
1180 wifi_network_pass)
1181
1182 tasks = [(phone_setup_voice_general, (log, ad_p1)),
1183 (phone_setup_on_rat, argv),
1184 (phone_setup_voice_general, (log, ad_p2))]
1185
1186 if not multithread_func(log, tasks):
1187 log.error("Phone Failed to Set Up Properly.")
1188 tel_logger.set_result(CallResult("CALL_SETUP_FAILURE"))
1189 raise signals.TestFailure("Failed",
1190 extras={"fail_reason": "Phone Failed to Set Up Properly."})
1191
1192 if is_wifi_connected:
1193 if not ensure_wifi_connected(
1194 log,
1195 ad_host,
1196 wifi_network_ssid,
1197 wifi_network_pass,
1198 apm=is_airplane_mode):
1199 return False
1200 time.sleep(5)
1201
1202 if "wfc" not in host_rat[host_slot]:
1203 if not toggle_wfc_for_subscription(
1204 log,
1205 ad_host,
1206 new_state=True,
1207 sub_id=host_sub_id):
1208 return False
1209 if not set_wfc_mode_for_subscription(
1210 ad_host, wfc_mode[host_slot], sub_id=host_sub_id):
1211 return False
1212
1213 log.info("Step 4: Make 3-way voice call.")
1214 is_host_in_call = is_phone_in_call_on_rat(
1215 log, ad_host, host_rat[host_slot], only_return_fn=True)
1216 call_ab_id = _three_phone_call_mo_add_mt(
1217 log,
1218 [ad_host, ad_p1, ad_p2],
1219 [None, None, None],
1220 [is_host_in_call, None, None],
1221 reject_once=reject_once)
1222
1223 if call_ab_id is None:
1224 if disable_cw:
1225 set_call_waiting(log, ad_host, enable=1)
1226 if str(getattr(ad_host, "exception", None)) == \
1227 "PhoneA call PhoneC failed.":
1228 ads[0].log.info("PhoneA failed to call PhoneC due to call"
1229 " waiting being disabled.")
1230 delattr(ad_host, "exception")
1231 return True
1232 log.error("Failed to get call_ab_id")
1233 return False
1234 else:
1235 if disable_cw:
1236 set_call_waiting(log, ad_host, enable=0)
1237 return False
1238
1239 calls = ads[0].droid.telecomCallGetCallIds()
1240 ads[0].log.info("Calls in PhoneA %s", calls)
1241 if num_active_calls(log, ads[0]) != 2:
1242 return False
1243 if calls[0] == call_ab_id:
1244 call_ac_id = calls[1]
1245 else:
1246 call_ac_id = calls[0]
1247
1248 if call_ac_id is None:
1249 log.error("Failed to get call_ac_id")
1250 return False
1251
1252 num_swaps = 2
1253 ad_host.log.info("Step 5: Begin Swap x%s test.", num_swaps)
1254 if not swap_calls(log, ads, call_ab_id, call_ac_id,
1255 num_swaps):
1256 ad_host.log.error("Swap test failed.")
1257 return False
1258
1259 if not merge:
1260 result = True
1261 if not hangup_call(log, ads[1]):
1262 result = False
1263 if not hangup_call(log, ads[2]):
1264 result = False
1265 return result
1266 else:
1267 ad_host.log.info("Step 6: Merge calls.")
1268
1269 if re.search('csfb|2g|3g', host_rat[host_slot].lower(), re.I):
1270 return _test_wcdma_conference_merge_drop(
1271 log, ads, call_ab_id, call_ac_id)
1272 else:
1273 return _test_ims_conference_merge_drop_second_call_from_participant(
Markus Liu481eccd2021-04-21 14:36:15 +08001274 log, ads, call_ab_id, call_ac_id)