blob: ffa4c6ef7dafec56cc4d4e807b15e649cce4bc79 [file] [log] [blame]
Jaineel4e4a96a2020-12-03 15:11:10 -08001#!/usr/bin/env python3.4
2#
3# Copyright 2020 - 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 5G SMS scenarios
18"""
19
20import time
Pratik Shethaec72b72021-02-09 15:44:28 -080021from acts.utils import rand_ascii_str
Jaineel4e4a96a2020-12-03 15:11:10 -080022from acts.test_decorators import test_tracker_info
23from acts_contrib.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
24from acts_contrib.test_utils.tel.tel_defines import WAIT_TIME_ANDROID_STATE_SETTLING
Pratik Shethaec72b72021-02-09 15:44:28 -080025from acts_contrib.test_utils.tel.tel_test_utils import ensure_phones_idle
Pei Huang47d6a0b2021-04-05 23:35:49 +080026from acts_contrib.test_utils.tel.tel_test_utils import hangup_call
Jaineel4e4a96a2020-12-03 15:11:10 -080027from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_iwlan
Pratik Shethaec72b72021-02-09 15:44:28 -080028from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_volte
Pei Huang47d6a0b2021-04-05 23:35:49 +080029from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_csfb
Jaineel78a57152020-12-08 17:03:00 -080030from acts_contrib.test_utils.tel.tel_5g_utils import disable_apm_mode_both_devices
Pratik Sheth0df9f222021-04-05 17:55:51 -070031from acts_contrib.test_utils.tel.tel_5g_utils import provision_device_for_5g
Jaineel78a57152020-12-08 17:03:00 -080032from acts_contrib.test_utils.tel.tel_5g_utils import provision_both_devices_for_volte
33from acts_contrib.test_utils.tel.tel_5g_utils import provision_both_devices_for_wfc_cell_pref
34from acts_contrib.test_utils.tel.tel_5g_utils import provision_both_devices_for_wfc_wifi_pref
35from acts_contrib.test_utils.tel.tel_5g_utils import verify_5g_attach_for_both_devices
Pei Huang47d6a0b2021-04-05 23:35:49 +080036from acts_contrib.test_utils.tel.tel_5g_utils import provision_both_devices_for_csfb
Pratik Shethaec72b72021-02-09 15:44:28 -080037from acts_contrib.test_utils.tel.tel_sms_utils import _sms_test_mo
Pratik Shethaec72b72021-02-09 15:44:28 -080038from acts_contrib.test_utils.tel.tel_sms_utils import _long_sms_test_mo
Pei Huang47d6a0b2021-04-05 23:35:49 +080039from acts_contrib.test_utils.tel.tel_sms_utils import test_sms_mo_in_call
Jaineel78a57152020-12-08 17:03:00 -080040
Jaineel4e4a96a2020-12-03 15:11:10 -080041
42class Nsa5gSmsTest(TelephonyBaseTest):
43 def setup_class(self):
44 super().setup_class()
Jaineel4e4a96a2020-12-03 15:11:10 -080045
46 def setup_test(self):
47 TelephonyBaseTest.setup_test(self)
48
49 def teardown_test(self):
50 ensure_phones_idle(self.log, self.android_devices)
51
Jaineel4e4a96a2020-12-03 15:11:10 -080052
Jaineel4e4a96a2020-12-03 15:11:10 -080053 """ Tests Begin """
54
Pratik Shethf9d0d2b2021-03-19 15:38:44 -070055
Jaineel4e4a96a2020-12-03 15:11:10 -080056 @test_tracker_info(uuid="4a64a262-7433-4a7f-b5c6-a36ff60aeaa2")
57 @TelephonyBaseTest.tel_test_wrap
58 def test_5g_nsa_sms_mo_mt(self):
59 """Test SMS between two phones in 5g NSA
60
61 Provision devices in 5g NSA
62 Send and Verify SMS from PhoneA to PhoneB
63 Verify both devices are still on 5g NSA
64
65 Returns:
66 True if success.
67 False if failed.
68 """
69 ads = self.android_devices
Pratik Sheth0df9f222021-04-05 17:55:51 -070070 if not provision_device_for_5g(self.log, ads):
Jaineel4e4a96a2020-12-03 15:11:10 -080071 return False
72
Pratik Shethaec72b72021-02-09 15:44:28 -080073 if not _sms_test_mo(self.log, ads):
Jaineel4e4a96a2020-12-03 15:11:10 -080074 return False
75
Jaineel78a57152020-12-08 17:03:00 -080076 if not verify_5g_attach_for_both_devices(self.log, ads):
Jaineel4e4a96a2020-12-03 15:11:10 -080077 return False
78
79 self.log.info("PASS - SMS test over 5G NSA validated")
80 return True
81
Pratik Shethf9d0d2b2021-03-19 15:38:44 -070082
Jaineel4e4a96a2020-12-03 15:11:10 -080083 @test_tracker_info(uuid="2ce809d4-cbf6-4233-81ad-43f91107b201")
84 @TelephonyBaseTest.tel_test_wrap
85 def test_5g_nsa_sms_mo_mt_volte(self):
86 """Test SMS between two phones with VoLTE on 5G NSA
87
88 Provision devices on VoLTE
89 Provision devices in 5g NSA
90 Send and Verify SMS from PhoneA to PhoneB
91 Verify both devices are still on 5g NSA
92
93 Returns:
94 True if success.
95 False if failed.
96 """
97
98 ads = self.android_devices
Jaineel78a57152020-12-08 17:03:00 -080099 if not provision_both_devices_for_volte(self.log, ads):
Jaineel4e4a96a2020-12-03 15:11:10 -0800100 return False
101
Pratik Sheth0df9f222021-04-05 17:55:51 -0700102 if not provision_device_for_5g(self.log, ads):
Jaineel4e4a96a2020-12-03 15:11:10 -0800103 return False
104
Pratik Shethaec72b72021-02-09 15:44:28 -0800105 if not _sms_test_mo(self.log, ads):
Jaineel4e4a96a2020-12-03 15:11:10 -0800106 return False
107
Pei Huang47d6a0b2021-04-05 23:35:49 +0800108 if not hangup_call(self.log, ads[0]):
109 ads[0].log.info("Failed to hang up call.!")
110 return False
111
Jaineel78a57152020-12-08 17:03:00 -0800112 if not verify_5g_attach_for_both_devices(self.log, ads):
Jaineel4e4a96a2020-12-03 15:11:10 -0800113 return False
114
115 self.log.info("PASS - VoLTE SMS test over 5G NSA validated")
116 return True
117
Pratik Shethf9d0d2b2021-03-19 15:38:44 -0700118
Jaineel4e4a96a2020-12-03 15:11:10 -0800119 @test_tracker_info(uuid="49bfb4b3-a6ec-45d4-ad96-09282fb07d1d")
120 @TelephonyBaseTest.tel_test_wrap
121 def test_5g_nsa_sms_mo_mt_in_call_volte(self):
122 """ Test MO SMS during a MO VoLTE call over 5G NSA.
123
124 Provision devices on VoLTE
125 Provision devices in 5g NSA
126 Make a Voice call from PhoneA to PhoneB
127 Send and Verify SMS from PhoneA to PhoneB
128 Verify both devices are still on 5g NSA
129
130 Returns:
131 True if pass; False if fail.
132 """
133 ads = self.android_devices
Jaineel78a57152020-12-08 17:03:00 -0800134 if not provision_both_devices_for_volte(self.log, ads):
Jaineel4e4a96a2020-12-03 15:11:10 -0800135 return False
136 time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING)
137
Pratik Sheth0df9f222021-04-05 17:55:51 -0700138 if not provision_device_for_5g(self.log, ads):
Jaineel4e4a96a2020-12-03 15:11:10 -0800139 return False
140
Pei Huang47d6a0b2021-04-05 23:35:49 +0800141 if not test_sms_mo_in_call(self.log,
142 ads,
143 caller_func=is_phone_in_call_volte):
Jaineel4e4a96a2020-12-03 15:11:10 -0800144 return False
145
Jaineel78a57152020-12-08 17:03:00 -0800146 if not verify_5g_attach_for_both_devices(self.log, ads):
Jaineel4e4a96a2020-12-03 15:11:10 -0800147 return False
148 return True
149
Pratik Shethf9d0d2b2021-03-19 15:38:44 -0700150
Jaineel4e4a96a2020-12-03 15:11:10 -0800151 @test_tracker_info(uuid="1f914d5c-ac24-4794-9fcb-cb28e483d69a")
152 @TelephonyBaseTest.tel_test_wrap
153 def test_5g_nsa_sms_mo_mt_iwlan(self):
154 """ Test SMS text function between two phones,
155 Phones in APM, WiFi connected, WFC Cell Preferred mode.
156
157 Disable APM on both devices
158 Provision devices in 5g NSA
159 Provision devices for WFC Cell Pref with APM ON
160 Send and Verify SMS from PhoneA to PhoneB
161
162 Returns:
163 True if pass; False if fail.
164 """
165
166 ads = self.android_devices
Jaineel78a57152020-12-08 17:03:00 -0800167 if not disable_apm_mode_both_devices(self.log, ads):
Jaineel4e4a96a2020-12-03 15:11:10 -0800168 return False
169
Pratik Sheth0df9f222021-04-05 17:55:51 -0700170 if not provision_device_for_5g(self.log, ads):
Jaineel4e4a96a2020-12-03 15:11:10 -0800171 return False
172
Jaineel78a57152020-12-08 17:03:00 -0800173 if not provision_both_devices_for_wfc_cell_pref(self.log,
174 ads,
175 self.wifi_network_ssid,
176 self.wifi_network_pass,
177 apm_mode=True):
Jaineel4e4a96a2020-12-03 15:11:10 -0800178 return False
179 time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING)
180
Pratik Shethaec72b72021-02-09 15:44:28 -0800181 if not _sms_test_mo(self.log, ads):
Jaineel4e4a96a2020-12-03 15:11:10 -0800182 return False
183
Jaineel78a57152020-12-08 17:03:00 -0800184 self.log.info("PASS - iwlan sms test over 5g nsa validated")
Jaineel4e4a96a2020-12-03 15:11:10 -0800185 return True
186
Pratik Shethf9d0d2b2021-03-19 15:38:44 -0700187
Jaineel4e4a96a2020-12-03 15:11:10 -0800188 @test_tracker_info(uuid="7274be32-b9dd-4ce3-83d1-f32ab14ce05e")
189 @TelephonyBaseTest.tel_test_wrap
190 def test_5g_nsa_sms_mo_mt_iwlan_apm_off(self):
191 """ Test MO SMS, Phone in APM off, WiFi connected, WFC WiFi Preferred mode.
192
193 Disable APM on both devices
194 Provision devices in 5g NSA
195 Provision devices for WFC Wifi Pref with APM OFF
196 Send and Verify SMS from PhoneA to PhoneB
197 Verify 5g NSA attach for both devices
198
199 Returns:
200 True if pass; False if fail.
201 """
202
203 ads = self.android_devices
Jaineel78a57152020-12-08 17:03:00 -0800204 if not disable_apm_mode_both_devices(self.log, ads):
Jaineel4e4a96a2020-12-03 15:11:10 -0800205 return False
206
Pratik Sheth0df9f222021-04-05 17:55:51 -0700207 if not provision_device_for_5g(self.log, ads):
Jaineel4e4a96a2020-12-03 15:11:10 -0800208 return False
209
Jaineel78a57152020-12-08 17:03:00 -0800210 if not provision_both_devices_for_wfc_wifi_pref(self.log,
211 ads,
212 self.wifi_network_ssid,
213 self.wifi_network_pass,
214 apm_mode=False):
Jaineel4e4a96a2020-12-03 15:11:10 -0800215 return False
216 time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING)
217
Pratik Shethaec72b72021-02-09 15:44:28 -0800218 if not _sms_test_mo(self.log, ads):
Jaineel78a57152020-12-08 17:03:00 -0800219 self.log.error("failed to send receive sms over 5g nsa")
Jaineel4e4a96a2020-12-03 15:11:10 -0800220 return False
Jaineel78a57152020-12-08 17:03:00 -0800221 self.log.info("PASS - iwlan sms test over 5g nsa validated")
Jaineel4e4a96a2020-12-03 15:11:10 -0800222
Jaineel78a57152020-12-08 17:03:00 -0800223 if not verify_5g_attach_for_both_devices(self.log, ads):
Jaineel4e4a96a2020-12-03 15:11:10 -0800224 return False
225 return True
226
Pratik Shethf9d0d2b2021-03-19 15:38:44 -0700227
Jaineel4e4a96a2020-12-03 15:11:10 -0800228 @test_tracker_info(uuid="2d1787f2-d6fe-4b41-b389-2a8f817594e4")
229 @TelephonyBaseTest.tel_test_wrap
230 def test_5g_nsa_sms_mo_mt_in_call_iwlan(self):
231 """ Test MO SMS, Phone in APM, WiFi connected, WFC WiFi Preferred mode.
232
233 Disable APM on both devices
234 Provision devices in 5g NSA
235 Provision devices for WFC Wifi Pref with APM ON
236 Make a Voice call from PhoneA to PhoneB
237 Send and Verify SMS from PhoneA to PhoneB
238
239 Returns:
240 True if pass; False if fail.
241 """
242
243 ads = self.android_devices
244
Jaineel78a57152020-12-08 17:03:00 -0800245 if not disable_apm_mode_both_devices(self.log, ads):
Jaineel4e4a96a2020-12-03 15:11:10 -0800246 return False
247
Pratik Sheth0df9f222021-04-05 17:55:51 -0700248 if not provision_device_for_5g(self.log, ads):
Jaineel4e4a96a2020-12-03 15:11:10 -0800249 return False
250
Jaineel78a57152020-12-08 17:03:00 -0800251 if not provision_both_devices_for_wfc_wifi_pref(self.log,
252 ads,
253 self.wifi_network_ssid,
254 self.wifi_network_pass,
255 apm_mode=True):
Jaineel4e4a96a2020-12-03 15:11:10 -0800256 return False
257 time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING)
258
Pei Huang47d6a0b2021-04-05 23:35:49 +0800259 return test_sms_mo_in_call(self.log,
260 ads,
261 caller_func=is_phone_in_call_iwlan)
Jaineel4e4a96a2020-12-03 15:11:10 -0800262
Pratik Shethf9d0d2b2021-03-19 15:38:44 -0700263
Pratik Sheth8ad702b2021-03-05 09:44:49 -0800264 @test_tracker_info(uuid="784062e8-02a4-49ce-8fc1-5359ab40bbdd")
Pratik Shethaec72b72021-02-09 15:44:28 -0800265 @TelephonyBaseTest.tel_test_wrap
266 def test_5g_nsa_sms_long_message_mo_mt(self):
267 """Test SMS basic function between two phone. Phones in nsa 5G network.
268
269 Airplane mode is off.
270 Send SMS from PhoneA to PhoneB.
271 Verify received message on PhoneB is correct.
272
273 Returns:
274 True if success.
275 False if failed.
276 """
277
278 ads = self.android_devices
279
280 if not disable_apm_mode_both_devices(self.log, ads):
281 return False
282
Pratik Sheth0df9f222021-04-05 17:55:51 -0700283 if not provision_device_for_5g(self.log, ads):
Pratik Shethaec72b72021-02-09 15:44:28 -0800284 return False
285
286 return _long_sms_test_mo(self.log, ads)
287
Jaineel4e4a96a2020-12-03 15:11:10 -0800288
Pratik Sheth0df9f222021-04-05 17:55:51 -0700289 @test_tracker_info(uuid="45dbd61a-6a90-473e-9cfa-03e2408d5f15")
Pei Huang47d6a0b2021-04-05 23:35:49 +0800290 @TelephonyBaseTest.tel_test_wrap
291 def test_5g_nsa_sms_mo_mt_in_call_csfb(self):
292 """ Test MO/MT SMS during a MO csfb call over 5G NSA.
293
294 Disable APM on both devices
295 Set up PhoneA/B are in CSFB mode.
296 Provision PhoneA/B in 5g NSA.
297 Make sure PhoneA/B is able to make/receive call.
298 Call from PhoneA to PhoneB, accept on PhoneB, send SMS on PhoneA,
299 receive SMS on PhoneB.
300
301 Returns:
302 True if pass; False if fail.
303 """
304 ads = self.android_devices
305
306 if not disable_apm_mode_both_devices(self.log, ads):
307 return False
308
309 if not provision_both_devices_for_csfb(self.log, ads):
310 return False
311 time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING)
312
313 if not provision_both_devices_for_5g(self.log, ads):
314 return False
315
316 return test_sms_mo_in_call(self.log,
317 ads,
318 caller_func=is_phone_in_call_csfb)
319
Jaineel4e4a96a2020-12-03 15:11:10 -0800320 """ Tests End """