• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3.4
2#
3#   Copyright 2016 - Google
4#
5#   Licensed under the Apache License, Version 2.0 (the "License");
6#   you may not use this file except in compliance with the License.
7#   You may obtain a copy of the License at
8#
9#       http://www.apache.org/licenses/LICENSE-2.0
10#
11#   Unless required by applicable law or agreed to in writing, software
12#   distributed under the License is distributed on an "AS IS" BASIS,
13#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#   See the License for the specific language governing permissions and
15#   limitations under the License.
16"""
17    Test Script for Telephony Pre Check In Sanity
18"""
19
20import time
21from queue import Empty
22from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
23from acts.test_utils.tel.tel_defines import GEN_3G
24from acts.test_utils.tel.tel_defines import GEN_4G
25from acts.test_utils.tel.tel_defines import PHONE_TYPE_CDMA
26from acts.test_utils.tel.tel_defines import PHONE_TYPE_GSM
27from acts.test_utils.tel.tel_defines import RAT_3G
28from acts.test_utils.tel.tel_defines import VT_STATE_BIDIRECTIONAL
29from acts.test_utils.tel.tel_defines import WAIT_TIME_ANDROID_STATE_SETTLING
30from acts.test_utils.tel.tel_defines import WFC_MODE_WIFI_PREFERRED
31from acts.test_utils.tel.tel_test_utils import call_setup_teardown
32from acts.test_utils.tel.tel_test_utils import \
33    ensure_network_generation_for_subscription
34from acts.test_utils.tel.tel_test_utils import ensure_network_generation
35from acts.test_utils.tel.tel_test_utils import mms_send_receive_verify
36from acts.test_utils.tel.tel_test_utils import multithread_func
37from acts.test_utils.tel.tel_test_utils import set_call_state_listen_level
38from acts.test_utils.tel.tel_test_utils import setup_sim
39from acts.test_utils.tel.tel_test_utils import sms_send_receive_verify
40from acts.test_utils.tel.tel_video_utils import phone_setup_video
41from acts.test_utils.tel.tel_video_utils import is_phone_in_call_video_bidirectional
42from acts.test_utils.tel.tel_video_utils import video_call_setup_teardown
43from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_1x
44from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_2g
45from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_3g
46from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_csfb
47from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_iwlan
48from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_volte
49from acts.test_utils.tel.tel_voice_utils import phone_setup_3g
50from acts.test_utils.tel.tel_voice_utils import phone_setup_csfb
51from acts.test_utils.tel.tel_voice_utils import phone_setup_data_general
52from acts.test_utils.tel.tel_voice_utils import phone_setup_iwlan
53from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_2g
54from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_3g
55from acts.test_utils.tel.tel_voice_utils import phone_setup_volte
56from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_general
57from acts.utils import rand_ascii_str
58
59
60class TelLiveSmsTest(TelephonyBaseTest):
61    def __init__(self, controllers):
62        TelephonyBaseTest.__init__(self, controllers)
63        self.tests = (
64            "test_sms_mo_4g", "test_sms_mt_4g", "test_sms_mo_in_call_volte",
65            "test_sms_mt_in_call_volte", "test_sms_mo_in_call_csfb",
66            "test_sms_mt_in_call_csfb", "test_sms_mo_in_call_csfb_1x",
67            "test_sms_mt_in_call_csfb_1x", "test_sms_mo_3g", "test_sms_mt_3g",
68            "test_sms_mo_in_call_wcdma", "test_sms_mt_in_call_wcdma",
69            "test_sms_mo_in_call_1x", "test_sms_mt_in_call_1x",
70            "test_sms_mo_2g", "test_sms_mt_2g", "test_sms_mo_in_call_gsm",
71            "test_sms_mt_in_call_gsm", "test_sms_mo_iwlan",
72            "test_sms_mt_iwlan", "test_sms_mo_in_call_iwlan",
73            "test_sms_mt_in_call_iwlan", "test_sms_mo_in_call_vt",
74            "test_sms_mt_in_call_vt")
75        # The path for "sim config file" should be set
76        # in "testbed.config" entry "sim_conf_file".
77        self.wifi_network_ssid = self.user_params["wifi_network_ssid"]
78
79        try:
80            self.wifi_network_pass = self.user_params["wifi_network_pass"]
81        except KeyError:
82            self.wifi_network_pass = None
83
84    def _sms_test(self, ads):
85        """Test SMS between two phones.
86
87        Returns:
88            True if success.
89            False if failed.
90        """
91
92        sms_params = [(ads[0], ads[1])]
93        message_arrays = [[rand_ascii_str(50)], [rand_ascii_str(160)],
94                          [rand_ascii_str(180)]]
95
96        for outer_param in sms_params:
97            outer_param = (self.log, ) + outer_param
98            for message_array in message_arrays:
99                inner_param = outer_param + (message_array, )
100                if not sms_send_receive_verify(*inner_param):
101                    return False
102
103        return True
104
105    def _sms_test_mo(self, ads):
106        return self._sms_test([ads[0], ads[1]])
107
108    def _sms_test_mt(self, ads):
109        return self._sms_test([ads[1], ads[0]])
110
111    def _mo_sms_in_3g_call(self, ads):
112        self.log.info("Begin In Call SMS Test.")
113        if not call_setup_teardown(self.log,
114                                   ads[0],
115                                   ads[1],
116                                   ad_hangup=None,
117                                   verify_caller_func=is_phone_in_call_3g,
118                                   verify_callee_func=None):
119            return False
120
121        if not self._sms_test_mo(ads):
122            self.log.error("SMS test fail.")
123            return False
124
125        return True
126
127    def _mt_sms_in_3g_call(self, ads):
128        self.log.info("Begin In Call SMS Test.")
129        if not call_setup_teardown(self.log,
130                                   ads[0],
131                                   ads[1],
132                                   ad_hangup=None,
133                                   verify_caller_func=is_phone_in_call_3g,
134                                   verify_callee_func=None):
135            return False
136
137        if not self._sms_test_mt(ads):
138            self.log.error("SMS test fail.")
139            return False
140
141        return True
142
143    def _mo_sms_in_2g_call(self, ads):
144        self.log.info("Begin In Call SMS Test.")
145        if not call_setup_teardown(self.log,
146                                   ads[0],
147                                   ads[1],
148                                   ad_hangup=None,
149                                   verify_caller_func=is_phone_in_call_2g,
150                                   verify_callee_func=None):
151            return False
152
153        if not self._sms_test_mo(ads):
154            self.log.error("SMS test fail.")
155            return False
156
157        return True
158
159    def _mt_sms_in_2g_call(self, ads):
160        self.log.info("Begin In Call SMS Test.")
161        if not call_setup_teardown(self.log,
162                                   ads[0],
163                                   ads[1],
164                                   ad_hangup=None,
165                                   verify_caller_func=is_phone_in_call_2g,
166                                   verify_callee_func=None):
167            return False
168
169        if not self._sms_test_mt(ads):
170            self.log.error("SMS test fail.")
171            return False
172
173        return True
174
175    @TelephonyBaseTest.tel_test_wrap
176    def test_sms_mo_general(self):
177        """Test SMS basic function between two phone. Phones in any network.
178
179        Airplane mode is off.
180        Send SMS from PhoneA to PhoneB.
181        Verify received message on PhoneB is correct.
182
183        Returns:
184            True if success.
185            False if failed.
186        """
187        ads = self.android_devices
188
189        tasks = [(phone_setup_voice_general, (self.log, ads[0])),
190                 (phone_setup_voice_general, (self.log, ads[1]))]
191        if not multithread_func(self.log, tasks):
192            self.log.error("Phone Failed to Set Up Properly.")
193            return False
194
195        return self._sms_test_mo(ads)
196
197    @TelephonyBaseTest.tel_test_wrap
198    def test_sms_mt_general(self):
199        """Test SMS basic function between two phone. Phones in any network.
200
201        Airplane mode is off.
202        Send SMS from PhoneB to PhoneA.
203        Verify received message on PhoneA is correct.
204
205        Returns:
206            True if success.
207            False if failed.
208        """
209        ads = self.android_devices
210
211        tasks = [(phone_setup_voice_general, (self.log, ads[0])),
212                 (phone_setup_voice_general, (self.log, ads[1]))]
213        if not multithread_func(self.log, tasks):
214            self.log.error("Phone Failed to Set Up Properly.")
215            return False
216
217        return self._sms_test_mt(ads)
218
219    @TelephonyBaseTest.tel_test_wrap
220    def test_sms_mo_2g(self):
221        """Test SMS basic function between two phone. Phones in 3g network.
222
223        Airplane mode is off.
224        Send SMS from PhoneA to PhoneB.
225        Verify received message on PhoneB is correct.
226
227        Returns:
228            True if success.
229            False if failed.
230        """
231        ads = self.android_devices
232
233        tasks = [(phone_setup_voice_2g, (self.log, ads[0])),
234                 (phone_setup_voice_general, (self.log, ads[1]))]
235        if not multithread_func(self.log, tasks):
236            self.log.error("Phone Failed to Set Up Properly.")
237            return False
238
239        return self._sms_test_mo(ads)
240
241    @TelephonyBaseTest.tel_test_wrap
242    def test_sms_mt_2g(self):
243        """Test SMS basic function between two phone. Phones in 3g network.
244
245        Airplane mode is off.
246        Send SMS from PhoneB to PhoneA.
247        Verify received message on PhoneA is correct.
248
249        Returns:
250            True if success.
251            False if failed.
252        """
253        ads = self.android_devices
254
255        tasks = [(phone_setup_voice_2g, (self.log, ads[0])),
256                 (phone_setup_voice_general, (self.log, ads[1]))]
257        if not multithread_func(self.log, tasks):
258            self.log.error("Phone Failed to Set Up Properly.")
259            return False
260
261        return self._sms_test_mt(ads)
262
263    @TelephonyBaseTest.tel_test_wrap
264    def test_sms_mo_3g(self):
265        """Test SMS basic function between two phone. Phones in 3g network.
266
267        Airplane mode is off.
268        Send SMS from PhoneA to PhoneB.
269        Verify received message on PhoneB is correct.
270
271        Returns:
272            True if success.
273            False if failed.
274        """
275
276        ads = self.android_devices
277
278        tasks = [(phone_setup_3g, (self.log, ads[0])),
279                 (phone_setup_voice_general, (self.log, ads[1]))]
280        if not multithread_func(self.log, tasks):
281            self.log.error("Phone Failed to Set Up Properly.")
282            return False
283
284        return self._sms_test_mo(ads)
285
286    @TelephonyBaseTest.tel_test_wrap
287    def test_sms_mt_3g(self):
288        """Test SMS basic function between two phone. Phones in 3g network.
289
290        Airplane mode is off.
291        Send SMS from PhoneB to PhoneA.
292        Verify received message on PhoneA is correct.
293
294        Returns:
295            True if success.
296            False if failed.
297        """
298
299        ads = self.android_devices
300
301        tasks = [(phone_setup_3g, (self.log, ads[0])),
302                 (phone_setup_voice_general, (self.log, ads[1]))]
303        if not multithread_func(self.log, tasks):
304            self.log.error("Phone Failed to Set Up Properly.")
305            return False
306
307        return self._sms_test_mt(ads)
308
309    @TelephonyBaseTest.tel_test_wrap
310    def test_sms_mo_4g(self):
311        """Test SMS basic function between two phone. Phones in LTE network.
312
313        Airplane mode is off.
314        Send SMS from PhoneA to PhoneB.
315        Verify received message on PhoneB is correct.
316
317        Returns:
318            True if success.
319            False if failed.
320        """
321
322        ads = self.android_devices
323        if (not phone_setup_data_general(self.log, ads[1]) and
324                not phone_setup_voice_general(self.log, ads[1])):
325            self.log.error("Failed to setup PhoneB.")
326            return False
327        if not ensure_network_generation(self.log, ads[0], GEN_4G):
328            self.log.error("DUT Failed to Set Up Properly.")
329            return False
330
331        return self._sms_test_mo(ads)
332
333    @TelephonyBaseTest.tel_test_wrap
334    def test_sms_mt_4g(self):
335        """Test SMS basic function between two phone. Phones in LTE network.
336
337        Airplane mode is off.
338        Send SMS from PhoneB to PhoneA.
339        Verify received message on PhoneA is correct.
340
341        Returns:
342            True if success.
343            False if failed.
344        """
345
346        ads = self.android_devices
347
348        if (not phone_setup_data_general(self.log, ads[1]) and
349                not phone_setup_voice_general(self.log, ads[1])):
350            self.log.error("Failed to setup PhoneB.")
351            return False
352        if not ensure_network_generation(self.log, ads[0], GEN_4G):
353            self.log.error("DUT Failed to Set Up Properly.")
354            return False
355
356        return self._sms_test_mt(ads)
357
358    @TelephonyBaseTest.tel_test_wrap
359    def test_sms_mo_in_call_volte(self):
360        """ Test MO SMS during a MO VoLTE call.
361
362        Make Sure PhoneA is in LTE mode (with VoLTE).
363        Make Sure PhoneB is able to make/receive call.
364        Call from PhoneA to PhoneB, accept on PhoneB, send SMS on PhoneA.
365
366        Returns:
367            True if pass; False if fail.
368        """
369        ads = self.android_devices
370
371        tasks = [(phone_setup_volte, (self.log, ads[0])), (phone_setup_volte,
372                                                           (self.log, ads[1]))]
373        if not multithread_func(self.log, tasks):
374            self.log.error("Phone Failed to Set Up Properly.")
375            return False
376
377        self.log.info("Begin In Call SMS Test.")
378        if not call_setup_teardown(self.log,
379                                   ads[0],
380                                   ads[1],
381                                   ad_hangup=None,
382                                   verify_caller_func=is_phone_in_call_volte,
383                                   verify_callee_func=None):
384            return False
385
386        if not self._sms_test_mo(ads):
387            self.log.error("SMS test fail.")
388            return False
389
390        return True
391
392    @TelephonyBaseTest.tel_test_wrap
393    def test_sms_mt_in_call_volte(self):
394        """ Test MT SMS during a MO VoLTE call.
395
396        Make Sure PhoneA is in LTE mode (with VoLTE).
397        Make Sure PhoneB is able to make/receive call.
398        Call from PhoneA to PhoneB, accept on PhoneB, receive SMS on PhoneA.
399
400        Returns:
401            True if pass; False if fail.
402        """
403        ads = self.android_devices
404
405        tasks = [(phone_setup_volte, (self.log, ads[0])), (phone_setup_volte,
406                                                           (self.log, ads[1]))]
407        if not multithread_func(self.log, tasks):
408            self.log.error("Phone Failed to Set Up Properly.")
409            return False
410
411        self.log.info("Begin In Call SMS Test.")
412        if not call_setup_teardown(self.log,
413                                   ads[0],
414                                   ads[1],
415                                   ad_hangup=None,
416                                   verify_caller_func=is_phone_in_call_volte,
417                                   verify_callee_func=None):
418            return False
419
420        if not self._sms_test_mt(ads):
421            self.log.error("SMS test fail.")
422            return False
423
424        return True
425
426    @TelephonyBaseTest.tel_test_wrap
427    def test_sms_mo_in_call_wcdma(self):
428        """ Test MO SMS during a MO wcdma call.
429
430        Make Sure PhoneA is in wcdma mode.
431        Make Sure PhoneB is able to make/receive call.
432        Call from PhoneA to PhoneB, accept on PhoneB, send SMS on PhoneA.
433
434        Returns:
435            True if pass; False if fail.
436        """
437        ads = self.android_devices
438        # make sure PhoneA is GSM phone before proceed.
439        if (ads[0].droid.telephonyGetPhoneType() != PHONE_TYPE_GSM):
440            self.log.error("Not GSM phone, abort this wcdma SMS test.")
441            return False
442
443        tasks = [(phone_setup_3g, (self.log, ads[0])),
444                 (phone_setup_voice_general, (self.log, ads[1]))]
445        if not multithread_func(self.log, tasks):
446            self.log.error("Phone Failed to Set Up Properly.")
447            return False
448
449        return self._mo_sms_in_3g_call(ads)
450
451    @TelephonyBaseTest.tel_test_wrap
452    def test_sms_mt_in_call_wcdma(self):
453        """ Test MT SMS during a MO wcdma call.
454
455        Make Sure PhoneA is in wcdma mode.
456        Make Sure PhoneB is able to make/receive call.
457        Call from PhoneA to PhoneB, accept on PhoneB, receive SMS on PhoneA.
458
459        Returns:
460            True if pass; False if fail.
461        """
462        ads = self.android_devices
463        # make sure PhoneA is GSM phone before proceed.
464        if (ads[0].droid.telephonyGetPhoneType() != PHONE_TYPE_GSM):
465            self.log.error("Not GSM phone, abort this wcdma SMS test.")
466            return False
467
468        tasks = [(phone_setup_3g, (self.log, ads[0])),
469                 (phone_setup_voice_general, (self.log, ads[1]))]
470        if not multithread_func(self.log, tasks):
471            self.log.error("Phone Failed to Set Up Properly.")
472            return False
473
474        return self._mt_sms_in_3g_call(ads)
475
476    @TelephonyBaseTest.tel_test_wrap
477    def test_sms_mo_in_call_csfb(self):
478        """ Test MO SMS during a MO csfb wcdma/gsm call.
479
480        Make Sure PhoneA is in LTE mode (no VoLTE).
481        Make Sure PhoneB is able to make/receive call.
482        Call from PhoneA to PhoneB, accept on PhoneB, send SMS on PhoneA.
483
484        Returns:
485            True if pass; False if fail.
486        """
487        ads = self.android_devices
488        # make sure PhoneA is GSM phone before proceed.
489        if (ads[0].droid.telephonyGetPhoneType() != PHONE_TYPE_GSM):
490            self.log.error("Not GSM phone, abort this csfb wcdma SMS test.")
491            return False
492
493        tasks = [(phone_setup_csfb, (self.log, ads[0])),
494                 (phone_setup_voice_general, (self.log, ads[1]))]
495        if not multithread_func(self.log, tasks):
496            self.log.error("Phone Failed to Set Up Properly.")
497            return False
498
499        self.log.info("Begin In Call SMS Test.")
500        if not call_setup_teardown(self.log,
501                                   ads[0],
502                                   ads[1],
503                                   ad_hangup=None,
504                                   verify_caller_func=is_phone_in_call_csfb,
505                                   verify_callee_func=None):
506            return False
507
508        if not self._sms_test_mo(ads):
509            self.log.error("SMS test fail.")
510            return False
511
512        return True
513
514    @TelephonyBaseTest.tel_test_wrap
515    def test_sms_mt_in_call_csfb(self):
516        """ Test MT SMS during a MO csfb wcdma/gsm call.
517
518        Make Sure PhoneA is in LTE mode (no VoLTE).
519        Make Sure PhoneB is able to make/receive call.
520        Call from PhoneA to PhoneB, accept on PhoneB, receive receive on PhoneA.
521
522        Returns:
523            True if pass; False if fail.
524        """
525        ads = self.android_devices
526        # make sure PhoneA is GSM phone before proceed.
527        if (ads[0].droid.telephonyGetPhoneType() != PHONE_TYPE_GSM):
528            self.log.error("Not GSM phone, abort this csfb wcdma SMS test.")
529            return False
530
531        tasks = [(phone_setup_csfb, (self.log, ads[0])),
532                 (phone_setup_voice_general, (self.log, ads[1]))]
533        if not multithread_func(self.log, tasks):
534            self.log.error("Phone Failed to Set Up Properly.")
535            return False
536
537        self.log.info("Begin In Call SMS Test.")
538        if not call_setup_teardown(self.log,
539                                   ads[0],
540                                   ads[1],
541                                   ad_hangup=None,
542                                   verify_caller_func=is_phone_in_call_csfb,
543                                   verify_callee_func=None):
544            return False
545
546        if not self._sms_test_mt(ads):
547            self.log.error("SMS test fail.")
548            return False
549
550        return True
551
552    @TelephonyBaseTest.tel_test_wrap
553    def test_sms_mo_in_call_1x(self):
554        """ Test MO SMS during a MO 1x call.
555
556        Make Sure PhoneA is in 1x mode.
557        Make Sure PhoneB is able to make/receive call.
558        Call from PhoneA to PhoneB, accept on PhoneB, send SMS on PhoneA.
559
560        Returns:
561            True if pass; False if fail.
562        """
563        ads = self.android_devices
564        # make sure PhoneA is CDMA phone before proceed.
565        if (ads[0].droid.telephonyGetPhoneType() != PHONE_TYPE_CDMA):
566            self.log.error("Not CDMA phone, abort this 1x SMS test.")
567            return False
568
569        tasks = [(phone_setup_3g, (self.log, ads[0])),
570                 (phone_setup_voice_general, (self.log, ads[1]))]
571        if not multithread_func(self.log, tasks):
572            self.log.error("Phone Failed to Set Up Properly.")
573            return False
574
575        self.log.info("Begin In Call SMS Test.")
576        if not call_setup_teardown(self.log,
577                                   ads[0],
578                                   ads[1],
579                                   ad_hangup=None,
580                                   verify_caller_func=is_phone_in_call_1x,
581                                   verify_callee_func=None):
582            return False
583
584        if not self._sms_test_mo(ads):
585            self.log.error("SMS test fail.")
586            return False
587
588        return True
589
590    @TelephonyBaseTest.tel_test_wrap
591    def test_sms_mt_in_call_1x(self):
592        """ Test MT SMS during a MO 1x call.
593
594        Make Sure PhoneA is in 1x mode.
595        Make Sure PhoneB is able to make/receive call.
596        Call from PhoneA to PhoneB, accept on PhoneB, receive SMS on PhoneA.
597
598        Returns:
599            True if pass; False if fail.
600        """
601        ads = self.android_devices
602        # make sure PhoneA is CDMA phone before proceed.
603        if (ads[0].droid.telephonyGetPhoneType() != PHONE_TYPE_CDMA):
604            self.log.error("Not CDMA phone, abort this 1x SMS test.")
605            return False
606
607        tasks = [(phone_setup_3g, (self.log, ads[0])),
608                 (phone_setup_voice_general, (self.log, ads[1]))]
609        if not multithread_func(self.log, tasks):
610            self.log.error("Phone Failed to Set Up Properly.")
611            return False
612
613        self.log.info("Begin In Call SMS Test.")
614        if not call_setup_teardown(self.log,
615                                   ads[0],
616                                   ads[1],
617                                   ad_hangup=None,
618                                   verify_caller_func=is_phone_in_call_1x,
619                                   verify_callee_func=None):
620            return False
621
622        if not self._sms_test_mt(ads):
623            self.log.error("SMS test fail.")
624            return False
625
626        return True
627
628    @TelephonyBaseTest.tel_test_wrap
629    def test_sms_mo_in_call_csfb_1x(self):
630        """ Test MO SMS during a MO csfb 1x call.
631
632        Make Sure PhoneA is in LTE mode (no VoLTE).
633        Make Sure PhoneB is able to make/receive call.
634        Call from PhoneA to PhoneB, accept on PhoneB, send SMS on PhoneA.
635
636        Returns:
637            True if pass; False if fail.
638        """
639        ads = self.android_devices
640        # make sure PhoneA is CDMA phone before proceed.
641        if (ads[0].droid.telephonyGetPhoneType() != PHONE_TYPE_CDMA):
642            self.log.error("Not CDMA phone, abort this csfb 1x SMS test.")
643            return False
644
645        tasks = [(phone_setup_csfb, (self.log, ads[0])),
646                 (phone_setup_voice_general, (self.log, ads[1]))]
647        if not multithread_func(self.log, tasks):
648            self.log.error("Phone Failed to Set Up Properly.")
649            return False
650
651        self.log.info("Begin In Call SMS Test.")
652        if not call_setup_teardown(self.log,
653                                   ads[0],
654                                   ads[1],
655                                   ad_hangup=None,
656                                   verify_caller_func=is_phone_in_call_1x,
657                                   verify_callee_func=None):
658            return False
659
660        if not self._sms_test_mo(ads):
661            self.log.error("SMS test fail.")
662            return False
663
664        return True
665
666    @TelephonyBaseTest.tel_test_wrap
667    def test_sms_mt_in_call_csfb_1x(self):
668        """ Test MT SMS during a MO csfb 1x call.
669
670        Make Sure PhoneA is in LTE mode (no VoLTE).
671        Make Sure PhoneB is able to make/receive call.
672        Call from PhoneA to PhoneB, accept on PhoneB, receive SMS on PhoneA.
673
674        Returns:
675            True if pass; False if fail.
676        """
677        ads = self.android_devices
678        # make sure PhoneA is CDMA phone before proceed.
679        if (ads[0].droid.telephonyGetPhoneType() != PHONE_TYPE_CDMA):
680            self.log.error("Not CDMA phone, abort this csfb 1x SMS test.")
681            return False
682
683        tasks = [(phone_setup_csfb, (self.log, ads[0])),
684                 (phone_setup_voice_general, (self.log, ads[1]))]
685        if not multithread_func(self.log, tasks):
686            self.log.error("Phone Failed to Set Up Properly.")
687            return False
688
689        self.log.info("Begin In Call SMS Test.")
690        if not call_setup_teardown(self.log,
691                                   ads[0],
692                                   ads[1],
693                                   ad_hangup=None,
694                                   verify_caller_func=is_phone_in_call_1x,
695                                   verify_callee_func=None):
696            return False
697
698        if not self._sms_test_mt(ads):
699            self.log.error("SMS test fail.")
700            return False
701
702        return True
703
704    @TelephonyBaseTest.tel_test_wrap
705    def test_sms_mo_iwlan(self):
706        """ Test MO SMS, Phone in APM, WiFi connected, WFC WiFi Preferred mode.
707
708        Make Sure PhoneA APM, WiFi connected, WFC WiFi preferred mode.
709        Make sure PhoneA report iwlan as data rat.
710        Make Sure PhoneB is able to make/receive call/sms.
711        Send SMS on PhoneA.
712
713        Returns:
714            True if pass; False if fail.
715        """
716
717        ads = self.android_devices
718
719        tasks = [(phone_setup_iwlan,
720                  (self.log, ads[0], True, WFC_MODE_WIFI_PREFERRED,
721                   self.wifi_network_ssid, self.wifi_network_pass)),
722                 (phone_setup_voice_general, (self.log, ads[1]))]
723        if not multithread_func(self.log, tasks):
724            self.log.error("Phone Failed to Set Up Properly.")
725            return False
726
727        return self._sms_test_mo(ads)
728
729    @TelephonyBaseTest.tel_test_wrap
730    def test_sms_mt_iwlan(self):
731        """ Test MT SMS, Phone in APM, WiFi connected, WFC WiFi Preferred mode.
732
733        Make Sure PhoneA APM, WiFi connected, WFC WiFi preferred mode.
734        Make sure PhoneA report iwlan as data rat.
735        Make Sure PhoneB is able to make/receive call/sms.
736        Receive SMS on PhoneA.
737
738        Returns:
739            True if pass; False if fail.
740        """
741
742        ads = self.android_devices
743
744        tasks = [(phone_setup_iwlan,
745                  (self.log, ads[0], True, WFC_MODE_WIFI_PREFERRED,
746                   self.wifi_network_ssid, self.wifi_network_pass)),
747                 (phone_setup_voice_general, (self.log, ads[1]))]
748        if not multithread_func(self.log, tasks):
749            self.log.error("Phone Failed to Set Up Properly.")
750            return False
751
752        return self._sms_test_mt(ads)
753
754    @TelephonyBaseTest.tel_test_wrap
755    def test_sms_mo_in_call_iwlan(self):
756        """ Test MO SMS, Phone in APM, WiFi connected, WFC WiFi Preferred mode.
757
758        Make Sure PhoneA APM, WiFi connected, WFC WiFi preferred mode.
759        Make sure PhoneA report iwlan as data rat.
760        Make Sure PhoneB is able to make/receive call/sms.
761        Call from PhoneA to PhoneB, accept on PhoneB.
762        Send SMS on PhoneA.
763
764        Returns:
765            True if pass; False if fail.
766        """
767
768        ads = self.android_devices
769
770        tasks = [(phone_setup_iwlan,
771                  (self.log, ads[0], True, WFC_MODE_WIFI_PREFERRED,
772                   self.wifi_network_ssid, self.wifi_network_pass)),
773                 (phone_setup_voice_general, (self.log, ads[1]))]
774        if not multithread_func(self.log, tasks):
775            self.log.error("Phone Failed to Set Up Properly.")
776            return False
777
778        self.log.info("Begin In Call SMS Test.")
779        if not call_setup_teardown(self.log,
780                                   ads[0],
781                                   ads[1],
782                                   ad_hangup=None,
783                                   verify_caller_func=is_phone_in_call_iwlan,
784                                   verify_callee_func=None):
785            return False
786
787        return self._sms_test_mo(ads)
788
789    @TelephonyBaseTest.tel_test_wrap
790    def test_sms_mt_in_call_iwlan(self):
791        """ Test MT SMS, Phone in APM, WiFi connected, WFC WiFi Preferred mode.
792
793        Make Sure PhoneA APM, WiFi connected, WFC WiFi preferred mode.
794        Make sure PhoneA report iwlan as data rat.
795        Make Sure PhoneB is able to make/receive call/sms.
796        Call from PhoneA to PhoneB, accept on PhoneB.
797        Receive SMS on PhoneA.
798
799        Returns:
800            True if pass; False if fail.
801        """
802
803        ads = self.android_devices
804
805        tasks = [(phone_setup_iwlan,
806                  (self.log, ads[0], True, WFC_MODE_WIFI_PREFERRED,
807                   self.wifi_network_ssid, self.wifi_network_pass)),
808                 (phone_setup_voice_general, (self.log, ads[1]))]
809        if not multithread_func(self.log, tasks):
810            self.log.error("Phone Failed to Set Up Properly.")
811            return False
812
813        self.log.info("Begin In Call SMS Test.")
814        if not call_setup_teardown(self.log,
815                                   ads[0],
816                                   ads[1],
817                                   ad_hangup=None,
818                                   verify_caller_func=is_phone_in_call_iwlan,
819                                   verify_callee_func=None):
820            return False
821
822        return self._sms_test_mt(ads)
823
824    @TelephonyBaseTest.tel_test_wrap
825    def test_sms_mo_in_call_vt(self):
826        """ Test MO SMS, Phone in ongoing VT call.
827
828        Make Sure PhoneA and PhoneB in LTE and can make VT call.
829        Make Video Call from PhoneA to PhoneB, accept on PhoneB as Video Call.
830        Send SMS on PhoneA.
831
832        Returns:
833            True if pass; False if fail.
834        """
835        ads = self.android_devices
836
837        tasks = [(phone_setup_video, (self.log, ads[0])), (phone_setup_video,
838                                                           (self.log, ads[1]))]
839        if not multithread_func(self.log, tasks):
840            self.log.error("Phone Failed to Set Up Properly.")
841            return False
842
843        if not video_call_setup_teardown(
844                self.log,
845                ads[0],
846                ads[1],
847                None,
848                video_state=VT_STATE_BIDIRECTIONAL,
849                verify_caller_func=is_phone_in_call_video_bidirectional,
850                verify_callee_func=is_phone_in_call_video_bidirectional):
851            self.log.error("Failed to setup a call")
852            return False
853
854        return self._sms_test_mo(ads)
855
856    @TelephonyBaseTest.tel_test_wrap
857    def test_sms_mt_in_call_vt(self):
858        """ Test MT SMS, Phone in ongoing VT call.
859
860        Make Sure PhoneA and PhoneB in LTE and can make VT call.
861        Make Video Call from PhoneA to PhoneB, accept on PhoneB as Video Call.
862        Receive SMS on PhoneA.
863
864        Returns:
865            True if pass; False if fail.
866        """
867        ads = self.android_devices
868
869        tasks = [(phone_setup_video, (self.log, ads[0])), (phone_setup_video,
870                                                           (self.log, ads[1]))]
871        if not multithread_func(self.log, tasks):
872            self.log.error("Phone Failed to Set Up Properly.")
873            return False
874
875        if not video_call_setup_teardown(
876                self.log,
877                ads[0],
878                ads[1],
879                None,
880                video_state=VT_STATE_BIDIRECTIONAL,
881                verify_caller_func=is_phone_in_call_video_bidirectional,
882                verify_callee_func=is_phone_in_call_video_bidirectional):
883            self.log.error("Failed to setup a call")
884            return False
885
886        return self._sms_test_mt(ads)
887
888    @TelephonyBaseTest.tel_test_wrap
889    def test_mms_mo_4g(self):
890        """Test MMS text function between two phone. Phones in LTE network.
891
892        Airplane mode is off.
893        Send SMS from PhoneA to PhoneB.
894        Verify received message on PhoneB is correct.
895
896        Returns:
897            True if success.
898            False if failed.
899        """
900
901        self.log.error("Test Case is non-functional: b/21569494")
902        return False
903
904        ads = self.android_devices
905
906        tasks = [(phone_setup_csfb, (self.log, ads[0])),
907                 (phone_setup_voice_general, (self.log, ads[1]))]
908        if not multithread_func(self.log, tasks):
909            self.log.error("Phone Failed to Set Up Properly.")
910            return False
911
912        return mms_send_receive_verify(
913            self.log, ads[0], ads[1],
914            [("Test Message", "Basic Message Body", None)])
915
916    @TelephonyBaseTest.tel_test_wrap
917    def test_mms_mt_4g(self):
918        """Test MMS text function between two phone. Phones in LTE network.
919
920        Airplane mode is off.
921        Send SMS from PhoneB to PhoneA.
922        Verify received message on PhoneA is correct.
923
924        Returns:
925            True if success.
926            False if failed.
927        """
928
929        self.log.error("Test Case is non-functional: b/21569494")
930        return False
931
932        ads = self.android_devices
933
934        tasks = [(phone_setup_csfb, (self.log, ads[0])),
935                 (phone_setup_voice_general, (self.log, ads[1]))]
936        if not multithread_func(self.log, tasks):
937            self.log.error("Phone Failed to Set Up Properly.")
938            return False
939
940        return mms_send_receive_verify(
941            self.log, ads[1], ads[0],
942            [("Test Message", "Basic Message Body", None)])
943
944    @TelephonyBaseTest.tel_test_wrap
945    def test_sms_mo_in_call_gsm(self):
946        """ Test MO SMS during a MO gsm call.
947
948        Make Sure PhoneA is in gsm mode.
949        Make Sure PhoneB is able to make/receive call.
950        Call from PhoneA to PhoneB, accept on PhoneB, send SMS on PhoneA.
951
952        Returns:
953            True if pass; False if fail.
954        """
955        ads = self.android_devices
956        # make sure PhoneA is GSM phone before proceed.
957        if (ads[0].droid.telephonyGetPhoneType() != PHONE_TYPE_GSM):
958            self.log.error("Not GSM phone, abort this gsm SMS test.")
959            return False
960
961        tasks = [(phone_setup_voice_2g, (self.log, ads[0])),
962                 (phone_setup_voice_general, (self.log, ads[1]))]
963        if not multithread_func(self.log, tasks):
964            self.log.error("Phone Failed to Set Up Properly.")
965            return False
966
967        self.log.info("Begin In Call SMS Test.")
968        if not call_setup_teardown(self.log,
969                                   ads[0],
970                                   ads[1],
971                                   ad_hangup=None,
972                                   verify_caller_func=is_phone_in_call_2g,
973                                   verify_callee_func=None):
974            return False
975
976        if not self._sms_test_mo(ads):
977            self.log.error("SMS test fail.")
978            return False
979
980        return True
981
982    @TelephonyBaseTest.tel_test_wrap
983    def test_sms_mt_in_call_gsm(self):
984        """ Test MT SMS during a MO gsm call.
985
986        Make Sure PhoneA is in gsm mode.
987        Make Sure PhoneB is able to make/receive call.
988        Call from PhoneA to PhoneB, accept on PhoneB, receive SMS on PhoneA.
989
990        Returns:
991            True if pass; False if fail.
992        """
993        ads = self.android_devices
994        # make sure PhoneA is GSM phone before proceed.
995        if (ads[0].droid.telephonyGetPhoneType() != PHONE_TYPE_GSM):
996            self.log.error("Not GSM phone, abort this gsm SMS test.")
997            return False
998
999        tasks = [(phone_setup_voice_2g, (self.log, ads[0])),
1000                 (phone_setup_voice_general, (self.log, ads[1]))]
1001        if not multithread_func(self.log, tasks):
1002            self.log.error("Phone Failed to Set Up Properly.")
1003            return False
1004
1005        self.log.info("Begin In Call SMS Test.")
1006        if not call_setup_teardown(self.log,
1007                                   ads[0],
1008                                   ads[1],
1009                                   ad_hangup=None,
1010                                   verify_caller_func=is_phone_in_call_2g,
1011                                   verify_callee_func=None):
1012            return False
1013
1014        if not self._sms_test_mt(ads):
1015            self.log.error("SMS test fail.")
1016            return False
1017
1018        return True
1019
1020    """ Tests End """
1021