• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3.4
2#
3#   Copyright 2018 - 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 time
18from acts_contrib.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
19from acts_contrib.test_utils.tel.tel_defines import MULTI_SIM_CONFIG, WAIT_TIME_ANDROID_STATE_SETTLING
20from acts_contrib.test_utils.tel.tel_message_utils import sms_send_receive_verify
21from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_setup_voice_general_for_slot
22from acts_contrib.test_utils.tel.tel_subscription_utils import get_subid_from_slot_index, set_subid_for_message
23from acts.libs.utils.multithread import multithread_func
24from acts.test_decorators import test_tracker_info
25from acts.utils import rand_ascii_str
26
27
28class TelLiveMSIMSmsTest(TelephonyBaseTest):
29    def setup_class(self):
30        super().setup_class()
31        self.numer_of_slots = 2
32        self.sim_config = { "config": MULTI_SIM_CONFIG,
33                            "number_of_sims": 2 }
34        self.message_lengths = (50, 160, 180)
35
36    def _sms_test_dsds(self, ads):
37        """Test SMS between two phones on multiple sub_id
38
39        Returns:
40            True if success.
41            False if failed.
42        """
43        for slot in range(self.sim_config["number_of_sims"]):
44            set_subid_for_message(
45                ads[0], get_subid_from_slot_index(self.log,ads[0],slot))
46            set_subid_for_message(
47                ads[1], get_subid_from_slot_index(self.log,ads[1],slot))
48            for length in self.message_lengths:
49                message_array = [rand_ascii_str(length)]
50                ads[0].log.info("SMS Test - length %s from slot %s to slot %s",
51                                 length, slot, slot)
52                if not sms_send_receive_verify(self.log, ads[0], ads[1],
53                                              message_array, slot_id_rx = slot):
54                    ads[0].log.warning(
55                        "SMS of length %s test failed from slot %s to slot %s",
56                         length, slot, slot)
57                    return False
58                ads[0].log.info("SMS Test - length %s from slot %s to slot %s",
59                                length, slot, 1-slot)
60                if not sms_send_receive_verify(self.log, ads[0], ads[1],
61                                            message_array, slot_id_rx = 1-slot):
62                    ads[0].log.warning(
63                        "SMS of length %s test failed from slot %s to slot %s",
64                        length, slot, 1-slot)
65                    return False
66                else:
67                    ads[0].log.info("SMS of length %s test succeeded", length)
68            self.log.info("SMS test of length %s characters succeeded.",
69                          self.message_lengths)
70        return True
71
72    @test_tracker_info(uuid="5c0b60d0-a963-4ccf-8c0a-3d968b99d3cd")
73    @TelephonyBaseTest.tel_test_wrap
74    def test_msim_sms_general(self):
75        """Test SMS basic function between two phone. Phones in any network.
76
77        Airplane mode is off.
78        Send SMS from PhoneA (sub_id 0 and 1) to PhoneB (sub_id 0 and 1)
79        Verify received message on PhoneB is correct.
80
81        Returns:
82            True if success.
83            False if failed.
84        """
85        ads = self.android_devices
86
87        tasks = [(phone_setup_voice_general_for_slot, (self.log, ads[0],0)),
88                 (phone_setup_voice_general_for_slot, (self.log, ads[1],0)),
89                 (phone_setup_voice_general_for_slot, (self.log, ads[0],1)),
90                 (phone_setup_voice_general_for_slot, (self.log, ads[1],1))
91                 ]
92
93        if not multithread_func(self.log, tasks):
94            self.log.error("Phone Failed to Set Up Properly.")
95            return False
96        time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING)
97
98        return self._sms_test_dsds(ads)
99
100